From 2e468279837326ed882c9a2ea11ccebf1a17b60d Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 17 Mar 2021 08:59:43 -0700 Subject: [PATCH] blocknumber: fix (#280) --- core/state_processor.go | 3 +++ core/state_transition_ovm.go | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index da5c50d40..7d349f83a 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -97,6 +97,9 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo } // Create a new context to be used in the EVM environment context := NewEVMContext(msg, header, bc, author) + if vm.UsingOVM { + context.BlockNumber = msg.L1BlockNumber() + } // Create a new environment which holds all relevant information // about the transaction and calling mechanisms. vmenv := vm.NewEVM(context, statedb, config, cfg) diff --git a/core/state_transition_ovm.go b/core/state_transition_ovm.go index 9b504a620..ee4882c88 100644 --- a/core/state_transition_ovm.go +++ b/core/state_transition_ovm.go @@ -13,19 +13,19 @@ import ( var ZeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") type ovmTransaction struct { - Timestamp *big.Int "json:\"timestamp\"" - BlockNumber *big.Int "json:\"blockNumber\"" - L1QueueOrigin uint8 "json:\"l1QueueOrigin\"" - L1TxOrigin common.Address "json:\"l1TxOrigin\"" - Entrypoint common.Address "json:\"entrypoint\"" - GasLimit *big.Int "json:\"gasLimit\"" - Data []uint8 "json:\"data\"" + Timestamp *big.Int `json:"timestamp"` + BlockNumber *big.Int `json:"blockNumber"` + L1QueueOrigin uint8 `json:"l1QueueOrigin"` + L1TxOrigin common.Address `json:"l1TxOrigin"` + Entrypoint common.Address `json:"entrypoint"` + GasLimit *big.Int `json:"gasLimit"` + Data []uint8 `json:"data"` } func toExecutionManagerRun(evm *vm.EVM, msg Message) (Message, error) { tx := ovmTransaction{ evm.Context.Time, - evm.Context.BlockNumber, // TODO (what's the correct block number?) + msg.L1BlockNumber(), uint8(msg.QueueOrigin().Uint64()), *msg.L1MessageSender(), *msg.To(),