From 5e1a0e2dcbab7f9aaf4c45518bddedf93b669e28 Mon Sep 17 00:00:00 2001 From: Sunny Date: Mon, 12 Jun 2023 22:26:04 +0800 Subject: [PATCH 1/2] eip2718test: add eip 2718 parlia test --- core/eip3529tests/eip3529_ethash_test.go | 140 -------- core/eip3529tests/eip3529_parlia_test.go | 140 -------- core/parlia_tests/eip2718_parlia_test.go | 54 +++ core/parlia_tests/eip3529_ethash_test.go | 309 +++++++++++++++++ core/parlia_tests/eip3529_parlia_test.go | 311 ++++++++++++++++++ .../parlia_test_util.go} | 45 +-- 6 files changed, 690 insertions(+), 309 deletions(-) delete mode 100644 core/eip3529tests/eip3529_ethash_test.go delete mode 100644 core/eip3529tests/eip3529_parlia_test.go create mode 100644 core/parlia_tests/eip2718_parlia_test.go create mode 100644 core/parlia_tests/eip3529_ethash_test.go create mode 100644 core/parlia_tests/eip3529_parlia_test.go rename core/{eip3529tests/eip3529_test_util.go => parlia_tests/parlia_test_util.go} (63%) diff --git a/core/eip3529tests/eip3529_ethash_test.go b/core/eip3529tests/eip3529_ethash_test.go deleted file mode 100644 index f58afad1f4..0000000000 --- a/core/eip3529tests/eip3529_ethash_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package eip3529tests - -import ( - "math/big" - "testing" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/consensus/ethash" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/params" -) - -func postLondonConfig() *params.ChainConfig { - config := *params.TestChainConfig - config.LondonBlock = big.NewInt(0) - return &config -} - -func preLondonConfig() *params.ChainConfig { - config := *params.TestChainConfig - config.LondonBlock = nil - return &config -} - -func TestSelfDestructGasPreLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PC), - byte(vm.SELFDESTRUCT), - } - - // Expected gas is (intrinsic + pc + cold load (due to legacy tx) + selfdestruct cost ) / 2 - // The refund of 24000 gas (i.e. params.SelfdestructRefundGas) is not applied since refunds pre-EIP3529 are - // capped to half of the transaction's gas. - expectedGasUsed := (params.TxGas + vm.GasQuickStep + params.ColdAccountAccessCostEIP2929 + params.SelfdestructGasEIP150) / 2 - TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSstoreModifyGasPreLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 3 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) - // i.e. no refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929) - TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsed) -} - -func TestSstoreClearGasPreLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x0, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 0 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - - // Expected gas is (intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) ) / 2 - // The refund of params.SstoreClearsScheduleRefundEIP2200 is not applied because of the refund cap to half the gas cost. - expectedGasUsage := (params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929)) / 2 - TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsage) -} - -func TestSstoreGasPreLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x3, // location - byte(vm.SSTORE), // Set slot[3] = 3 - } - // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreGas - // i.e. No refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + params.SstoreSetGasEIP2200 - TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSelfDestructGasPostLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PC), - byte(vm.SELFDESTRUCT), - } - // Expected gas is intrinsic + pc + cold load (due to legacy tx) + SelfDestructGas - // i.e. No refund - expectedGasUsed := params.TxGas + vm.GasQuickStep + params.ColdAccountAccessCostEIP2929 + params.SelfdestructGasEIP150 - TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSstoreGasPostLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x3, // location - byte(vm.SSTORE), // Set slot[3] = 3 - } - // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreGas - // i.e. No refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + params.SstoreSetGasEIP2200 - TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSstoreModifyGasPostLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 3 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) - // i.e. No refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929) - TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsed) -} - -func TestSstoreClearGasPostLondon(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x0, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 0 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - - // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) - sstoreClearGasRefund - expectedGasUsage := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929) - params.SstoreClearsScheduleRefundEIP3529 - TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsage) -} diff --git a/core/eip3529tests/eip3529_parlia_test.go b/core/eip3529tests/eip3529_parlia_test.go deleted file mode 100644 index f759a8f880..0000000000 --- a/core/eip3529tests/eip3529_parlia_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package eip3529tests - -import ( - "testing" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/consensus/ethash" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/params" -) - -func postHertzConfig() *params.ChainConfig { - config := *params.ParliaTestChainConfig - return &config -} - -func preHertzConfig() *params.ChainConfig { - config := *params.ParliaTestChainConfig - config.LondonBlock = nil - config.BerlinBlock = nil - config.HertzBlock = nil - return &config -} - -func TestSelfDestructGasPreHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PC), - byte(vm.SELFDESTRUCT), - } - - // Expected gas is (intrinsic + selfdestruct cost ) / 2 - // The refund of 24000 gas (i.e. params.SelfdestructRefundGas) is not applied since refunds pre-EIP3529 are - // capped to half of the transaction's gas. - expectedGasUsed := (params.TxGas + vm.GasQuickStep + params.SelfdestructGasEIP150) / 2 - TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSstoreClearGasPreHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x0, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 0 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - - // Expected gas is (intrinsic + 2*pushGas + SstoreReset (a->b such that a!=0) ) / 2 - // The refund of params.SstoreClearsScheduleRefundEIP2200 is not applied because of the refund cap to half the gas cost. - expectedGasUsage := (params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200) / 2 - TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsage) -} - -func TestSstoreModifyGasPreHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 3 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - // Expected gas is intrinsic + 2*pushGas + SstoreReset (a->b such that a!=0) - // i.e. no refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200 - TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsed) -} - -func TestSstoreGasPreHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x3, // location - byte(vm.SSTORE), // Set slot[3] = 3 - } - // Expected gas is intrinsic + 2*pushGas + SstoreGas - // i.e. No refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.SstoreSetGasEIP2200 - TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSelfDestructGasPostHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PC), - byte(vm.SELFDESTRUCT), - } - // Expected gas is intrinsic + pc + cold load (due to legacy tx) + SelfDestructGas - // i.e. No refund - expectedGasUsed := params.TxGas + vm.GasQuickStep + params.ColdAccountAccessCostEIP2929 + params.SelfdestructGasEIP150 - TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSstoreGasPostHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x3, // location - byte(vm.SSTORE), // Set slot[3] = 3 - } - // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreGas - // i.e. No refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + params.SstoreSetGasEIP2200 - TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), bytecode, nil, 60_000, expectedGasUsed) -} - -func TestSstoreModifyGasPostHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x3, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 3 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) - // i.e. No refund - expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200 - TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsed) -} - -func TestSstoreClearGasPostHertz(t *testing.T) { - bytecode := []byte{ - byte(vm.PUSH1), 0x0, // value - byte(vm.PUSH1), 0x1, // location - byte(vm.SSTORE), // Set slot[1] = 0 - } - // initialize contract storage - initialStorage := make(map[common.Hash]common.Hash) - // Populate two slots - initialStorage[common.HexToHash("01")] = common.HexToHash("01") - initialStorage[common.HexToHash("02")] = common.HexToHash("02") - - // Expected gas is intrinsic + 2*pushGas + SstoreReset (a->b such that a!=0) - sstoreClearGasRefund - expectedGasUsage := params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200 - params.SstoreClearsScheduleRefundEIP3529 - TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), bytecode, initialStorage, 60_000, expectedGasUsage) -} diff --git a/core/parlia_tests/eip2718_parlia_test.go b/core/parlia_tests/eip2718_parlia_test.go new file mode 100644 index 0000000000..a69cb095cd --- /dev/null +++ b/core/parlia_tests/eip2718_parlia_test.go @@ -0,0 +1,54 @@ +package parlia_tests + +import ( + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "math/big" + "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" +) + +func TestEIP2718PostHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PC), + byte(vm.PC), + byte(vm.SLOAD), + byte(vm.SLOAD), + } + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.AccessListTx{ + ChainID: postHertzConfig().ChainID, + Nonce: 0, + To: &aa, + Gas: 30000, + AccessList: types.AccessList{{ + Address: aa, + StorageKeys: []common.Hash{{0}}, + }}, + } + + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + + // Expected gas is intrinsic + 2 * pc + hot load + cold load, since only one load is in the access list + expectedGasUsage := params.TxGas + params.TxAccessListAddressGas + params.TxAccessListStorageKeyGas + + vm.GasQuickStep*2 + params.WarmStorageReadCostEIP2929 + params.ColdSloadCostEIP2929 + + TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsage) +} diff --git a/core/parlia_tests/eip3529_ethash_test.go b/core/parlia_tests/eip3529_ethash_test.go new file mode 100644 index 0000000000..28068d34b0 --- /dev/null +++ b/core/parlia_tests/eip3529_ethash_test.go @@ -0,0 +1,309 @@ +package parlia_tests + +import ( + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "math/big" + "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" +) + +func postLondonConfig() *params.ChainConfig { + config := *params.TestChainConfig + config.LondonBlock = big.NewInt(0) + return &config +} + +func preLondonConfig() *params.ChainConfig { + config := *params.TestChainConfig + config.LondonBlock = nil + return &config +} + +func TestSelfDestructGasPreLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PC), + byte(vm.SELFDESTRUCT), + } + + // Expected gas is (intrinsic + pc + cold load (due to legacy tx) + selfdestruct cost ) / 2 + // The refund of 24000 gas (i.e. params.SelfdestructRefundGas) is not applied since refunds pre-EIP3529 are + // capped to half of the transaction's gas. + expectedGasUsed := (params.TxGas + vm.GasQuickStep + params.ColdAccountAccessCostEIP2929 + params.SelfdestructGasEIP150) / 2 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreModifyGasPreLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 3 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) + // i.e. no refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929) + + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreClearGasPreLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x0, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 0 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + + // Expected gas is (intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) ) / 2 + // The refund of params.SstoreClearsScheduleRefundEIP2200 is not applied because of the refund cap to half the gas cost. + expectedGasUsage := (params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929)) / 2 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsage) +} + +func TestSstoreGasPreLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x3, // location + byte(vm.SSTORE), // Set slot[3] = 3 + } + // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreGas + // i.e. No refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + params.SstoreSetGasEIP2200 + + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, preLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSelfDestructGasPostLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PC), + byte(vm.SELFDESTRUCT), + } + // Expected gas is intrinsic + pc + cold load (due to legacy tx) + SelfDestructGas + // i.e. No refund + expectedGasUsed := params.TxGas + vm.GasQuickStep + params.ColdAccountAccessCostEIP2929 + params.SelfdestructGasEIP150 + + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreGasPostLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x3, // location + byte(vm.SSTORE), // Set slot[3] = 3 + } + // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreGas + // i.e. No refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + params.SstoreSetGasEIP2200 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreModifyGasPostLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 3 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) + // i.e. No refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929) + + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + + TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreClearGasPostLondon(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x0, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 0 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + + // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) - sstoreClearGasRefund + expectedGasUsage := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + (params.SstoreResetGasEIP2200 - params.ColdSloadCostEIP2929) - params.SstoreClearsScheduleRefundEIP3529 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, postLondonConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsage) +} diff --git a/core/parlia_tests/eip3529_parlia_test.go b/core/parlia_tests/eip3529_parlia_test.go new file mode 100644 index 0000000000..d2cc9f117b --- /dev/null +++ b/core/parlia_tests/eip3529_parlia_test.go @@ -0,0 +1,311 @@ +package parlia_tests + +import ( + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "math/big" + "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" +) + +func postHertzConfig() *params.ChainConfig { + config := *params.ParliaTestChainConfig + return &config +} + +func preHertzConfig() *params.ChainConfig { + config := *params.ParliaTestChainConfig + config.LondonBlock = nil + config.BerlinBlock = nil + config.HertzBlock = nil + return &config +} + +func TestSelfDestructGasPreHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PC), + byte(vm.SELFDESTRUCT), + } + + // Expected gas is (intrinsic + selfdestruct cost ) / 2 + // The refund of 24000 gas (i.e. params.SelfdestructRefundGas) is not applied since refunds pre-EIP3529 are + // capped to half of the transaction's gas. + expectedGasUsed := (params.TxGas + vm.GasQuickStep + params.SelfdestructGasEIP150) / 2 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + + TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreClearGasPreHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x0, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 0 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + + // Expected gas is (intrinsic + 2*pushGas + SstoreReset (a->b such that a!=0) ) / 2 + // The refund of params.SstoreClearsScheduleRefundEIP2200 is not applied because of the refund cap to half the gas cost. + expectedGasUsage := (params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200) / 2 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsage) +} + +func TestSstoreModifyGasPreHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 3 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + // Expected gas is intrinsic + 2*pushGas + SstoreReset (a->b such that a!=0) + // i.e. no refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreGasPreHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x3, // location + byte(vm.SSTORE), // Set slot[3] = 3 + } + // Expected gas is intrinsic + 2*pushGas + SstoreGas + // i.e. No refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.SstoreSetGasEIP2200 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, preHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSelfDestructGasPostHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PC), + byte(vm.SELFDESTRUCT), + } + // Expected gas is intrinsic + pc + cold load (due to legacy tx) + SelfDestructGas + // i.e. No refund + expectedGasUsed := params.TxGas + vm.GasQuickStep + params.ColdAccountAccessCostEIP2929 + params.SelfdestructGasEIP150 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreGasPostHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x3, // location + byte(vm.SSTORE), // Set slot[3] = 3 + } + // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreGas + // i.e. No refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.ColdSloadCostEIP2929 + params.SstoreSetGasEIP2200 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: nil, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + + TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreModifyGasPostHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x3, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 3 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + // Expected gas is intrinsic + 2*pushGas + cold load (due to legacy tx) + SstoreReset (a->b such that a!=0) + // i.e. No refund + expectedGasUsed := params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsed) +} + +func TestSstoreClearGasPostHertz(t *testing.T) { + bytecode := []byte{ + byte(vm.PUSH1), 0x0, // value + byte(vm.PUSH1), 0x1, // location + byte(vm.SSTORE), // Set slot[1] = 0 + } + // initialize contract storage + initialStorage := make(map[common.Hash]common.Hash) + // Populate two slots + initialStorage[common.HexToHash("01")] = common.HexToHash("01") + initialStorage[common.HexToHash("02")] = common.HexToHash("02") + + // Expected gas is intrinsic + 2*pushGas + SstoreReset (a->b such that a!=0) - sstoreClearGasRefund + expectedGasUsage := params.TxGas + 2*vm.GasFastestStep + params.SstoreResetGasEIP2200 - params.SstoreClearsScheduleRefundEIP3529 + aa := common.HexToAddress("0x000000000000000000000000000000000000aaaa") + txData := &types.LegacyTx{ + Nonce: 0, + To: &aa, + Gas: 60_000, + GasPrice: newGwei(5), + } + // A sender who makes transactions, has some funds + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address := crypto.PubkeyToAddress(key.PublicKey) + balanceBefore := big.NewInt(1000000000000000) + gAlloc := core.GenesisAlloc{ + address: {Balance: balanceBefore}, + aa: { + Code: bytecode, + Storage: initialStorage, + Nonce: 0, + Balance: big.NewInt(0), + }, + } + + TestGasUsage(t, postHertzConfig(), ethash.NewFaker(), key, gAlloc, txData, expectedGasUsage) +} diff --git a/core/eip3529tests/eip3529_test_util.go b/core/parlia_tests/parlia_test_util.go similarity index 63% rename from core/eip3529tests/eip3529_test_util.go rename to core/parlia_tests/parlia_test_util.go index 2ca1ebf777..a7a35f7ca8 100644 --- a/core/eip3529tests/eip3529_test_util.go +++ b/core/parlia_tests/parlia_test_util.go @@ -1,17 +1,17 @@ -package eip3529tests +package parlia_tests import ( - "math/big" - "testing" - + "crypto/ecdsa" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "math/big" + "reflect" + "testing" ) func newGwei(n int64) *big.Int { @@ -19,43 +19,30 @@ func newGwei(n int64) *big.Int { } // Test the gas used by running a transaction sent to a smart contract with given bytecode and storage. -func TestGasUsage(t *testing.T, config *params.ChainConfig, engine consensus.Engine, bytecode []byte, initialStorage map[common.Hash]common.Hash, initialGas, expectedGasUsed uint64) { +func TestGasUsage(t *testing.T, config *params.ChainConfig, engine consensus.Engine, key *ecdsa.PrivateKey, gAlloc core.GenesisAlloc, txData types.TxData, expectedGasUsed uint64) { var ( - aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") - // Generate a canonical chain to act as the main dataset db = rawdb.NewMemoryDatabase() - // A sender who makes transactions, has some funds - key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - address = crypto.PubkeyToAddress(key.PublicKey) - balanceBefore = big.NewInt(1000000000000000) - gspec = &core.Genesis{ + gspec = &core.Genesis{ Config: config, - Alloc: core.GenesisAlloc{ - address: {Balance: balanceBefore}, - aa: { - Code: bytecode, - Storage: initialStorage, - Nonce: 0, - Balance: big.NewInt(0), - }, - }, + Alloc: gAlloc, } genesis = gspec.MustCommit(db) ) blocks, _ := core.GenerateChain(gspec.Config, genesis, engine, db, 1, func(i int, b *core.BlockGen) { b.SetCoinbase(common.Address{1}) - // One transaction to 0xAAAA signer := types.LatestSigner(gspec.Config) - tx, _ := types.SignNewTx(key, signer, &types.LegacyTx{ - Nonce: 0, - To: &aa, - Gas: initialGas, - GasPrice: newGwei(5), - }) + txType := reflect.TypeOf(txData) + var tx *types.Transaction + if txType.String() == "*types.AccessListTx" { + txData.(*types.AccessListTx).GasPrice = b.BaseFee() + tx, _ = types.SignNewTx(key, signer, txData) + } else { + tx, _ = types.SignNewTx(key, signer, txData) + } b.AddTx(tx) }) From 534fb0076d0cdcf8af4f5556bf6124dd6c6559d6 Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 13 Jun 2023 11:04:04 +0800 Subject: [PATCH 2/2] fix: fix lint issue --- core/parlia_tests/eip2718_parlia_test.go | 5 +++-- core/parlia_tests/eip3529_ethash_test.go | 5 +++-- core/parlia_tests/eip3529_parlia_test.go | 5 +++-- core/parlia_tests/parlia_test_util.go | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/parlia_tests/eip2718_parlia_test.go b/core/parlia_tests/eip2718_parlia_test.go index a69cb095cd..8f6d2bd6b1 100644 --- a/core/parlia_tests/eip2718_parlia_test.go +++ b/core/parlia_tests/eip2718_parlia_test.go @@ -1,11 +1,12 @@ package parlia_tests import ( + "math/big" + "testing" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "math/big" - "testing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus/ethash" diff --git a/core/parlia_tests/eip3529_ethash_test.go b/core/parlia_tests/eip3529_ethash_test.go index 28068d34b0..f6e00fec38 100644 --- a/core/parlia_tests/eip3529_ethash_test.go +++ b/core/parlia_tests/eip3529_ethash_test.go @@ -1,11 +1,12 @@ package parlia_tests import ( + "math/big" + "testing" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "math/big" - "testing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus/ethash" diff --git a/core/parlia_tests/eip3529_parlia_test.go b/core/parlia_tests/eip3529_parlia_test.go index d2cc9f117b..a2f58d0ef2 100644 --- a/core/parlia_tests/eip3529_parlia_test.go +++ b/core/parlia_tests/eip3529_parlia_test.go @@ -1,11 +1,12 @@ package parlia_tests import ( + "math/big" + "testing" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "math/big" - "testing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus/ethash" diff --git a/core/parlia_tests/parlia_test_util.go b/core/parlia_tests/parlia_test_util.go index a7a35f7ca8..bf55a8ba61 100644 --- a/core/parlia_tests/parlia_test_util.go +++ b/core/parlia_tests/parlia_test_util.go @@ -2,6 +2,10 @@ package parlia_tests import ( "crypto/ecdsa" + "math/big" + "reflect" + "testing" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core" @@ -9,9 +13,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" - "math/big" - "reflect" - "testing" ) func newGwei(n int64) *big.Int {