From 4be3ee5b6c6b6e88c42ccf44c970fde7fbe2736f Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 10 Jan 2025 18:56:12 +0800 Subject: [PATCH] core: move genesis alloc types to core/types (#29003) --- accounts/abi/bind/backends/simulated.go | 4 +- accounts/abi/bind/backends/simulated_test.go | 21 ++-- accounts/abi/bind/bind_test.go | 96 +++++++++---------- accounts/abi/bind/util_test.go | 5 +- cmd/puppeth/genesis.go | 19 ++-- cmd/puppeth/wizard_genesis.go | 21 ++-- consensus/tests/api_test.go | 4 +- consensus/tests/engine_v1_tests/helper.go | 4 +- consensus/tests/engine_v2_tests/helper.go | 8 +- contracts/blocksigner/blocksigner_test.go | 4 +- contracts/ens/ens_test.go | 4 +- contracts/randomize/randomize_test.go | 5 +- contracts/tests/Inherited_test.go | 4 +- contracts/trc21issuer/trc21issuer_test.go | 4 +- contracts/utils_test.go | 3 +- contracts/validator/validator_test.go | 9 +- core/bench_test.go | 5 +- core/blockchain_test.go | 18 ++-- core/chain_makers_test.go | 2 +- core/gen_genesis.go | 9 +- core/genesis.go | 87 ++++------------- core/genesis_test.go | 6 +- core/state_processor_test.go | 8 +- core/types/account.go | 88 +++++++++++++++++ .../gen_account.go} | 44 ++++----- eth/filters/filter_system_test.go | 2 +- eth/gasprice/gasprice_test.go | 2 +- eth/helper_test.go | 2 +- eth/tracers/tracers_test.go | 18 ++-- les/helper_test.go | 2 +- light/odr_test.go | 2 +- light/trie_test.go | 3 +- light/txpool_test.go | 2 +- tests/block_test_util.go | 4 +- tests/state_test_util.go | 4 +- tests/vm_test_util.go | 5 +- 36 files changed, 282 insertions(+), 246 deletions(-) create mode 100644 core/types/account.go rename core/{gen_genesis_account.go => types/gen_account.go} (61%) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index e24636ac680ed..3f73d01cf2a17 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -102,7 +102,7 @@ func SimulateWalletAddressAndSignFn() (common.Address, func(account accounts.Acc } // NewXDCSimulatedBackend creates a new backend for testing purpose. -func NewXDCSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64, chainConfig *params.ChainConfig) *SimulatedBackend { +func NewXDCSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64, chainConfig *params.ChainConfig) *SimulatedBackend { database := rawdb.NewMemoryDatabase() genesis := core.Genesis{ GasLimit: gasLimit, // need this big, support initial smart contract @@ -147,7 +147,7 @@ func NewXDCSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64, chainConfi // SimulOldNewSimulatedBackendatedBackend creates a new binding backend based on the given database // and uses a simulated blockchain for testing purposes. // A simulated backend always uses chainID 1337. -func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend { +func NewSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64) *SimulatedBackend { database := rawdb.NewMemoryDatabase() genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc} genesis.MustCommit(database) diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index b8848a6e8d8db..187582fd89d22 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -31,7 +31,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/accounts/abi" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" @@ -42,8 +41,8 @@ func TestSimulatedBackend(t *testing.T) { var gasLimit uint64 = 8000029 key, _ := crypto.GenerateKey() // nolint: gosec auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - genAlloc := make(core.GenesisAlloc) - genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)} + genAlloc := make(types.GenesisAlloc) + genAlloc[auth.From] = types.Account{Balance: big.NewInt(9223372036854775807)} config := *params.TestXDPoSMockChainConfig config.Eip1559Block = big.NewInt(0) @@ -119,7 +118,7 @@ func simTestBackend(testAddr common.Address) *SimulatedBackend { config := *params.TestXDPoSMockChainConfig config.Eip1559Block = big.NewInt(0) return NewXDCSimulatedBackend( - core.GenesisAlloc{ + types.GenesisAlloc{ testAddr: {Balance: big.NewInt(100000000000000000)}, }, 10000000, @@ -144,7 +143,7 @@ func TestNewSimulatedBackend(t *testing.T) { func TestAdjustTime(t *testing.T) { t.Parallel() sim := NewXDCSimulatedBackend( - core.GenesisAlloc{}, + types.GenesisAlloc{}, 10000000, params.TestXDPoSMockChainConfig, ) @@ -226,7 +225,7 @@ func TestBalanceAt(t *testing.T) { func TestBlockByHash(t *testing.T) { t.Parallel() sim := NewXDCSimulatedBackend( - core.GenesisAlloc{}, + types.GenesisAlloc{}, 10000000, params.TestXDPoSMockChainConfig, ) @@ -250,7 +249,7 @@ func TestBlockByHash(t *testing.T) { func TestBlockByNumber(t *testing.T) { t.Parallel() sim := NewXDCSimulatedBackend( - core.GenesisAlloc{}, + types.GenesisAlloc{}, 10000000, params.TestXDPoSMockChainConfig, ) @@ -446,7 +445,7 @@ func TestEstimateGas(t *testing.T) { opts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) sim := NewXDCSimulatedBackend( - core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}}, + types.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}}, 10000000, params.TestXDPoSMockChainConfig, ) @@ -557,10 +556,10 @@ func TestEstimateGasWithPrice(t *testing.T) { addr := crypto.PubkeyToAddress(key.PublicKey) sim := NewXDCSimulatedBackend( - core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether*2 + 2e17)}}, + types.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether*2 + 2e17)}}, 10000000, params.TestXDPoSMockChainConfig, -) + ) defer sim.Close() recipient := common.HexToAddress("deadbeef") @@ -908,7 +907,7 @@ func TestTransactionReceipt(t *testing.T) { func TestSuggestGasPrice(t *testing.T) { t.Parallel() sim := NewXDCSimulatedBackend( - core.GenesisAlloc{}, + types.GenesisAlloc{}, 10000000, params.TestXDPoSMockChainConfig, ) diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go index 22b7f41d3aac3..3bd3d869482b8 100644 --- a/accounts/abi/bind/bind_test.go +++ b/accounts/abi/bind/bind_test.go @@ -290,7 +290,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -299,7 +299,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy an interaction tester contract and call a transaction on it @@ -346,7 +346,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -355,7 +355,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a tuple tester contract and execute a structured call on it @@ -393,7 +393,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -402,7 +402,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a tuple tester contract and execute a structured call on it @@ -452,7 +452,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -461,7 +461,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a slice tester contract and execute a n array call on it @@ -501,7 +501,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -510,7 +510,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a default method invoker contract and execute its default method @@ -568,7 +568,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -577,7 +577,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a structs method invoker contract and execute its default method @@ -615,12 +615,12 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/params" `, ` // Create a simulator and wrap a non-deployed contract - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{}, uint64(10000000000), params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{}, uint64(10000000000), params.TestXDPoSMockChainConfig) defer sim.Close() nonexistent, err := NewNonExistent(common.Address{}, sim) @@ -654,12 +654,12 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/params" `, ` // Create a simulator and wrap a non-deployed contract - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() nonexistent, err := NewNonExistentStruct(common.Address{}, sim) @@ -701,7 +701,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -710,7 +710,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a funky gas pattern contract @@ -753,7 +753,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -762,7 +762,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a sender tester contract and execute a structured call on it @@ -830,7 +830,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -838,7 +838,7 @@ var bindTests = []struct { // Generate a new random account and a funded simulator key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a underscorer tester contract and execute a structured call on it @@ -924,7 +924,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -933,7 +933,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy an eventer contract @@ -1115,7 +1115,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1124,7 +1124,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() //deploy the test contract @@ -1253,7 +1253,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1262,7 +1262,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() _, _, contract, err := DeployTuple(auth, sim) @@ -1393,7 +1393,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1402,7 +1402,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // deploy the test contract @@ -1484,7 +1484,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/crypto" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/params" `, ` @@ -1493,7 +1493,7 @@ var bindTests = []struct { addr := crypto.PubkeyToAddress(key.PublicKey) // Deploy registrar contract - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() transactOpts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) @@ -1548,7 +1548,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/crypto" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/params" `, ` @@ -1556,7 +1556,7 @@ var bindTests = []struct { addr := crypto.PubkeyToAddress(key.PublicKey) // Deploy registrar contract - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() transactOpts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) @@ -1610,7 +1610,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1619,7 +1619,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() // Deploy a tester contract and execute a structured call on it @@ -1672,7 +1672,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1680,7 +1680,7 @@ var bindTests = []struct { key, _ := crypto.GenerateKey() addr := crypto.PubkeyToAddress(key.PublicKey) - sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) defer sim.Close() opts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) @@ -1761,7 +1761,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1769,7 +1769,7 @@ var bindTests = []struct { var ( key, _ = crypto.GenerateKey() user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim = backends.NewXDCSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim = backends.NewXDCSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) ) defer sim.Close() @@ -1831,7 +1831,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1839,7 +1839,7 @@ var bindTests = []struct { var ( key, _ = crypto.GenerateKey() user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim = backends.NewXDCSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim = backends.NewXDCSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) ) defer sim.Close() @@ -1883,7 +1883,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1891,7 +1891,7 @@ var bindTests = []struct { var ( key, _ = crypto.GenerateKey() user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim = backends.NewXDCSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim = backends.NewXDCSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) ) defer sim.Close() @@ -1931,7 +1931,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1939,7 +1939,7 @@ var bindTests = []struct { var ( key, _ = crypto.GenerateKey() user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim = backends.NewXDCSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim = backends.NewXDCSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) ) defer sim.Close() @@ -1971,7 +1971,7 @@ var bindTests = []struct { "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" `, @@ -1979,7 +1979,7 @@ var bindTests = []struct { var ( key, _ = crypto.GenerateKey() user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim = backends.NewXDCSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + sim = backends.NewXDCSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) ) _, tx, _, err := DeployRangeKeyword(user, sim) if err != nil { diff --git a/accounts/abi/bind/util_test.go b/accounts/abi/bind/util_test.go index cf50ec4737ad9..89deb2c5599b0 100644 --- a/accounts/abi/bind/util_test.go +++ b/accounts/abi/bind/util_test.go @@ -26,7 +26,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" @@ -59,7 +58,7 @@ func TestWaitDeployed(t *testing.T) { config.Eip1559Block = big.NewInt(0) for name, test := range waitDeployedTests { backend := backends.NewXDCSimulatedBackend( - core.GenesisAlloc{ + types.GenesisAlloc{ crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(100000000000000000)}, }, 10000000, @@ -109,7 +108,7 @@ func TestWaitDeployedCornerCases(t *testing.T) { config := *params.TestXDPoSMockChainConfig config.Eip1559Block = big.NewInt(0) backend := backends.NewXDCSimulatedBackend( - core.GenesisAlloc{ + types.GenesisAlloc{ crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(100000000000000000)}, }, 10000000, diff --git a/cmd/puppeth/genesis.go b/cmd/puppeth/genesis.go index 6aef1cf27e762..a27891ced0e9e 100644 --- a/cmd/puppeth/genesis.go +++ b/cmd/puppeth/genesis.go @@ -25,6 +25,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/common/hexutil" "github.com/XinFinOrg/XDPoSChain/consensus/ethash" "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/params" ) @@ -344,15 +345,15 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin // pyEthereumGenesisSpec represents the genesis specification format used by the // Python Ethereum implementation. type pyEthereumGenesisSpec struct { - Nonce hexutil.Bytes `json:"nonce"` - Timestamp hexutil.Uint64 `json:"timestamp"` - ExtraData hexutil.Bytes `json:"extraData"` - GasLimit hexutil.Uint64 `json:"gasLimit"` - Difficulty *hexutil.Big `json:"difficulty"` - Mixhash common.Hash `json:"mixhash"` - Coinbase common.Address `json:"coinbase"` - Alloc core.GenesisAlloc `json:"alloc"` - ParentHash common.Hash `json:"parentHash"` + Nonce hexutil.Bytes `json:"nonce"` + Timestamp hexutil.Uint64 `json:"timestamp"` + ExtraData hexutil.Bytes `json:"extraData"` + GasLimit hexutil.Uint64 `json:"gasLimit"` + Difficulty *hexutil.Big `json:"difficulty"` + Mixhash common.Hash `json:"mixhash"` + Coinbase common.Address `json:"coinbase"` + Alloc types.GenesisAlloc `json:"alloc"` + ParentHash common.Hash `json:"parentHash"` } // newPyEthereumGenesisSpec converts a go-ethereum genesis block into a Parity specific diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index af52abc8e4593..e2dbdbc623356 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -26,6 +26,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/log" "github.com/XinFinOrg/XDPoSChain/params" @@ -49,7 +50,7 @@ func (w *wizard) makeGenesis() { Timestamp: uint64(time.Now().Unix()), GasLimit: 4700000, Difficulty: big.NewInt(524288), - Alloc: make(core.GenesisAlloc), + Alloc: make(types.GenesisAlloc), Config: ¶ms.ChainConfig{ HomesteadBlock: big.NewInt(0), EIP150Block: big.NewInt(0), @@ -202,7 +203,7 @@ func (w *wizard) makeGenesis() { // Validator Smart Contract Code pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") addr := crypto.PubkeyToAddress(pKey.PublicKey) - contractBackend := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + contractBackend := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) transactOpts := bind.NewKeyedTransactor(pKey) validatorAddress, _, err := validatorContract.DeployValidator(transactOpts, contractBackend, signers, validatorCaps, owner) @@ -225,7 +226,7 @@ func (w *wizard) makeGenesis() { return true } contractBackend.ForEachStorageAt(ctx, validatorAddress, nil, f) - genesis.Alloc[common.MasternodeVotingSMCBinary] = core.GenesisAccount{ + genesis.Alloc[common.MasternodeVotingSMCBinary] = types.Account{ Balance: validatorCap.Mul(validatorCap, big.NewInt(int64(len(validatorCaps)))), Code: code, Storage: storage, @@ -259,7 +260,7 @@ func (w *wizard) makeGenesis() { fBalance := big.NewInt(0) // 16m fBalance.Add(fBalance, big.NewInt(16*1000*1000)) fBalance.Mul(fBalance, big.NewInt(1000000000000000000)) - genesis.Alloc[common.FoudationAddrBinary] = core.GenesisAccount{ + genesis.Alloc[common.FoudationAddrBinary] = types.Account{ Balance: fBalance, Code: code, Storage: storage, @@ -275,7 +276,7 @@ func (w *wizard) makeGenesis() { code, _ = contractBackend.CodeAt(ctx, blockSignerAddress, nil) storage = make(map[common.Hash]common.Hash) contractBackend.ForEachStorageAt(ctx, blockSignerAddress, nil, f) - genesis.Alloc[common.BlockSignersBinary] = core.GenesisAccount{ + genesis.Alloc[common.BlockSignersBinary] = types.Account{ Balance: big.NewInt(0), Code: code, Storage: storage, @@ -291,7 +292,7 @@ func (w *wizard) makeGenesis() { code, _ = contractBackend.CodeAt(ctx, randomizeAddress, nil) storage = make(map[common.Hash]common.Hash) contractBackend.ForEachStorageAt(ctx, randomizeAddress, nil, f) - genesis.Alloc[common.RandomizeSMCBinary] = core.GenesisAccount{ + genesis.Alloc[common.RandomizeSMCBinary] = types.Account{ Balance: big.NewInt(0), Code: code, Storage: storage, @@ -330,7 +331,7 @@ func (w *wizard) makeGenesis() { subBalance.Add(subBalance, big.NewInt(int64(len(signers))*50*1000)) subBalance.Mul(subBalance, big.NewInt(1000000000000000000)) balance.Sub(balance, subBalance) // 12m - i * 50k - genesis.Alloc[common.TeamAddrBinary] = core.GenesisAccount{ + genesis.Alloc[common.TeamAddrBinary] = types.Account{ Balance: balance, Code: code, Storage: storage, @@ -342,7 +343,7 @@ func (w *wizard) makeGenesis() { baseBalance := big.NewInt(0) // 55m baseBalance.Add(baseBalance, big.NewInt(55*1000*1000)) baseBalance.Mul(baseBalance, big.NewInt(1000000000000000000)) - genesis.Alloc[swapAddr] = core.GenesisAccount{ + genesis.Alloc[swapAddr] = types.Account{ Balance: baseBalance, } @@ -355,7 +356,7 @@ func (w *wizard) makeGenesis() { for { // Read the address of the account to fund if address := w.readAddress(); address != nil { - genesis.Alloc[*address] = core.GenesisAccount{ + genesis.Alloc[*address] = types.Account{ Balance: new(big.Int).Lsh(big.NewInt(1), 256-7), // 2^256 / 128 (allow many pre-funds without balance overflows) } continue @@ -364,7 +365,7 @@ func (w *wizard) makeGenesis() { } // Add a batch of precompile balances to avoid them getting deleted for i := int64(0); i < 2; i++ { - genesis.Alloc[common.BigToAddress(big.NewInt(i))] = core.GenesisAccount{Balance: big.NewInt(0)} + genesis.Alloc[common.BigToAddress(big.NewInt(i))] = types.Account{Balance: big.NewInt(0)} } // Query the user for some custom extras fmt.Println() diff --git a/consensus/tests/api_test.go b/consensus/tests/api_test.go index 64cbf8043118c..395fd7f60ce0e 100644 --- a/consensus/tests/api_test.go +++ b/consensus/tests/api_test.go @@ -6,7 +6,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/consensus/XDPoS" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" "github.com/stretchr/testify/assert" @@ -18,7 +18,7 @@ var ( ) func TestConfigApi(t *testing.T) { - bc := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + bc := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ voterAddr: {Balance: new(big.Int).SetUint64(10000000000)}, }, 10000000, params.TestXDPoSMockChainConfig) diff --git a/consensus/tests/engine_v1_tests/helper.go b/consensus/tests/engine_v1_tests/helper.go index e1a66d1308eed..c63c325ee2dc1 100644 --- a/consensus/tests/engine_v1_tests/helper.go +++ b/consensus/tests/engine_v1_tests/helper.go @@ -74,7 +74,7 @@ func RandStringBytes(n int) string { func getCommonBackend(t *testing.T, chainConfig *params.ChainConfig) *backends.SimulatedBackend { // initial helper backend - contractBackendForSC := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + contractBackendForSC := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ voterAddr: {Balance: new(big.Int).SetUint64(10000000000)}, }, 10000000, chainConfig) @@ -143,7 +143,7 @@ func getCommonBackend(t *testing.T, chainConfig *params.ChainConfig) *backends.S } // create test backend with smart contract in it - contractBackend2 := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + contractBackend2 := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ acc1Addr: {Balance: new(big.Int).SetUint64(10000000000)}, acc2Addr: {Balance: new(big.Int).SetUint64(10000000000)}, acc3Addr: {Balance: new(big.Int).SetUint64(10000000000)}, diff --git a/consensus/tests/engine_v2_tests/helper.go b/consensus/tests/engine_v2_tests/helper.go index 01a607b0331f9..89439f8119773 100644 --- a/consensus/tests/engine_v2_tests/helper.go +++ b/consensus/tests/engine_v2_tests/helper.go @@ -115,7 +115,7 @@ func voteTX(gasLimit uint64, nonce uint64, addr string) (*types.Transaction, err func getCommonBackend(t *testing.T, chainConfig *params.ChainConfig) *backends.SimulatedBackend { // initial helper backend - contractBackendForSC := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + contractBackendForSC := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ voterAddr: {Balance: new(big.Int).SetUint64(10000000000)}, }, 10000000, chainConfig) @@ -184,7 +184,7 @@ func getCommonBackend(t *testing.T, chainConfig *params.ChainConfig) *backends.S } // create test backend with smart contract in it - contractBackend2 := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + contractBackend2 := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ acc1Addr: {Balance: new(big.Int).SetUint64(10000000000)}, acc2Addr: {Balance: new(big.Int).SetUint64(10000000000)}, acc3Addr: {Balance: new(big.Int).SetUint64(10000000000)}, @@ -198,7 +198,7 @@ func getCommonBackend(t *testing.T, chainConfig *params.ChainConfig) *backends.S func getMultiCandidatesBackend(t *testing.T, chainConfig *params.ChainConfig, n int) *backends.SimulatedBackend { assert.GreaterOrEqual(t, n, 4) // initial helper backend, give a very large gas limit - contractBackendForSC := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + contractBackendForSC := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ voterAddr: {Balance: new(big.Int).SetUint64(10000000000)}, }, 1000000000, chainConfig) @@ -268,7 +268,7 @@ func getMultiCandidatesBackend(t *testing.T, chainConfig *params.ChainConfig, n } // create test backend with smart contract in it - contractBackend2 := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + contractBackend2 := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ acc1Addr: {Balance: new(big.Int).SetUint64(10000000000)}, acc2Addr: {Balance: new(big.Int).SetUint64(10000000000)}, acc3Addr: {Balance: new(big.Int).SetUint64(10000000000)}, diff --git a/contracts/blocksigner/blocksigner_test.go b/contracts/blocksigner/blocksigner_test.go index d1f8cbc0f4861..d4e1bcc394acc 100644 --- a/contracts/blocksigner/blocksigner_test.go +++ b/contracts/blocksigner/blocksigner_test.go @@ -26,7 +26,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" ) @@ -37,7 +37,7 @@ var ( ) func TestBlockSigner(t *testing.T) { - contractBackend := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + contractBackend := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) transactOpts := bind.NewKeyedTransactor(key) blockSignerAddress, blockSigner, err := DeployBlockSigner(transactOpts, contractBackend, big.NewInt(99)) diff --git a/contracts/ens/ens_test.go b/contracts/ens/ens_test.go index 410b5acdadf14..05cef3195be97 100644 --- a/contracts/ens/ens_test.go +++ b/contracts/ens/ens_test.go @@ -23,7 +23,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/contracts/ens/contract" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" ) @@ -36,7 +36,7 @@ var ( ) func TestENS(t *testing.T) { - contractBackend := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + contractBackend := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) transactOpts := bind.NewKeyedTransactor(key) ensAddr, ens, err := DeployENS(transactOpts, contractBackend) diff --git a/contracts/randomize/randomize_test.go b/contracts/randomize/randomize_test.go index 08c38e375d38e..8588bd8fe3108 100644 --- a/contracts/randomize/randomize_test.go +++ b/contracts/randomize/randomize_test.go @@ -26,7 +26,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" "github.com/XinFinOrg/XDPoSChain/contracts" - "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" @@ -42,7 +41,7 @@ var ( ) func TestRandomize(t *testing.T) { - contractBackend := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(100000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + contractBackend := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(100000000000000)}}, 10000000, params.TestXDPoSMockChainConfig) transactOpts := bind.NewKeyedTransactor(key) transactOpts.GasLimit = 1000000 @@ -72,7 +71,7 @@ func TestRandomize(t *testing.T) { } func TestSendTxRandomizeSecretAndOpening(t *testing.T) { - genesis := core.GenesisAlloc{acc1Addr: {Balance: big.NewInt(1000000000000)}} + genesis := types.GenesisAlloc{acc1Addr: {Balance: big.NewInt(1000000000000)}} // TODO(daniel): replace NewSimulatedBackend with NewXDCSimulatedBackend backend := backends.NewSimulatedBackend(genesis, 42000000) backend.Commit() diff --git a/contracts/tests/Inherited_test.go b/contracts/tests/Inherited_test.go index da9178ad1b4f9..2a0c1284877b7 100644 --- a/contracts/tests/Inherited_test.go +++ b/contracts/tests/Inherited_test.go @@ -9,7 +9,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/log" "github.com/XinFinOrg/XDPoSChain/params" @@ -28,7 +28,7 @@ func TestPriceFeed(t *testing.T) { common.TIPXDCXCancellationFee = big.NewInt(0) // init genesis contractBackend := backends.NewXDCSimulatedBackend( - core.GenesisAlloc{ + types.GenesisAlloc{ mainAddr: {Balance: big.NewInt(0).Mul(big.NewInt(10000000000000), big.NewInt(10000000000000))}, }, 42000000, diff --git a/contracts/trc21issuer/trc21issuer_test.go b/contracts/trc21issuer/trc21issuer_test.go index 04d98f41fb1b0..19e3dde595b9a 100644 --- a/contracts/trc21issuer/trc21issuer_test.go +++ b/contracts/trc21issuer/trc21issuer_test.go @@ -8,7 +8,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind" "github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/core" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" ) @@ -32,7 +32,7 @@ var ( func TestFeeTxWithTRC21Token(t *testing.T) { // init genesis contractBackend := backends.NewXDCSimulatedBackend( - core.GenesisAlloc{ + types.GenesisAlloc{ mainAddr: {Balance: big.NewInt(0).Mul(big.NewInt(10000000000000), big.NewInt(10000000000000))}, }, 42000000, diff --git a/contracts/utils_test.go b/contracts/utils_test.go index 0f706c6032478..c30409ceb8dfd 100644 --- a/contracts/utils_test.go +++ b/contracts/utils_test.go @@ -29,7 +29,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils" "github.com/XinFinOrg/XDPoSChain/contracts/blocksigner" - "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" @@ -47,7 +46,7 @@ var ( ) func getCommonBackend() *backends.SimulatedBackend { - genesis := core.GenesisAlloc{acc1Addr: {Balance: big.NewInt(1000000000000)}} + genesis := types.GenesisAlloc{acc1Addr: {Balance: big.NewInt(1000000000000)}} backend := backends.NewXDCSimulatedBackend(genesis, 10000000, params.TestXDPoSMockChainConfig) backend.Commit() diff --git a/contracts/validator/validator_test.go b/contracts/validator/validator_test.go index 090d261770c06..00ed5836503fc 100644 --- a/contracts/validator/validator_test.go +++ b/contracts/validator/validator_test.go @@ -31,7 +31,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" contractValidator "github.com/XinFinOrg/XDPoSChain/contracts/validator/contract" - "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/state" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/crypto" @@ -54,7 +53,7 @@ var ( ) func TestValidator(t *testing.T) { - contractBackend := backends.NewXDCSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) + contractBackend := backends.NewXDCSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000, params.TestXDPoSMockChainConfig) transactOpts := bind.NewKeyedTransactor(key) validatorCap := new(big.Int) @@ -90,7 +89,7 @@ func TestValidator(t *testing.T) { } func TestRewardBalance(t *testing.T) { - contractBackend := backends.NewXDCSimulatedBackend(core.GenesisAlloc{ + contractBackend := backends.NewXDCSimulatedBackend(types.GenesisAlloc{ acc1Addr: {Balance: new(big.Int).SetUint64(10000000)}, acc2Addr: {Balance: new(big.Int).SetUint64(10000000)}, acc4Addr: {Balance: new(big.Int).SetUint64(10000000)}, @@ -274,7 +273,7 @@ func TestStatedbUtils(t *testing.T) { validatorCap.SetString("50000000000000000000000", 10) voteAmount := new(big.Int) voteAmount.SetString("25000000000000000000000", 10) - genesisAlloc := core.GenesisAlloc{ + genesisAlloc := types.GenesisAlloc{ addr: {Balance: big.NewInt(1000000000)}, acc1Addr: {Balance: validatorCap}, acc2Addr: {Balance: validatorCap}, @@ -310,7 +309,7 @@ func TestStatedbUtils(t *testing.T) { return true } contractBackend.ForEachStorageAt(ctx, validatorAddress, nil, f) - genesisAlloc[common.MasternodeVotingSMCBinary] = core.GenesisAccount{ + genesisAlloc[common.MasternodeVotingSMCBinary] = types.Account{ Balance: validatorCap, Code: code, Storage: storage, diff --git a/core/bench_test.go b/core/bench_test.go index e65e38ec0dea7..baee84dd9d35a 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -22,11 +22,10 @@ import ( "os" "testing" - "github.com/XinFinOrg/XDPoSChain/core/rawdb" - "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/math" "github.com/XinFinOrg/XDPoSChain/consensus/ethash" + "github.com/XinFinOrg/XDPoSChain/core/rawdb" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/core/vm" "github.com/XinFinOrg/XDPoSChain/crypto" @@ -164,7 +163,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) { // generator function. gspec := Genesis{ Config: params.TestChainConfig, - Alloc: GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}}, + Alloc: types.GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}}, } genesis := gspec.MustCommit(db) chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, b.N, gen) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index b26cb1c2413b7..7601beb50b4ff 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -557,7 +557,7 @@ func TestFastVsFullChains(t *testing.T) { funds = big.NewInt(1000000000000000) gspec = &Genesis{ Config: params.TestChainConfig, - Alloc: GenesisAlloc{address: {Balance: funds}}, + Alloc: types.GenesisAlloc{address: {Balance: funds}}, BaseFee: big.NewInt(params.InitialBaseFee), } genesis = gspec.MustCommit(gendb) @@ -646,7 +646,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { funds = big.NewInt(1000000000000000) gspec = &Genesis{ Config: params.TestChainConfig, - Alloc: GenesisAlloc{address: {Balance: funds}}, + Alloc: types.GenesisAlloc{address: {Balance: funds}}, BaseFee: big.NewInt(params.InitialBaseFee), } genesis = gspec.MustCommit(gendb) @@ -733,7 +733,7 @@ func TestChainTxReorgs(t *testing.T) { gspec = &Genesis{ Config: params.TestChainConfig, GasLimit: 3141592, - Alloc: GenesisAlloc{ + Alloc: types.GenesisAlloc{ addr1: {Balance: big.NewInt(1000000000000000)}, addr2: {Balance: big.NewInt(1000000000000000)}, addr3: {Balance: big.NewInt(1000000000000000)}, @@ -844,7 +844,7 @@ func TestLogReorgs(t *testing.T) { db = rawdb.NewMemoryDatabase() // this code generates a log code = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00") - gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} + gspec = &Genesis{Config: params.TestChainConfig, Alloc: types.GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) ) @@ -1023,7 +1023,7 @@ func TestEIP155Transition(t *testing.T) { deleteAddr = common.Address{1} gspec = &Genesis{ Config: ¶ms.ChainConfig{ChainId: big.NewInt(1), EIP150Block: big.NewInt(0), EIP155Block: big.NewInt(2), HomesteadBlock: new(big.Int)}, - Alloc: GenesisAlloc{address: {Balance: funds}, deleteAddr: {Balance: new(big.Int)}}, + Alloc: types.GenesisAlloc{address: {Balance: funds}, deleteAddr: {Balance: new(big.Int)}}, } genesis = gspec.MustCommit(db) ) @@ -1131,7 +1131,7 @@ func TestEIP161AccountRemoval(t *testing.T) { EIP155Block: new(big.Int), EIP158Block: big.NewInt(2), }, - Alloc: GenesisAlloc{address: {Balance: funds}}, + Alloc: types.GenesisAlloc{address: {Balance: funds}}, } genesis = gspec.MustCommit(db) ) @@ -1452,7 +1452,7 @@ func TestEIP2718Transition(t *testing.T) { IstanbulBlock: big.NewInt(0), Eip1559Block: big.NewInt(0), }, - Alloc: GenesisAlloc{ + Alloc: types.GenesisAlloc{ address: {Balance: funds}, // The address 0xAAAA sloads 0x00 and 0x01 aa: { @@ -1553,7 +1553,7 @@ func TestTransientStorageReset(t *testing.T) { }...) gspec := &Genesis{ Config: params.TestChainConfig, - Alloc: GenesisAlloc{ + Alloc: types.GenesisAlloc{ address: {Balance: funds}, }, } @@ -1624,7 +1624,7 @@ func TestEIP3651(t *testing.T) { funds = big.NewInt(8000000000000000) gspec = &Genesis{ Config: params.TestChainConfig, - Alloc: GenesisAlloc{ + Alloc: types.GenesisAlloc{ addr1: {Balance: funds}, addr2: {Balance: funds}, // The address 0xAAAA sloads 0x00 and 0x01 diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index 1dbcaf9fb048d..d24cd2ec9e4d3 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -41,7 +41,7 @@ func ExampleGenerateChain() { // Ensure that key1 has some funds in the genesis block. gspec := &Genesis{ Config: ¶ms.ChainConfig{HomesteadBlock: new(big.Int)}, - Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(1000000)}}, + Alloc: types.GenesisAlloc{addr1: {Balance: big.NewInt(1000000)}}, } genesis := gspec.MustCommit(db) diff --git a/core/gen_genesis.go b/core/gen_genesis.go index 27dcb1f7cc131..181f6740d773d 100644 --- a/core/gen_genesis.go +++ b/core/gen_genesis.go @@ -10,6 +10,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" "github.com/XinFinOrg/XDPoSChain/common/math" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/params" ) @@ -26,7 +27,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) { Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash common.Hash `json:"mixHash"` Coinbase common.Address `json:"coinbase"` - Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"` + Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"` Number math.HexOrDecimal64 `json:"number"` GasUsed math.HexOrDecimal64 `json:"gasUsed"` ParentHash common.Hash `json:"parentHash"` @@ -42,7 +43,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) { enc.Mixhash = g.Mixhash enc.Coinbase = g.Coinbase if g.Alloc != nil { - enc.Alloc = make(map[common.UnprefixedAddress]GenesisAccount, len(g.Alloc)) + enc.Alloc = make(map[common.UnprefixedAddress]types.Account, len(g.Alloc)) for k, v := range g.Alloc { enc.Alloc[common.UnprefixedAddress(k)] = v } @@ -65,7 +66,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash *common.Hash `json:"mixHash"` Coinbase *common.Address `json:"coinbase"` - Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"` + Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"` Number *math.HexOrDecimal64 `json:"number"` GasUsed *math.HexOrDecimal64 `json:"gasUsed"` ParentHash *common.Hash `json:"parentHash"` @@ -104,7 +105,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { if dec.Alloc == nil { return errors.New("missing required field 'alloc' for Genesis") } - g.Alloc = make(GenesisAlloc, len(dec.Alloc)) + g.Alloc = make(types.GenesisAlloc, len(dec.Alloc)) for k, v := range dec.Alloc { g.Alloc[common.Address(k)] = v } diff --git a/core/genesis.go b/core/genesis.go index d14b1c73d153a..95b1aefa5c4fc 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -17,33 +17,35 @@ package core import ( - "bytes" - "encoding/hex" "encoding/json" "errors" "fmt" "math/big" "strings" - "github.com/XinFinOrg/XDPoSChain/core/rawdb" - "github.com/XinFinOrg/XDPoSChain/crypto" - "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" "github.com/XinFinOrg/XDPoSChain/common/math" + "github.com/XinFinOrg/XDPoSChain/core/rawdb" "github.com/XinFinOrg/XDPoSChain/core/state" "github.com/XinFinOrg/XDPoSChain/core/types" + "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/ethdb" "github.com/XinFinOrg/XDPoSChain/log" "github.com/XinFinOrg/XDPoSChain/params" "github.com/XinFinOrg/XDPoSChain/rlp" ) -//go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go -//go:generate gencodec -type GenesisAccount -field-override genesisAccountMarshaling -out gen_genesis_account.go +//go:generate go run github.com/fjl/gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go var errGenesisNoConfig = errors.New("genesis has no chain configuration") +// Deprecated: use types.GenesisAccount instead. +type GenesisAccount = types.Account + +// Deprecated: use types.GenesisAlloc instead. +type GenesisAlloc = types.GenesisAlloc + // Genesis specifies the header fields, state of a genesis block. It also defines hard // fork switch-over blocks through the chain configuration. type Genesis struct { @@ -55,7 +57,7 @@ type Genesis struct { Difficulty *big.Int `json:"difficulty" gencodec:"required"` Mixhash common.Hash `json:"mixHash"` Coinbase common.Address `json:"coinbase"` - Alloc GenesisAlloc `json:"alloc" gencodec:"required"` + Alloc types.GenesisAlloc `json:"alloc" gencodec:"required"` // These fields are used for consensus tests. Please don't use them // in actual genesis blocks. @@ -65,30 +67,6 @@ type Genesis struct { BaseFee *big.Int `json:"baseFeePerGas"` } -// GenesisAlloc specifies the initial state that is part of the genesis block. -type GenesisAlloc map[common.Address]GenesisAccount - -func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error { - m := make(map[common.UnprefixedAddress]GenesisAccount) - if err := json.Unmarshal(data, &m); err != nil { - return err - } - *ga = make(GenesisAlloc) - for addr, a := range m { - (*ga)[common.Address(addr)] = a - } - return nil -} - -// GenesisAccount is an account in the state of the genesis block. -type GenesisAccount struct { - Code []byte `json:"code,omitempty"` - Storage map[common.Hash]common.Hash `json:"storage,omitempty"` - Balance *big.Int `json:"balance" gencodec:"required"` - Nonce uint64 `json:"nonce,omitempty"` - PrivateKey []byte `json:"secretKey,omitempty"` // for tests -} - // field type overrides for gencodec type genesisSpecMarshaling struct { Nonce math.HexOrDecimal64 @@ -99,36 +77,7 @@ type genesisSpecMarshaling struct { Number math.HexOrDecimal64 Difficulty *math.HexOrDecimal256 BaseFee *math.HexOrDecimal256 - Alloc map[common.UnprefixedAddress]GenesisAccount -} - -type genesisAccountMarshaling struct { - Code hexutil.Bytes - Balance *math.HexOrDecimal256 - Nonce math.HexOrDecimal64 - Storage map[storageJSON]storageJSON - PrivateKey hexutil.Bytes -} - -// storageJSON represents a 256 bit byte array, but allows less than 256 bits when -// unmarshaling from hex. -type storageJSON common.Hash - -func (h *storageJSON) UnmarshalText(text []byte) error { - text = bytes.TrimPrefix(text, []byte("0x")) - if len(text) > 64 { - return fmt.Errorf("too many hex characters in storage key/value %q", text) - } - offset := len(h) - len(text)/2 // pad on the left - if _, err := hex.Decode(h[offset:], text); err != nil { - fmt.Println(err) - return fmt.Errorf("invalid hex storage key/value %q", text) - } - return nil -} - -func (h storageJSON) MarshalText() ([]byte, error) { - return hexutil.Bytes(h[:]).MarshalText() + Alloc map[common.UnprefixedAddress]types.Account } // GenesisMismatchError is raised when trying to overwrite an existing @@ -320,7 +269,7 @@ func (g *Genesis) MustCommit(db ethdb.Database) *types.Block { // GenesisBlockForTesting creates and writes a block in which addr has the given wei balance. func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block { g := Genesis{ - Alloc: GenesisAlloc{addr: {Balance: balance}}, + Alloc: types.GenesisAlloc{addr: {Balance: balance}}, BaseFee: big.NewInt(params.InitialBaseFee), } return g.MustCommit(db) @@ -381,7 +330,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { GasLimit: 6283185, BaseFee: big.NewInt(params.InitialBaseFee), Difficulty: big.NewInt(1), - Alloc: map[common.Address]GenesisAccount{ + Alloc: map[common.Address]types.Account{ common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256 common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD @@ -395,20 +344,20 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { } } -func decodePrealloc(data string) GenesisAlloc { +func decodePrealloc(data string) types.GenesisAlloc { var p []struct{ Addr, Balance *big.Int } if err := rlp.NewStream(strings.NewReader(data), 0).Decode(&p); err != nil { panic(err) } - ga := make(GenesisAlloc, len(p)) + ga := make(types.GenesisAlloc, len(p)) for _, account := range p { - ga[common.BigToAddress(account.Addr)] = GenesisAccount{Balance: account.Balance} + ga[common.BigToAddress(account.Addr)] = types.Account{Balance: account.Balance} } return ga } -func DecodeAllocJson(s string) GenesisAlloc { - alloc := GenesisAlloc{} +func DecodeAllocJson(s string) types.GenesisAlloc { + alloc := types.GenesisAlloc{} json.Unmarshal([]byte(s), &alloc) return alloc } diff --git a/core/genesis_test.go b/core/genesis_test.go index ee8f42512ac68..67936f1eb6eba 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -21,11 +21,11 @@ import ( "reflect" "testing" + "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/consensus/ethash" "github.com/XinFinOrg/XDPoSChain/core/rawdb" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/core/vm" - - "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/ethdb" "github.com/XinFinOrg/XDPoSChain/params" "github.com/davecgh/go-spew/spew" @@ -47,7 +47,7 @@ func TestSetupGenesis(t *testing.T) { customghash = common.HexToHash("0xfc8a143549950b0d3e3e7b70b0067b152e6b903ab5438f1ea87f0448ec93da48") customg = Genesis{ Config: ¶ms.ChainConfig{HomesteadBlock: big.NewInt(3)}, - Alloc: GenesisAlloc{ + Alloc: types.GenesisAlloc{ {1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}}, }, } diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 39d6ce194ff68..71462096e051b 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -79,8 +79,8 @@ func TestStateProcessorErrors(t *testing.T) { db = rawdb.NewMemoryDatabase() gspec = &Genesis{ Config: config, - Alloc: GenesisAlloc{ - common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{ + Alloc: types.GenesisAlloc{ + common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): types.Account{ Balance: big.NewInt(1000000000000000000), // 1 ether Nonce: 0, }, @@ -213,8 +213,8 @@ func TestStateProcessorErrors(t *testing.T) { PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), }, - Alloc: GenesisAlloc{ - common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{ + Alloc: types.GenesisAlloc{ + common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): types.Account{ Balance: big.NewInt(1000000000000000000), // 1 ether Nonce: 0, }, diff --git a/core/types/account.go b/core/types/account.go new file mode 100644 index 0000000000000..3e15010aaf425 --- /dev/null +++ b/core/types/account.go @@ -0,0 +1,88 @@ +// Copyright 2024 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package types + +import ( + "bytes" + "encoding/hex" + "encoding/json" + "fmt" + "math/big" + + "github.com/XinFinOrg/XDPoSChain/common" + "github.com/XinFinOrg/XDPoSChain/common/hexutil" + "github.com/XinFinOrg/XDPoSChain/common/math" +) + +//go:generate go run github.com/fjl/gencodec -type Account -field-override accountMarshaling -out gen_account.go + +// Account represents an Ethereum account and its attached data. +// This type is used to specify accounts in the genesis block state, and +// is also useful for JSON encoding/decoding of accounts. +type Account struct { + Code []byte `json:"code,omitempty"` + Storage map[common.Hash]common.Hash `json:"storage,omitempty"` + Balance *big.Int `json:"balance" gencodec:"required"` + Nonce uint64 `json:"nonce,omitempty"` + + // used in tests + PrivateKey []byte `json:"secretKey,omitempty"` +} + +type accountMarshaling struct { + Code hexutil.Bytes + Balance *math.HexOrDecimal256 + Nonce math.HexOrDecimal64 + Storage map[storageJSON]storageJSON + PrivateKey hexutil.Bytes +} + +// storageJSON represents a 256 bit byte array, but allows less than 256 bits when +// unmarshaling from hex. +type storageJSON common.Hash + +func (h *storageJSON) UnmarshalText(text []byte) error { + text = bytes.TrimPrefix(text, []byte("0x")) + if len(text) > 64 { + return fmt.Errorf("too many hex characters in storage key/value %q", text) + } + offset := len(h) - len(text)/2 // pad on the left + if _, err := hex.Decode(h[offset:], text); err != nil { + fmt.Println(err) + return fmt.Errorf("invalid hex storage key/value %q", text) + } + return nil +} + +func (h storageJSON) MarshalText() ([]byte, error) { + return hexutil.Bytes(h[:]).MarshalText() +} + +// GenesisAlloc specifies the initial state that is part of the genesis block. +type GenesisAlloc map[common.Address]Account + +func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error { + m := make(map[common.UnprefixedAddress]Account) + if err := json.Unmarshal(data, &m); err != nil { + return err + } + *ga = make(GenesisAlloc) + for addr, a := range m { + (*ga)[common.Address(addr)] = a + } + return nil +} diff --git a/core/gen_genesis_account.go b/core/types/gen_account.go similarity index 61% rename from core/gen_genesis_account.go rename to core/types/gen_account.go index dd0a6f6719676..0fd48d2eb9081 100644 --- a/core/gen_genesis_account.go +++ b/core/types/gen_account.go @@ -1,6 +1,6 @@ // Code generated by github.com/fjl/gencodec. DO NOT EDIT. -package core +package types import ( "encoding/json" @@ -12,62 +12,62 @@ import ( "github.com/XinFinOrg/XDPoSChain/common/math" ) -var _ = (*genesisAccountMarshaling)(nil) +var _ = (*accountMarshaling)(nil) // MarshalJSON marshals as JSON. -func (g GenesisAccount) MarshalJSON() ([]byte, error) { - type GenesisAccount struct { +func (a Account) MarshalJSON() ([]byte, error) { + type Account struct { Code hexutil.Bytes `json:"code,omitempty"` Storage map[storageJSON]storageJSON `json:"storage,omitempty"` Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"` Nonce math.HexOrDecimal64 `json:"nonce,omitempty"` PrivateKey hexutil.Bytes `json:"secretKey,omitempty"` } - var enc GenesisAccount - enc.Code = g.Code - if g.Storage != nil { - enc.Storage = make(map[storageJSON]storageJSON, len(g.Storage)) - for k, v := range g.Storage { + var enc Account + enc.Code = a.Code + if a.Storage != nil { + enc.Storage = make(map[storageJSON]storageJSON, len(a.Storage)) + for k, v := range a.Storage { enc.Storage[storageJSON(k)] = storageJSON(v) } } - enc.Balance = (*math.HexOrDecimal256)(g.Balance) - enc.Nonce = math.HexOrDecimal64(g.Nonce) - enc.PrivateKey = g.PrivateKey + enc.Balance = (*math.HexOrDecimal256)(a.Balance) + enc.Nonce = math.HexOrDecimal64(a.Nonce) + enc.PrivateKey = a.PrivateKey return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. -func (g *GenesisAccount) UnmarshalJSON(input []byte) error { - type GenesisAccount struct { +func (a *Account) UnmarshalJSON(input []byte) error { + type Account struct { Code *hexutil.Bytes `json:"code,omitempty"` Storage map[storageJSON]storageJSON `json:"storage,omitempty"` Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"` Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"` PrivateKey *hexutil.Bytes `json:"secretKey,omitempty"` } - var dec GenesisAccount + var dec Account if err := json.Unmarshal(input, &dec); err != nil { return err } if dec.Code != nil { - g.Code = *dec.Code + a.Code = *dec.Code } if dec.Storage != nil { - g.Storage = make(map[common.Hash]common.Hash, len(dec.Storage)) + a.Storage = make(map[common.Hash]common.Hash, len(dec.Storage)) for k, v := range dec.Storage { - g.Storage[common.Hash(k)] = common.Hash(v) + a.Storage[common.Hash(k)] = common.Hash(v) } } if dec.Balance == nil { - return errors.New("missing required field 'balance' for GenesisAccount") + return errors.New("missing required field 'balance' for Account") } - g.Balance = (*big.Int)(dec.Balance) + a.Balance = (*big.Int)(dec.Balance) if dec.Nonce != nil { - g.Nonce = uint64(*dec.Nonce) + a.Nonce = uint64(*dec.Nonce) } if dec.PrivateKey != nil { - g.PrivateKey = *dec.PrivateKey + a.PrivateKey = *dec.PrivateKey } return nil } diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index de872ea989cc3..522efbb69bacd 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -670,7 +670,7 @@ func TestLightFilterLogs(t *testing.T) { key, _ = crypto.GenerateKey() addr = crypto.PubkeyToAddress(key.PublicKey) genesis = &core.Genesis{Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{ + Alloc: types.GenesisAlloc{ addr: {Balance: big.NewInt(params.Ether)}, }, } diff --git a/eth/gasprice/gasprice_test.go b/eth/gasprice/gasprice_test.go index abaca1190136c..e6ac77a076811 100644 --- a/eth/gasprice/gasprice_test.go +++ b/eth/gasprice/gasprice_test.go @@ -116,7 +116,7 @@ func newTestBackend(t *testing.T, eip1559Block *big.Int, pending bool) *testBack addr = crypto.PubkeyToAddress(key.PublicKey) gspec = &core.Genesis{ Config: &config, - Alloc: core.GenesisAlloc{addr: {Balance: big.NewInt(math.MaxInt64)}}, + Alloc: types.GenesisAlloc{addr: {Balance: big.NewInt(math.MaxInt64)}}, } signer = types.LatestSigner(gspec.Config) ) diff --git a/eth/helper_test.go b/eth/helper_test.go index 0b793d09bc5ac..c883e6f624529 100644 --- a/eth/helper_test.go +++ b/eth/helper_test.go @@ -58,7 +58,7 @@ func newTestProtocolManager(mode downloader.SyncMode, blocks int, generator func db = rawdb.NewMemoryDatabase() gspec = &core.Genesis{ Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{testBank: {Balance: big.NewInt(1000000)}}, + Alloc: types.GenesisAlloc{testBank: {Balance: big.NewInt(1000000)}}, } genesis = gspec.MustCommit(db) blockchain, _ = core.NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}) diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go index af01acda6741d..4eefd532b19a1 100644 --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -136,12 +136,12 @@ func TestZeroValueToNotExitCall(t *testing.T) { byte(vm.DUP1), byte(vm.PUSH1), 0xff, byte(vm.GAS), // value=0,address=0xff, gas=GAS byte(vm.CALL), } - var alloc = core.GenesisAlloc{ - to: core.GenesisAccount{ + var alloc = types.GenesisAlloc{ + to: types.Account{ Nonce: 1, Code: code, }, - origin: core.GenesisAccount{ + origin: types.Account{ Nonce: 0, Balance: big.NewInt(500000000000000), }, @@ -215,16 +215,16 @@ func TestPrestateTracerCreate2(t *testing.T) { Difficulty: big.NewInt(0x30000), GasLimit: uint64(6000000), } - alloc := core.GenesisAlloc{} + alloc := types.GenesisAlloc{} // The code pushes 'deadbeef' into memory, then the other params, and calls CREATE2, then returns // the address - alloc[common.HexToAddress("0x00000000000000000000000000000000deadbeef")] = core.GenesisAccount{ + alloc[common.HexToAddress("0x00000000000000000000000000000000deadbeef")] = types.Account{ Nonce: 1, Code: hexutil.MustDecode("0x63deadbeef60005263cafebabe6004601c6000F560005260206000F3"), Balance: big.NewInt(1), } - alloc[origin] = core.GenesisAccount{ + alloc[origin] = types.Account{ Nonce: 1, Code: []byte{}, Balance: big.NewInt(500000000000000), @@ -309,7 +309,7 @@ func BenchmarkTransactionTrace(b *testing.B) { GasLimit: gas, // BaseFee: big.NewInt(8), } - alloc := core.GenesisAlloc{} + alloc := types.GenesisAlloc{} // The code pushes 'deadbeef' into memory, then the other params, and calls CREATE2, then returns // the address loop := []byte{ @@ -317,12 +317,12 @@ func BenchmarkTransactionTrace(b *testing.B) { byte(vm.PUSH1), 0, // jumpdestination byte(vm.JUMP), } - alloc[common.HexToAddress("0x00000000000000000000000000000000deadbeef")] = core.GenesisAccount{ + alloc[common.HexToAddress("0x00000000000000000000000000000000deadbeef")] = types.Account{ Nonce: 1, Code: loop, Balance: big.NewInt(1), } - alloc[from] = core.GenesisAccount{ + alloc[from] = types.Account{ Nonce: 1, Code: []byte{}, Balance: big.NewInt(500000000000000), diff --git a/les/helper_test.go b/les/helper_test.go index 19e054626a0dd..2093a6fb1739c 100644 --- a/les/helper_test.go +++ b/les/helper_test.go @@ -142,7 +142,7 @@ func newTestProtocolManager(lightSync bool, blocks int, generator func(int, *cor engine = ethash.NewFaker() gspec = core.Genesis{ Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, + Alloc: types.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, } genesis = gspec.MustCommit(db) chain BlockChain diff --git a/light/odr_test.go b/light/odr_test.go index 80e42ac2eeb4c..649090b61b3e2 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -246,7 +246,7 @@ func testChainOdr(t *testing.T, protocol int, fn odrTestFn) { sdb = rawdb.NewMemoryDatabase() ldb = rawdb.NewMemoryDatabase() gspec = core.Genesis{ - Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, + Alloc: types.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, BaseFee: big.NewInt(params.InitialBaseFee), } genesis = gspec.MustCommit(sdb) diff --git a/light/trie_test.go b/light/trie_test.go index 1dda0cc73ee7f..bf4853e536c67 100644 --- a/light/trie_test.go +++ b/light/trie_test.go @@ -28,6 +28,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/rawdb" "github.com/XinFinOrg/XDPoSChain/core/state" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/core/vm" "github.com/XinFinOrg/XDPoSChain/params" "github.com/XinFinOrg/XDPoSChain/trie" @@ -39,7 +40,7 @@ func TestNodeIterator(t *testing.T) { fulldb = rawdb.NewMemoryDatabase() lightdb = rawdb.NewMemoryDatabase() gspec = core.Genesis{ - Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, + Alloc: types.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, BaseFee: big.NewInt(params.InitialBaseFee), } genesis = gspec.MustCommit(fulldb) diff --git a/light/txpool_test.go b/light/txpool_test.go index e52e8dff7370f..dc7ae41482091 100644 --- a/light/txpool_test.go +++ b/light/txpool_test.go @@ -85,7 +85,7 @@ func TestTxPool(t *testing.T) { sdb = rawdb.NewMemoryDatabase() ldb = rawdb.NewMemoryDatabase() gspec = core.Genesis{ - Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, + Alloc: types.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, BaseFee: big.NewInt(params.InitialBaseFee), } genesis = gspec.MustCommit(sdb) diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 44d1c1b4d72ff..7feed79ab844b 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -50,8 +50,8 @@ func (t *BlockTest) UnmarshalJSON(in []byte) error { type btJSON struct { Blocks []btBlock `json:"blocks"` Genesis btHeader `json:"genesisBlockHeader"` - Pre core.GenesisAlloc `json:"pre"` - Post core.GenesisAlloc `json:"postState"` + Pre types.GenesisAlloc `json:"pre"` + Post types.GenesisAlloc `json:"postState"` BestBlock common.UnprefixedHash `json:"lastblockhash"` Network string `json:"network"` } diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 74f5fc33c47a2..fd533f1fb88ad 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -57,7 +57,7 @@ func (t *StateTest) UnmarshalJSON(in []byte) error { type stJSON struct { Env stEnv `json:"env"` - Pre core.GenesisAlloc `json:"pre"` + Pre types.GenesisAlloc `json:"pre"` Tx stTransaction `json:"transaction"` Out hexutil.Bytes `json:"out"` Post map[string][]stPostState `json:"post"` @@ -185,7 +185,7 @@ func (t *StateTest) gasLimit(subtest StateSubtest) uint64 { return t.json.Tx.GasLimit[t.json.Post[subtest.Fork][subtest.Index].Indexes.Gas] } -func MakePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB { +func MakePreState(db ethdb.Database, accounts types.GenesisAlloc) *state.StateDB { sdb := state.NewDatabase(db) statedb, _ := state.New(common.Hash{}, sdb) for addr, a := range accounts { diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go index 0dfa4f634922d..21b0eda0d0084 100644 --- a/tests/vm_test_util.go +++ b/tests/vm_test_util.go @@ -29,6 +29,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/rawdb" "github.com/XinFinOrg/XDPoSChain/core/state" + "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/core/vm" "github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/params" @@ -50,8 +51,8 @@ type vmJSON struct { Logs common.UnprefixedHash `json:"logs"` GasRemaining *math.HexOrDecimal64 `json:"gas"` Out hexutil.Bytes `json:"out"` - Pre core.GenesisAlloc `json:"pre"` - Post core.GenesisAlloc `json:"post"` + Pre types.GenesisAlloc `json:"pre"` + Post types.GenesisAlloc `json:"post"` PostStateRoot common.Hash `json:"postStateRoot"` }