Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions fvm/evm/emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/onflow/crypto/hash"
gethCommon "github.com/onflow/go-ethereum/common"
gethCore "github.com/onflow/go-ethereum/core"
"github.com/onflow/go-ethereum/core/tracing"
gethTracing "github.com/onflow/go-ethereum/core/tracing"
gethTypes "github.com/onflow/go-ethereum/core/types"
gethVM "github.com/onflow/go-ethereum/core/vm"
Expand Down Expand Up @@ -324,7 +325,7 @@ func (bl *BlockView) newProcedure() (*procedure, error) {
config: cfg,
evm: gethVM.NewEVM(
*cfg.BlockContext,
*cfg.TxContext,
// *cfg.TxContext, TODO(m-Peter): Investigate
execState,
cfg.ChainConfig,
cfg.EVMConfig,
Expand Down Expand Up @@ -514,11 +515,15 @@ func (proc *procedure) deployAt(
proc.state.CreateAccount(callerCommon)
}
// increment the nonce for the caller
proc.state.SetNonce(callerCommon, proc.state.GetNonce(callerCommon)+1)
proc.state.SetNonce(
callerCommon,
proc.state.GetNonce(callerCommon)+1,
tracing.NonceChangeContractCreator,
)

// setup account
proc.state.CreateAccount(addr)
proc.state.SetNonce(addr, 1) // (EIP-158)
proc.state.SetNonce(addr, 1, tracing.NonceChangeNewContract) // (EIP-158)
if call.Value.Sign() > 0 {
proc.evm.Context.Transfer( // transfer value
proc.state,
Expand Down Expand Up @@ -642,11 +647,11 @@ func (proc *procedure) run(
gasPool := (*gethCore.GasPool)(&proc.config.BlockContext.GasLimit)

// transit the state
execResult, err := gethCore.NewStateTransition(
execResult, err := gethCore.ApplyMessage(
proc.evm,
msg,
gasPool,
).TransitionDb()
)
if err != nil {
// if the error is a fatal error or a non-fatal state error or a backend err return it
// this condition should never happen given all StateDB errors are withheld for the commit time.
Expand Down
16 changes: 14 additions & 2 deletions fvm/evm/emulator/state/stateDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
"github.com/onflow/atree"
"github.com/onflow/crypto/hash"
gethCommon "github.com/onflow/go-ethereum/common"
gethState "github.com/onflow/go-ethereum/core/state"
gethStateless "github.com/onflow/go-ethereum/core/stateless"
"github.com/onflow/go-ethereum/core/tracing"
gethTracing "github.com/onflow/go-ethereum/core/tracing"
gethTypes "github.com/onflow/go-ethereum/core/types"
gethParams "github.com/onflow/go-ethereum/params"
Expand Down Expand Up @@ -188,7 +190,11 @@ func (db *StateDB) GetNonce(addr gethCommon.Address) uint64 {
}

// SetNonce sets the nonce value for the given address
func (db *StateDB) SetNonce(addr gethCommon.Address, nonce uint64) {
func (db *StateDB) SetNonce(
addr gethCommon.Address,
nonce uint64,
reason tracing.NonceChangeReason,
) {
err := db.latestView().SetNonce(addr, nonce)
db.handleError(err)
}
Expand All @@ -215,9 +221,11 @@ func (db *StateDB) GetCodeSize(addr gethCommon.Address) int {
}

// SetCode sets the code for the given address
func (db *StateDB) SetCode(addr gethCommon.Address, code []byte) {
func (db *StateDB) SetCode(addr gethCommon.Address, code []byte) (prev []byte) {
err := db.latestView().SetCode(addr, code)
db.handleError(err)

return nil
}

// AddRefund adds the amount to the total (gas) refund
Expand Down Expand Up @@ -571,6 +579,10 @@ func (s *StateDB) Witness() *gethStateless.Witness {
return nil
}

func (s *StateDB) AccessEvents() *gethState.AccessEvents {
return &gethState.AccessEvents{}
}

func (db *StateDB) latestView() *DeltaView {
return db.views[len(db.views)-1]
}
Expand Down
29 changes: 15 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ require (
github.com/schollz/progressbar/v3 v3.13.1
github.com/sethvargo/go-retry v0.2.3
github.com/shirou/gopsutil/v3 v3.22.2
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.10.0
Expand All @@ -77,13 +77,13 @@ require (
go.opentelemetry.io/otel/trace v1.31.0
go.uber.org/atomic v1.11.0
go.uber.org/multierr v1.11.0
golang.org/x/crypto v0.31.0
golang.org/x/crypto v0.32.0
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67
golang.org/x/sync v0.10.0
golang.org/x/sys v0.28.0
golang.org/x/sys v0.29.0
golang.org/x/text v0.21.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.28.0
golang.org/x/tools v0.29.0
google.golang.org/api v0.169.0
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de
google.golang.org/grpc v1.67.1
Expand All @@ -102,13 +102,13 @@ require (
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
github.com/gorilla/websocket v1.5.3
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/holiman/uint256 v1.3.1
github.com/holiman/uint256 v1.3.2
github.com/huandu/go-clone/generic v1.7.2
github.com/ipfs/boxo v0.17.1-0.20240131173518-89bceff34bf1
github.com/libp2p/go-libp2p-routing-helpers v0.7.4
github.com/mitchellh/mapstructure v1.5.0
github.com/onflow/bridged-usdc/lib/go/contracts v1.0.0
github.com/onflow/go-ethereum v1.14.8-0.20250321083631-c17e334a7940
github.com/onflow/go-ethereum v1.14.8-0.20250327092350-88fbc940c1b0
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0
github.com/onflow/wal v1.0.2
github.com/slok/go-http-metrics v0.12.0
Expand Down Expand Up @@ -144,7 +144,7 @@ require (
github.com/aws/smithy-go v1.20.2 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/bits-and-blooms/bitset v1.17.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand All @@ -153,12 +153,12 @@ require (
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/consensys/bavard v0.1.22 // indirect
github.com/consensys/gnark-crypto v0.14.0 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/cskr/pubsub v1.0.2 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
Expand All @@ -168,7 +168,7 @@ require (
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect
github.com/elastic/gosigar v0.14.3 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/filecoin-project/go-clock v0.1.0 // indirect
Expand Down Expand Up @@ -277,6 +277,7 @@ require (
github.com/pion/sdp/v3 v3.0.9 // indirect
github.com/pion/srtp/v2 v2.0.20 // indirect
github.com/pion/stun v0.6.1 // indirect
github.com/pion/stun/v2 v2.0.0 // indirect
github.com/pion/transport/v2 v2.2.10 // indirect
github.com/pion/transport/v3 v3.0.7 // indirect
github.com/pion/turn/v2 v2.1.6 // indirect
Expand Down Expand Up @@ -324,9 +325,9 @@ require (
go.uber.org/mock v0.5.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/term v0.28.0 // indirect
gonum.org/v1/gonum v0.15.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
Expand Down
Loading
Loading