From 5d95ba96c99debdba0f7cf6219651a2a19309c26 Mon Sep 17 00:00:00 2001 From: Nazarii Denha Date: Mon, 11 Dec 2023 08:13:31 +0100 Subject: [PATCH] fix: conflicts in library for blockhash pr (#591) * feat: change `BLOCKHASH` opcode behavior to `keccak(chain_id || block_number)` * fix conflicts in library --------- Co-authored-by: HAOYUatHZ Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- build/ci.go | 2 +- core/vm/instructions.go | 5 ++++- go.mod | 2 +- go.sum | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build/ci.go b/build/ci.go index 46f1ac28121a..f3f49bc847c0 100644 --- a/build/ci.go +++ b/build/ci.go @@ -285,7 +285,7 @@ func doTest(cmdline []string) { coverage = flag.Bool("coverage", false, "Whether to record code coverage") verbose = flag.Bool("v", false, "Whether to log verbosely") race = flag.Bool("race", false, "Execute the race detector") - short = flag.Bool("short", false, "Pass the 'short'-flag to go test") + short = flag.Bool("short", false, "Pass the 'short'-flag to go test") cachedir = flag.String("cachedir", "./build/cache", "directory for caching downloads") ) flag.CommandLine.Parse(cmdline) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 8c021833c935..2e1a5f7c3dba 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -17,11 +17,14 @@ package vm import ( + "encoding/binary" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" + "golang.org/x/crypto/sha3" ) func opAdd(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { @@ -454,7 +457,7 @@ func opBlockhash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ( binary.BigEndian.PutUint64(num64Buf, num64) if interpreter.hasher == nil { - interpreter.hasher = sha3.NewLegacyKeccak256().(keccakState) + interpreter.hasher = sha3.NewLegacyKeccak256().(crypto.KeccakState) } else { interpreter.hasher.Reset() } diff --git a/go.mod b/go.mod index 46878dbde1c7..68cb194c86a2 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,7 @@ require ( github.com/holiman/bloomfilter/v2 v2.0.3 github.com/holiman/uint256 v1.2.3 github.com/huin/goupnp v1.3.0 + github.com/iden3/go-iden3-crypto v0.0.15 github.com/influxdata/influxdb-client-go/v2 v2.4.0 github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c github.com/jackpal/go-nat-pmp v1.0.2 @@ -112,7 +113,6 @@ require ( github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.4 // indirect - github.com/iden3/go-iden3-crypto v0.0.15 // indirect github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/kilic/bls12-381 v0.1.0 // indirect diff --git a/go.sum b/go.sum index fa8d06e274cc..7fc5de3a6a17 100644 --- a/go.sum +++ b/go.sum @@ -561,7 +561,6 @@ github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobt github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=