Skip to content
Merged
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
2 changes: 1 addition & 1 deletion fvm/evm/emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func newConfig(ctx types.BlockContext) *Config {
}

// NewReadOnlyBlockView constructs a new read-only block view
func (em *Emulator) NewReadOnlyBlockView(ctx types.BlockContext) (types.ReadOnlyBlockView, error) {
func (em *Emulator) NewReadOnlyBlockView() (types.ReadOnlyBlockView, error) {
execState, err := state.NewStateDB(em.ledger, em.rootAddr)
return &ReadOnlyBlockView{
state: execState,
Expand Down
2 changes: 1 addition & 1 deletion fvm/evm/emulator/emulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func RunWithNewBlockView(t testing.TB, em *emulator.Emulator, f func(blk types.B
}

func RunWithNewReadOnlyBlockView(t testing.TB, em *emulator.Emulator, f func(blk types.ReadOnlyBlockView)) {
blk, err := em.NewReadOnlyBlockView(defaultCtx)
blk, err := em.NewReadOnlyBlockView()
require.NoError(t, err)
f(blk)
}
Expand Down
47 changes: 4 additions & 43 deletions fvm/evm/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,16 +737,7 @@ func (a *Account) Nonce() uint64 {
}

func (a *Account) nonce() (uint64, error) {
bp, err := a.fch.getBlockProposal()
if err != nil {
return 0, err
}
ctx, err := a.fch.getBlockContext(bp)
if err != nil {
return 0, err
}

blk, err := a.fch.emulator.NewReadOnlyBlockView(ctx)
blk, err := a.fch.emulator.NewReadOnlyBlockView()
if err != nil {
return 0, err
}
Expand All @@ -765,17 +756,7 @@ func (a *Account) Balance() types.Balance {
}

func (a *Account) balance() (types.Balance, error) {
bp, err := a.fch.getBlockProposal()
if err != nil {
return nil, err
}

ctx, err := a.fch.getBlockContext(bp)
if err != nil {
return nil, err
}

blk, err := a.fch.emulator.NewReadOnlyBlockView(ctx)
blk, err := a.fch.emulator.NewReadOnlyBlockView()
if err != nil {
return nil, err
}
Expand All @@ -795,17 +776,7 @@ func (a *Account) Code() types.Code {
}

func (a *Account) code() (types.Code, error) {
bp, err := a.fch.getBlockProposal()
if err != nil {
return nil, err
}

ctx, err := a.fch.getBlockContext(bp)
if err != nil {
return nil, err
}

blk, err := a.fch.emulator.NewReadOnlyBlockView(ctx)
blk, err := a.fch.emulator.NewReadOnlyBlockView()
if err != nil {
return nil, err
}
Expand All @@ -823,17 +794,7 @@ func (a *Account) CodeHash() []byte {
}

func (a *Account) codeHash() ([]byte, error) {
bp, err := a.fch.getBlockProposal()
if err != nil {
return nil, err
}

ctx, err := a.fch.getBlockContext(bp)
if err != nil {
return nil, err
}

blk, err := a.fch.emulator.NewReadOnlyBlockView(ctx)
blk, err := a.fch.emulator.NewReadOnlyBlockView()
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion fvm/evm/testutils/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func FundAndGetEOATestAccount(t testing.TB, led atree.Ledger, flowEVMRootAddress
)
require.NoError(t, err)

blk2, err := e.NewReadOnlyBlockView(types.NewDefaultBlockContext(2))
blk2, err := e.NewReadOnlyBlockView()
require.NoError(t, err)

bal, err := blk2.BalanceOf(account.Address())
Expand Down
2 changes: 1 addition & 1 deletion fvm/evm/testutils/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func DeployContract(t testing.TB, caller types.Address, tc *TestContract, led at

ctx := types.NewDefaultBlockContext(2)

bl, err := e.NewReadOnlyBlockView(ctx)
bl, err := e.NewReadOnlyBlockView()
require.NoError(t, err)

nonce, err := bl.NonceOf(caller)
Expand Down
2 changes: 1 addition & 1 deletion fvm/evm/testutils/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (em *TestEmulator) NewBlockView(_ types.BlockContext) (types.BlockView, err
}

// NewBlock returns a new block view
func (em *TestEmulator) NewReadOnlyBlockView(_ types.BlockContext) (types.ReadOnlyBlockView, error) {
func (em *TestEmulator) NewReadOnlyBlockView() (types.ReadOnlyBlockView, error) {
return em, nil
}

Expand Down
2 changes: 1 addition & 1 deletion fvm/evm/types/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type BlockView interface {
// Emulator emulates an evm-compatible chain
type Emulator interface {
// constructs a new block view
NewReadOnlyBlockView(ctx BlockContext) (ReadOnlyBlockView, error)
NewReadOnlyBlockView() (ReadOnlyBlockView, error)

// constructs a new block
NewBlockView(ctx BlockContext) (BlockView, error)
Expand Down
Loading