diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index a8b30de307..b182a30eca 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -115,7 +115,7 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis Alloc: alloc, } cacheConfig := &core.CacheConfig{} - blockchain, _ := core.NewBlockChain(database, cacheConfig, &genesis, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + blockchain, _ := core.NewBlockChain(database, cacheConfig, &genesis, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) backend := &SimulatedBackend{ database: database, diff --git a/consensus/dummy/consensus.go b/consensus/dummy/consensus.go index 36753547de..95a992b91a 100644 --- a/consensus/dummy/consensus.go +++ b/consensus/dummy/consensus.go @@ -10,11 +10,11 @@ import ( "math/big" "time" + "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/coreth/consensus" "github.com/ava-labs/coreth/core/state" "github.com/ava-labs/coreth/core/types" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/coreth/trie" "github.com/ethereum/go-ethereum/common" ) @@ -31,16 +31,14 @@ var ( errExtDataGasUsedTooLarge = errors.New("extDataGasUsed is not uint64") ) -type Mode uint - -const ( - ModeSkipHeader Mode = 1 // Skip over header verification - ModeSkipBlockFee Mode = 2 // Skip block fee verification -) +type Mode struct { + ModeSkipHeader bool + ModeSkipBlockFee bool + ModeSkipCoinbase bool +} type ( OnFinalizeAndAssembleCallbackType = func(header *types.Header, state *state.StateDB, txs []*types.Transaction) (extraData []byte, blockFeeContribution *big.Int, extDataGasUsed *big.Int, err error) - OnAPIsCallbackType = func(consensus.ChainHeaderReader) []rpc.API OnExtraStateChangeType = func(block *types.Block, statedb *state.StateDB) (blockFeeContribution *big.Int, extDataGasUsed *big.Int, err error) ConsensusCallbacks struct { @@ -49,39 +47,58 @@ type ( } DummyEngine struct { - cb *ConsensusCallbacks + cb ConsensusCallbacks + clock *mockable.Clock consensusMode Mode } ) -func NewDummyEngine(cb *ConsensusCallbacks) *DummyEngine { +func NewETHFaker() *DummyEngine { return &DummyEngine{ - cb: cb, + clock: &mockable.Clock{}, + consensusMode: Mode{ModeSkipBlockFee: true}, } } -func NewETHFaker() *DummyEngine { +func NewFaker() *DummyEngine { return &DummyEngine{ - cb: new(ConsensusCallbacks), - consensusMode: ModeSkipBlockFee, + clock: &mockable.Clock{}, } } -func NewComplexETHFaker(cb *ConsensusCallbacks) *DummyEngine { +func NewFakerWithClock(cb ConsensusCallbacks, clock *mockable.Clock) *DummyEngine { + return &DummyEngine{ + cb: cb, + clock: clock, + } +} + +func NewFakerWithCallbacks(cb ConsensusCallbacks) *DummyEngine { + return &DummyEngine{ + cb: cb, + clock: &mockable.Clock{}, + } +} + +func NewFakerWithMode(cb ConsensusCallbacks, mode Mode) *DummyEngine { return &DummyEngine{ cb: cb, - consensusMode: ModeSkipBlockFee, + clock: &mockable.Clock{}, + consensusMode: mode, } } -func NewFaker() *DummyEngine { - return NewDummyEngine(new(ConsensusCallbacks)) +func NewCoinbaseFaker() *DummyEngine { + return &DummyEngine{ + clock: &mockable.Clock{}, + consensusMode: Mode{ModeSkipCoinbase: true}, + } } func NewFullFaker() *DummyEngine { return &DummyEngine{ - cb: new(ConsensusCallbacks), - consensusMode: ModeSkipHeader, + clock: &mockable.Clock{}, + consensusMode: Mode{ModeSkipHeader: true}, } } @@ -212,7 +229,7 @@ func (self *DummyEngine) verifyHeader(chain consensus.ChainHeaderReader, header } // Verify the header's timestamp - if header.Time > uint64(time.Now().Add(allowedFutureBlockTime).Unix()) { + if header.Time > uint64(self.clock.Time().Add(allowedFutureBlockTime).Unix()) { return consensus.ErrFutureBlock } // Verify the header's timestamp is not earlier than parent's @@ -241,7 +258,7 @@ func (self *DummyEngine) Author(header *types.Header) (common.Address, error) { func (self *DummyEngine) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error { // If we're running a full engine faking, accept any input as valid - if self.consensusMode == ModeSkipHeader { + if self.consensusMode.ModeSkipHeader { return nil } // Short circuit if the header is known, or it's parent not @@ -276,7 +293,7 @@ func (self *DummyEngine) verifyBlockFee( receipts []*types.Receipt, extraStateChangeContribution *big.Int, ) error { - if self.consensusMode == ModeSkipBlockFee { + if self.consensusMode.ModeSkipBlockFee { return nil } if baseFee == nil || baseFee.Sign() <= 0 { @@ -442,8 +459,8 @@ func (self *DummyEngine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, // Header seems complete, assemble into a block and return return types.NewBlockWithExtData( - header, txs, uncles, receipts, trie.NewStackTrie(nil), extraData, - chain.Config().IsApricotPhase1(header.Time), + header, txs, uncles, receipts, trie.NewStackTrie(nil), + extraData, chain.Config().IsApricotPhase1(header.Time), ), nil } diff --git a/core/bench_test.go b/core/bench_test.go index 0fbbc28a87..649e98f84d 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -162,11 +162,11 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) { Config: params.TestChainConfig, Alloc: GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}}, } - _, chain, _, _ := GenerateChainWithGenesis(gspec, dummy.NewFaker(), b.N, 10, gen) + _, chain, _, _ := GenerateChainWithGenesis(gspec, dummy.NewCoinbaseFaker(), b.N, 10, gen) // Time the insertion of the new chain. // State and blocks are stored in the same DB. - chainman, _ := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + chainman, _ := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) defer chainman.Stop() b.ReportAllocs() b.ResetTimer() diff --git a/core/blockchain_log_test.go b/core/blockchain_log_test.go index 40cb8515d8..5c7df458d3 100644 --- a/core/blockchain_log_test.go +++ b/core/blockchain_log_test.go @@ -36,7 +36,7 @@ func TestAcceptedLogsSubscription(t *testing.T) { ) var ( require = require.New(t) - engine = dummy.NewFaker() + engine = dummy.NewCoinbaseFaker() key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") addr1 = crypto.PubkeyToAddress(key1.PublicKey) funds = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether)) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 6ac2d2655f..cb8befcdd6 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -64,7 +64,7 @@ func createBlockChain( db, cacheConfig, gspec, - dummy.NewDummyEngine(&TestCallbacks), + dummy.NewFakerWithCallbacks(TestCallbacks), vm.Config{}, lastAcceptedHash, false, @@ -648,14 +648,14 @@ func TestTransactionIndices(t *testing.T) { } signer = types.LatestSigner(gspec.Config) ) - genDb, blocks, _, err := GenerateChainWithGenesis(gspec, dummy.NewDummyEngine(&TestCallbacks), 128, 10, func(i int, block *BlockGen) { + genDb, blocks, _, err := GenerateChainWithGenesis(gspec, dummy.NewFakerWithCallbacks(TestCallbacks), 128, 10, func(i int, block *BlockGen) { tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), params.TxGas, nil, nil), signer, key1) require.NoError(err) block.AddTx(tx) }) require.NoError(err) - blocks2, _, err := GenerateChain(gspec.Config, blocks[len(blocks)-1], dummy.NewDummyEngine(&TestCallbacks), genDb, 10, 10, func(i int, block *BlockGen) { + blocks2, _, err := GenerateChain(gspec.Config, blocks[len(blocks)-1], dummy.NewFakerWithCallbacks(TestCallbacks), genDb, 10, 10, func(i int, block *BlockGen) { tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), params.TxGas, nil, nil), signer, key1) require.NoError(err) block.AddTx(tx) @@ -789,14 +789,14 @@ func TestTransactionSkipIndexing(t *testing.T) { } signer = types.LatestSigner(gspec.Config) ) - genDb, blocks, _, err := GenerateChainWithGenesis(gspec, dummy.NewDummyEngine(&TestCallbacks), 5, 10, func(i int, block *BlockGen) { + genDb, blocks, _, err := GenerateChainWithGenesis(gspec, dummy.NewFakerWithCallbacks(TestCallbacks), 5, 10, func(i int, block *BlockGen) { tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), params.TxGas, nil, nil), signer, key1) require.NoError(err) block.AddTx(tx) }) require.NoError(err) - blocks2, _, err := GenerateChain(gspec.Config, blocks[len(blocks)-1], dummy.NewDummyEngine(&TestCallbacks), genDb, 5, 10, func(i int, block *BlockGen) { + blocks2, _, err := GenerateChain(gspec.Config, blocks[len(blocks)-1], dummy.NewFakerWithCallbacks(TestCallbacks), genDb, 5, 10, func(i int, block *BlockGen) { tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr1), addr2, big.NewInt(10000), params.TxGas, nil, nil), signer, key1) require.NoError(err) block.AddTx(tx) @@ -936,7 +936,7 @@ func TestCanonicalHashMarker(t *testing.T) { Alloc: GenesisAlloc{}, BaseFee: big.NewInt(params.ApricotPhase3InitialBaseFee), } - engine = dummy.NewFaker() + engine = dummy.NewCoinbaseFaker() ) _, forkA, _, err := GenerateChainWithGenesis(gspec, engine, c.forkA, 10, func(i int, gen *BlockGen) {}) if err != nil { @@ -1242,7 +1242,7 @@ func TestEIP3651(t *testing.T) { var ( aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") bb = common.HexToAddress("0x000000000000000000000000000000000000bbbb") - engine = dummy.NewFaker() + engine = dummy.NewCoinbaseFaker() // A sender who makes transactions, has some funds key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index 88f0f9ec93..cdc2752758 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -60,7 +60,7 @@ func ExampleGenerateChain() { // each block and adds different features to gen based on the // block index. signer := types.HomesteadSigner{} - _, chain, _, err := GenerateChainWithGenesis(gspec, dummy.NewFaker(), 3, 10, func(i int, gen *BlockGen) { + _, chain, _, err := GenerateChainWithGenesis(gspec, dummy.NewCoinbaseFaker(), 3, 10, func(i int, gen *BlockGen) { switch i { case 0: // In block 1, addr1 sends addr2 some ether. @@ -81,7 +81,7 @@ func ExampleGenerateChain() { } // Import the chain. This runs all block validation rules. - blockchain, _ := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + blockchain, _ := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) defer blockchain.Stop() if i, err := blockchain.InsertChain(chain); err != nil { diff --git a/core/headerchain_test.go b/core/headerchain_test.go index 3b349be043..b70a9802f0 100644 --- a/core/headerchain_test.go +++ b/core/headerchain_test.go @@ -80,18 +80,18 @@ func TestHeaderInsertion(t *testing.T) { } ) genesis := gspec.ToBlock() - chain, err := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + chain, err := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) if err != nil { t.Fatal(err) } defer chain.Stop() // chain A: G->A1->A2...A128 - chainA, _, _ := GenerateChain(params.TestChainConfig, types.NewBlockWithHeader(genesis.Header()), dummy.NewFaker(), db, 128, 10, func(i int, b *BlockGen) { + chainA, _, _ := GenerateChain(params.TestChainConfig, types.NewBlockWithHeader(genesis.Header()), dummy.NewCoinbaseFaker(), db, 128, 10, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{0: byte(10), 19: byte(i)}) }) // chain B: G->A1->B2...B128 - chainB, _, _ := GenerateChain(params.TestChainConfig, types.NewBlockWithHeader(chainA[0].Header()), dummy.NewFaker(), db, 128, 10, func(i int, b *BlockGen) { + chainB, _, _ := GenerateChain(params.TestChainConfig, types.NewBlockWithHeader(chainA[0].Header()), dummy.NewCoinbaseFaker(), db, 128, 10, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{0: byte(10), 19: byte(i)}) }) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 18820e7d7b..db400702cf 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -104,7 +104,7 @@ func TestStateProcessorErrors(t *testing.T) { }, GasLimit: params.CortinaGasLimit, } - blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) ) defer blockchain.Stop() bigNumber := new(big.Int).SetBytes(common.FromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) @@ -203,7 +203,7 @@ func TestStateProcessorErrors(t *testing.T) { want: "could not apply tx 0 [0xd82a0c2519acfeac9a948258c47e784acd20651d9d80f9a1c67b4137651c3a24]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 4000000000000000000 want 2431633873983640103894990685182446064918669677978451844828609264166175722438635000", }, } { - block := GenerateBadBlock(gspec.ToBlock(), dummy.NewFaker(), tt.txs, gspec.Config) + block := GenerateBadBlock(gspec.ToBlock(), dummy.NewCoinbaseFaker(), tt.txs, gspec.Config) _, err := blockchain.InsertChain(types.Blocks{block}) if err == nil { t.Fatal("block imported without errors") @@ -241,7 +241,7 @@ func TestStateProcessorErrors(t *testing.T) { }, GasLimit: params.ApricotPhase1GasLimit, } - blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) ) defer blockchain.Stop() for i, tt := range []struct { @@ -255,7 +255,7 @@ func TestStateProcessorErrors(t *testing.T) { want: "could not apply tx 0 [0x88626ac0d53cb65308f2416103c62bb1f18b805573d4f96a3640bbbfff13c14f]: transaction type not supported", }, } { - block := GenerateBadBlock(gspec.ToBlock(), dummy.NewFaker(), tt.txs, gspec.Config) + block := GenerateBadBlock(gspec.ToBlock(), dummy.NewCoinbaseFaker(), tt.txs, gspec.Config) _, err := blockchain.InsertChain(types.Blocks{block}) if err == nil { t.Fatal("block imported without errors") @@ -281,7 +281,7 @@ func TestStateProcessorErrors(t *testing.T) { }, GasLimit: params.CortinaGasLimit, } - blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) ) defer blockchain.Stop() for i, tt := range []struct { @@ -295,7 +295,7 @@ func TestStateProcessorErrors(t *testing.T) { want: "could not apply tx 0 [0x88626ac0d53cb65308f2416103c62bb1f18b805573d4f96a3640bbbfff13c14f]: sender not an eoa: address 0x71562b71999873DB5b286dF957af199Ec94617F7, codehash: 0x9280914443471259d4570a8661015ae4a5b80186dbc619658fb494bebc3da3d1", }, } { - block := GenerateBadBlock(gspec.ToBlock(), dummy.NewFaker(), tt.txs, gspec.Config) + block := GenerateBadBlock(gspec.ToBlock(), dummy.NewCoinbaseFaker(), tt.txs, gspec.Config) _, err := blockchain.InsertChain(types.Blocks{block}) if err == nil { t.Fatal("block imported without errors") @@ -344,7 +344,7 @@ func TestStateProcessorErrors(t *testing.T) { }, GasLimit: params.CortinaGasLimit, } - blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewFaker(), vm.Config{}, common.Hash{}, false) + blockchain, _ = NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false) tooBigInitCode = [params.MaxInitCodeSize + 1]byte{} smallInitCode = [320]byte{} ) @@ -366,7 +366,7 @@ func TestStateProcessorErrors(t *testing.T) { want: "could not apply tx 0 [0x849278f616d51ab56bba399551317213ce7a10e4d9cbc3d14bb663e50cb7ab99]: intrinsic gas too low: have 54299, want 54300", }, } { - block := GenerateBadBlock(gspec.ToBlock(), dummy.NewFaker(), tt.txs, gspec.Config) + block := GenerateBadBlock(gspec.ToBlock(), dummy.NewCoinbaseFaker(), tt.txs, gspec.Config) _, err := blockchain.InsertChain(types.Blocks{block}) if err == nil { t.Fatal("block imported without errors") diff --git a/core/test_blockchain.go b/core/test_blockchain.go index 9453c128fc..eab50a4f48 100644 --- a/core/test_blockchain.go +++ b/core/test_blockchain.go @@ -1341,7 +1341,7 @@ func TestInsertChainInvalidBlockFee(t *testing.T, create func(db ethdb.Database, // This call generates a chain of 3 blocks. signer := types.LatestSigner(params.TestChainConfig) - eng := dummy.NewComplexETHFaker(&TestCallbacks) + eng := dummy.NewFakerWithMode(TestCallbacks, dummy.Mode{ModeSkipBlockFee: true, ModeSkipCoinbase: true}) _, chain, _, err := GenerateChainWithGenesis(gspec, eng, 3, 0, func(i int, gen *BlockGen) { tx := types.NewTx(&types.DynamicFeeTx{ ChainID: params.TestChainConfig.ChainID, diff --git a/eth/backend.go b/eth/backend.go index 3497bf0adc..55d674d9d6 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -117,7 +117,7 @@ func roundUpCacheSize(input int, allocSize int) int { func New( stack *node.Node, config *Config, - cb *dummy.ConsensusCallbacks, + cb dummy.ConsensusCallbacks, chainDb ethdb.Database, settings Settings, lastAcceptedHash common.Hash, @@ -154,7 +154,7 @@ func New( chainDb: chainDb, eventMux: new(event.TypeMux), accountManager: stack.AccountManager(), - engine: dummy.NewDummyEngine(cb), + engine: dummy.NewFakerWithClock(cb, clock), closeBloomHandler: make(chan struct{}), networkID: config.NetworkId, etherbase: config.Miner.Etherbase, diff --git a/eth/gasprice/gasprice_test.go b/eth/gasprice/gasprice_test.go index b968cb081d..82941c015e 100644 --- a/eth/gasprice/gasprice_test.go +++ b/eth/gasprice/gasprice_test.go @@ -125,7 +125,7 @@ func newTestBackend(t *testing.T, config *params.ChainConfig, numBlocks int, ext Alloc: core.GenesisAlloc{addr: core.GenesisAccount{Balance: bal}}, } - engine := dummy.NewDummyEngine(&dummy.ConsensusCallbacks{ + engine := dummy.NewFakerWithCallbacks(dummy.ConsensusCallbacks{ OnFinalizeAndAssemble: func(header *types.Header, state *state.StateDB, txs []*types.Transaction) ([]byte, *big.Int, *big.Int, error) { return nil, common.Big0, extDataGasUsage, nil }, diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 6fca3858fb..19237e5b61 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -200,7 +200,7 @@ type testBackend struct { func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i int, b *core.BlockGen)) *testBackend { var ( - engine = dummy.NewETHFaker() + engine = dummy.NewCoinbaseFaker() backend = &testBackend{ db: rawdb.NewMemoryDatabase(), } diff --git a/plugin/evm/syncervm_test.go b/plugin/evm/syncervm_test.go index fec9150cfb..251107fd30 100644 --- a/plugin/evm/syncervm_test.go +++ b/plugin/evm/syncervm_test.go @@ -590,7 +590,7 @@ func generateAndAcceptBlocks(t *testing.T, vm *VM, numBlocks int, gen func(int, _, _, err := core.GenerateChain( vm.chainConfig, vm.blockChain.LastAcceptedBlock(), - dummy.NewDummyEngine(vm.createConsensusCallbacks()), + dummy.NewFakerWithCallbacks(vm.createConsensusCallbacks()), vm.chaindb, numBlocks, 10, diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index a393cd901e..401fca1823 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -97,13 +97,16 @@ import ( avalancheJSON "github.com/ava-labs/avalanchego/utils/json" ) +var ( + _ block.ChainVM = &VM{} + _ block.BuildBlockWithContextChainVM = &VM{} + _ block.StateSyncableVM = &VM{} + _ statesyncclient.EthBlockParser = &VM{} +) + const ( x2cRateInt64 int64 = 1_000_000_000 x2cRateMinus1Int64 int64 = x2cRateInt64 - 1 - - // Prefixes for metrics gatherers - ethMetricsPrefix = "eth" - chainStateMetricsPrefix = "chain_state" ) var ( @@ -113,10 +116,6 @@ var ( // places on the X and P chains, but is 18 decimal places within the EVM. x2cRate = big.NewInt(x2cRateInt64) x2cRateMinus1 = big.NewInt(x2cRateMinus1Int64) - - _ block.ChainVM = &VM{} - _ block.StateSyncableVM = &VM{} - _ statesyncclient.EthBlockParser = &VM{} ) const ( @@ -134,6 +133,10 @@ const ( bytesToIDCacheSize = 5 * units.MiB warpSignatureCacheSize = 500 + // Prefixes for metrics gatherers + ethMetricsPrefix = "eth" + chainStateMetricsPrefix = "chain_state" + targetAtomicTxsSize = 40 * units.KiB // p2p app protocols @@ -819,8 +822,8 @@ func (vm *VM) initChainState(lastAcceptedBlock *types.Block) error { return vm.multiGatherer.Register(chainStateMetricsPrefix, chainStateRegisterer) } -func (vm *VM) createConsensusCallbacks() *dummy.ConsensusCallbacks { - return &dummy.ConsensusCallbacks{ +func (vm *VM) createConsensusCallbacks() dummy.ConsensusCallbacks { + return dummy.ConsensusCallbacks{ OnFinalizeAndAssemble: vm.onFinalizeAndAssemble, OnExtraStateChange: vm.onExtraStateChange, }