From cb87b43efde8b409f3b3736fb8e4ce61dd65809e Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Fri, 4 Sep 2020 13:31:01 -0600 Subject: [PATCH 01/83] all: implement EIP-2718 + EIP-2930 --- accounts/abi/bind/backends/simulated.go | 17 +- core/bench_test.go | 2 +- core/blockchain_test.go | 70 +++++ core/error.go | 4 + core/state_processor.go | 22 +- core/state_transition.go | 13 +- core/tx_pool.go | 7 +- core/types/access_list_tx.go | 124 ++++++++ core/types/block_test.go | 47 +++ core/types/gen_tx_json.go | 190 ++++++++---- core/types/legacy_tx.go | 101 +++++++ core/types/receipt.go | 29 +- core/types/receipt_test.go | 16 + core/types/transaction.go | 377 ++++++++++++------------ core/types/transaction_signing.go | 115 +++++++- core/types/transaction_test.go | 59 +++- interfaces.go | 13 +- internal/ethapi/api.go | 2 +- internal/guide/guide_test.go | 4 +- les/odr_test.go | 4 +- light/odr_test.go | 2 +- light/txpool.go | 4 +- miner/worker.go | 5 + params/protocol_params.go | 31 +- tests/state_test_util.go | 2 +- tests/transaction_test_util.go | 21 +- 26 files changed, 976 insertions(+), 305 deletions(-) create mode 100644 core/types/access_list_tx.go create mode 100644 core/types/legacy_tx.go diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 8be364d08fdd..0ebce994a98d 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -707,14 +707,15 @@ type callMsg struct { ethereum.CallMsg } -func (m callMsg) From() common.Address { return m.CallMsg.From } -func (m callMsg) Nonce() uint64 { return 0 } -func (m callMsg) CheckNonce() bool { return false } -func (m callMsg) To() *common.Address { return m.CallMsg.To } -func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } -func (m callMsg) Gas() uint64 { return m.CallMsg.Gas } -func (m callMsg) Value() *big.Int { return m.CallMsg.Value } -func (m callMsg) Data() []byte { return m.CallMsg.Data } +func (m callMsg) From() common.Address { return m.CallMsg.From } +func (m callMsg) Nonce() uint64 { return 0 } +func (m callMsg) CheckNonce() bool { return false } +func (m callMsg) To() *common.Address { return m.CallMsg.To } +func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } +func (m callMsg) Gas() uint64 { return m.CallMsg.Gas } +func (m callMsg) Value() *big.Int { return m.CallMsg.Value } +func (m callMsg) Data() []byte { return m.CallMsg.Data } +func (m callMsg) AccessList() *types.AccessList { return m.CallMsg.AccessList } // filterBackend implements filters.Backend to support filtering for logs without // taking bloom-bits acceleration structures into account. diff --git a/core/bench_test.go b/core/bench_test.go index 0f4cabd83752..0347bc44318c 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -85,7 +85,7 @@ func genValueTx(nbytes int) func(int, *BlockGen) { return func(i int, gen *BlockGen) { toaddr := common.Address{} data := make([]byte, nbytes) - gas, _ := IntrinsicGas(data, false, false, false) + gas, _ := IntrinsicGas(data, nil, false, false, false, false) tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(benchRootAddr), toaddr, big.NewInt(1), gas, nil, data), types.HomesteadSigner{}, benchRootKey) gen.AddTx(tx) } diff --git a/core/blockchain_test.go b/core/blockchain_test.go index c33e7321ecd5..92899540167d 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -3030,3 +3030,73 @@ func TestInitThenFailCreateContract(t *testing.T) { } } } + +func TestEIP2718Transition(t *testing.T) { + var ( + aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") + + // Generate a canonical chain to act as the main dataset + engine = ethash.NewFaker() + db = rawdb.NewMemoryDatabase() + + // A sender who makes transactions, has some funds + key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address = crypto.PubkeyToAddress(key.PublicKey) + funds = big.NewInt(1000000000) + gspec = &Genesis{ + Config: params.YoloV2ChainConfig, + Alloc: GenesisAlloc{ + address: {Balance: funds}, + // The address 0xAAAA sloads 0x00 and 0x01 + aa: { + Code: []byte{ + byte(vm.PC), + byte(vm.PC), + byte(vm.SLOAD), + byte(vm.SLOAD), + }, + Nonce: 0, + Balance: big.NewInt(0), + }, + }, + } + genesis = gspec.MustCommit(db) + ) + + blocks, _ := GenerateChain(gspec.Config, genesis, engine, db, 1, func(i int, b *BlockGen) { + b.SetCoinbase(common.Address{1}) + + // One transaction to 0xAAAA + accesses := types.AccessList{types.AccessTuple{ + Address: &aa, + StorageKeys: []*common.Hash{ + {0}, + }, + }} + + tx := types.NewAccessListTransaction(gspec.Config.ChainID, 0, aa, big.NewInt(0), 30000, big.NewInt(1), nil, &accesses) + tx, _ = types.SignTx(tx, types.NewEIP2718Signer(gspec.Config.ChainID), key) + + b.AddTx(tx) + }) + // Import the canonical chain + diskdb := rawdb.NewMemoryDatabase() + gspec.MustCommit(diskdb) + + chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) + if err != nil { + t.Fatalf("failed to create tester chain: %v", err) + } + if n, err := chain.InsertChain(blocks); err != nil { + t.Fatalf("block %d: failed to insert into chain: %v", n, err) + } + + block := chain.GetBlockByNumber(1) + + // Expected gas is intrinsic + 2 * pc + hot load + cold load, since only one load is in the access list + expected := params.TxGas + params.TxAccessListAddressGas + params.TxAccessListStorageKeyGas + vm.GasQuickStep*2 + vm.WarmStorageReadCostEIP2929 + vm.ColdSloadCostEIP2929 + if block.GasUsed() != expected { + t.Fatalf("incorrect amount of gas spent: expected %d, got %d", expected, block.GasUsed()) + + } +} diff --git a/core/error.go b/core/error.go index 5a28be7e1c92..b7ed5bc6ecfc 100644 --- a/core/error.go +++ b/core/error.go @@ -63,4 +63,8 @@ var ( // ErrIntrinsicGas is returned if the transaction is specified to use less gas // than required to start the invocation. ErrIntrinsicGas = errors.New("intrinsic gas too low") + + // ErrTxTypeNotSupported is returned if a transaction is not supported in the + // current network configuration. + ErrTxTypeNotSupported = errors.New("tx type not supported") ) diff --git a/core/state_processor.go b/core/state_processor.go index c5b0bb160977..099b079c9a78 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -89,7 +89,14 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg return receipts, allLogs, *usedGas, nil } +// ApplyTransaction attempts to apply a transaction to the given state database +// and uses the input parameters for its environment. It returns the receipt +// for the transaction, gas used and an error if the transaction failed, +// indicating the block was invalid. func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { + if !config.IsYoloV2(header.Number) && tx.Type() != types.LegacyTxId { + return nil, ErrTxTypeNotSupported + } // Create a new context to be used in the EVM environment txContext := NewEVMTxContext(msg) // Add addresses to access list if applicable @@ -102,6 +109,14 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon for _, addr := range evm.ActivePrecompiles() { statedb.AddAddressToAccessList(addr) } + if al := msg.AccessList(); al != nil { + for _, el := range *al { + statedb.AddAddressToAccessList(*el.Address) + for _, key := range el.StorageKeys { + statedb.AddSlotToAccessList(*el.Address, *key) + } + } + } } // Update the evm with the new transaction context. @@ -122,7 +137,12 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon // Create a new receipt for the transaction, storing the intermediate root and gas used by the tx // based on the eip phase, we're passing whether the root touch-delete accounts. - receipt := types.NewReceipt(root, result.Failed(), *usedGas) + var receipt *types.Receipt + if config.IsYoloV2(header.Number) { + receipt = types.NewEIP2718Receipt(tx.Type(), root, result.Failed(), *usedGas) + } else { + receipt = types.NewReceipt(root, result.Failed(), *usedGas) + } receipt.TxHash = tx.Hash() receipt.GasUsed = result.UsedGas // if the transaction created a contract, store the creation address in the receipt. diff --git a/core/state_transition.go b/core/state_transition.go index a8d1936c1f76..83e7f2c6362c 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -22,6 +22,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" ) @@ -67,6 +68,7 @@ type Message interface { Nonce() uint64 CheckNonce() bool Data() []byte + AccessList() *types.AccessList } // ExecutionResult includes all output after executing given evm @@ -105,10 +107,10 @@ func (result *ExecutionResult) Revert() []byte { } // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. -func IntrinsicGas(data []byte, contractCreation, isHomestead bool, isEIP2028 bool) (uint64, error) { +func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP2718 bool) (uint64, error) { // Set the starting gas for the raw transaction var gas uint64 - if contractCreation && isHomestead { + if isContractCreation && isHomestead { gas = params.TxGasContractCreation } else { gas = params.TxGas @@ -138,6 +140,10 @@ func IntrinsicGas(data []byte, contractCreation, isHomestead bool, isEIP2028 boo } gas += z * params.TxDataZeroGas } + if isEIP2718 && accessList != nil { + gas += uint64(accessList.Addresses()) * params.TxAccessListAddressGas + gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas + } return gas, nil } @@ -235,10 +241,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { sender := vm.AccountRef(msg.From()) homestead := st.evm.ChainConfig().IsHomestead(st.evm.Context.BlockNumber) istanbul := st.evm.ChainConfig().IsIstanbul(st.evm.Context.BlockNumber) + yoloV2 := st.evm.ChainConfig().IsYoloV2(st.evm.Context.BlockNumber) contractCreation := msg.To() == nil // Check clauses 4-5, subtract intrinsic gas if everything is correct - gas, err := IntrinsicGas(st.data, contractCreation, homestead, istanbul) + gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, homestead, istanbul, yoloV2) if err != nil { return nil, err } diff --git a/core/tx_pool.go b/core/tx_pool.go index 36546cde7549..02c786fda25a 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -229,6 +229,7 @@ type TxPool struct { mu sync.RWMutex istanbul bool // Fork indicator whether we are in the istanbul stage. + yoloV2 bool // Fork indicator whether we are in the YoloV2 stage. currentState *state.StateDB // Current state in the blockchain head pendingNonces *txNoncer // Pending state tracking virtual nonces @@ -281,6 +282,9 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block reorgShutdownCh: make(chan struct{}), gasPrice: new(big.Int).SetUint64(config.PriceLimit), } + if chainconfig.IsYoloV2(chain.CurrentBlock().Number()) { + pool.signer = types.NewEIP2718Signer(chainconfig.ChainID) + } pool.locals = newAccountSet(pool.signer) for _, addr := range config.Locals { log.Info("Setting new local account", "address", addr) @@ -554,7 +558,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrInsufficientFunds } // Ensure the transaction has more gas than the basic tx fee. - intrGas, err := IntrinsicGas(tx.Data(), tx.To() == nil, true, pool.istanbul) + intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.yoloV2) if err != nil { return err } @@ -1199,6 +1203,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) { // Update all fork indicator by next pending block number. next := new(big.Int).Add(newHead.Number, big.NewInt(1)) pool.istanbul = pool.chainconfig.IsIstanbul(next) + pool.yoloV2 = pool.chainconfig.IsYoloV2(next) } // promoteExecutables moves transactions that have become processable from the diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go new file mode 100644 index 000000000000..fa547d3e6a97 --- /dev/null +++ b/core/types/access_list_tx.go @@ -0,0 +1,124 @@ +// Copyright 2020 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 ( + "math/big" + "time" + + "github.com/ethereum/go-ethereum/common" +) + +type AccessTuple struct { + Address *common.Address `json:"address" gencodec:"required"` + StorageKeys []*common.Hash `json:"storageKeys" gencodec:"required"` +} + +type AccessList []AccessTuple + +func (al *AccessList) Addresses() int { return len(*al) } +func (al *AccessList) StorageKeys() int { + sum := 0 + for _, tuple := range *al { + sum += len(tuple.StorageKeys) + } + return sum +} + +type AccessListTransaction struct { + Chain *big.Int `json:"chainId" gencodec:"required"` + AccountNonce uint64 `json:"nonce" gencodec:"required"` + Price *big.Int `json:"gasPrice" gencodec:"required"` + GasLimit uint64 `json:"gas" gencodec:"required"` + Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation + Amount *big.Int `json:"value" gencodec:"required"` + Payload []byte `json:"input" gencodec:"required"` + Accesses *AccessList `json:"accessList" gencodec:"required"` + + // Signature values + V *big.Int `json:"v" gencodec:"required"` + R *big.Int `json:"r" gencodec:"required"` + S *big.Int `json:"s" gencodec:"required"` +} + +func NewAccessListTransaction(chainId *big.Int, nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { + return newAccessListTransaction(chainId, nonce, &to, amount, gasLimit, gasPrice, data, accesses) +} + +func NewAccessListContractCreation(chainId *big.Int, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { + return newAccessListTransaction(chainId, nonce, nil, amount, gasLimit, gasPrice, data, accesses) +} + +func newAccessListTransaction(chainId *big.Int, nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { + if len(data) > 0 { + data = common.CopyBytes(data) + } + i := AccessListTransaction{ + Chain: new(big.Int), + AccountNonce: nonce, + Recipient: to, + Payload: data, + Accesses: accesses, + Amount: new(big.Int), + GasLimit: gasLimit, + Price: new(big.Int), + V: new(big.Int), + R: new(big.Int), + S: new(big.Int), + } + if chainId != nil { + i.Chain.Set(chainId) + } + if amount != nil { + i.Amount.Set(amount) + } + if gasPrice != nil { + i.Price.Set(gasPrice) + } + return &Transaction{ + typ: AccessListTxId, + inner: &i, + time: time.Now(), + } +} + +func (tx *AccessListTransaction) ChainId() *big.Int { return tx.Chain } +func (tx *AccessListTransaction) Protected() bool { return true } +func (tx *AccessListTransaction) AccessList() *AccessList { return tx.Accesses } +func (tx *AccessListTransaction) Data() []byte { return common.CopyBytes(tx.Payload) } +func (tx *AccessListTransaction) Gas() uint64 { return tx.GasLimit } +func (tx *AccessListTransaction) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } +func (tx *AccessListTransaction) Value() *big.Int { return new(big.Int).Set(tx.Amount) } +func (tx *AccessListTransaction) Nonce() uint64 { return tx.AccountNonce } +func (tx *AccessListTransaction) CheckNonce() bool { return true } +func (tx *AccessListTransaction) Hash() common.Hash { return rlpHash(tx) } + +// To returns the recipient address of the transaction. +// It returns nil if the transaction is a contract creation. +func (tx *AccessListTransaction) To() *common.Address { + if tx.Recipient == nil { + return nil + } + to := *tx.Recipient + return &to +} + +// RawSignatureValues returns the V, R, S signature values of the transaction. +// The return values should not be modified by the caller. +func (tx *AccessListTransaction) RawSignatureValues() (v, r, s *big.Int) { + return tx.V, tx.R, tx.S +} diff --git a/core/types/block_test.go b/core/types/block_test.go index 4dfdcf95457f..4f7fb6519335 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -59,6 +59,53 @@ func TestBlockEncoding(t *testing.T) { tx1, _ = tx1.WithSignature(HomesteadSigner{}, common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100")) check("len(Transactions)", len(block.Transactions()), 1) check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash()) + ourBlockEnc, err := rlp.EncodeToBytes(&block) + if err != nil { + t.Fatal("encode error: ", err) + } + if !bytes.Equal(ourBlockEnc, blockEnc) { + t.Errorf("encoded block mismatch:\ngot: %x\nwant: %x", ourBlockEnc, blockEnc) + } +} + +func TestEIP2718BlockEncoding(t *testing.T) { + blockEnc := common.FromHex("f90316f90211a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a08dae65c92dceddaa2fabec652b550258568abed0de8ae7482e662afa5cd6bef7a0cafe75574d59780665a97fbfd11365c7545aa8f1abf4e5e12e8243334ef7286bb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000820200832fefd882a410845506eb0796636f6f6c65737420626c6f636b206f6e20636861696ea0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4f8fff85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b101f89b01800a8301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000001a078b8236a3b26d56c7d4ba94a36e64c5ea086619e489c005ece0ac7bd8356be22a02fea9f3d5aaff74ac1e996e590f7152ea74ed300c59909b2921b73237c7b0692c0") + var block Block + if err := rlp.DecodeBytes(blockEnc, &block); err != nil { + t.Fatal("decode error: ", err) + } + + check := func(f string, got, want interface{}) { + if !reflect.DeepEqual(got, want) { + t.Errorf("%s mismatch: got %v, want %v", f, got, want) + } + } + check("Difficulty", block.Difficulty(), big.NewInt(131072)) + check("GasLimit", block.GasLimit(), uint64(3141592)) + check("GasUsed", block.GasUsed(), uint64(42000)) + check("Coinbase", block.Coinbase(), common.HexToAddress("8888f1f195afa192cfee860698584c030f4c9db1")) + check("MixDigest", block.MixDigest(), common.HexToHash("bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff498")) + check("Root", block.Root(), common.HexToHash("ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017")) + check("Nonce", block.Nonce(), uint64(0xa13a5a8c8f2bb1c4)) + check("Time", block.Time(), uint64(1426516743)) + check("Size", block.Size(), common.StorageSize(len(blockEnc))) + + tx1 := NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(10), 50000, big.NewInt(10), nil) + tx1, _ = tx1.WithSignature(HomesteadSigner{}, common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100")) + addr := common.HexToAddress("0x0000000000000000000000000000000000000001") + accesses := AccessList{AccessTuple{ + Address: &addr, + StorageKeys: []*common.Hash{ + {0}, + }, + }} + tx2 := NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) + tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), common.Hex2Bytes("78b8236a3b26d56c7d4ba94a36e64c5ea086619e489c005ece0ac7bd8356be222fea9f3d5aaff74ac1e996e590f7152ea74ed300c59909b2921b73237c7b069201")) + + check("len(Transactions)", len(block.Transactions()), 2) + check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash()) + check("Transactions[1].Hash", block.Transactions()[1].Hash(), tx2.Hash()) + check("Transactions[1].Type()", block.Transactions()[1].Type(), uint8(AccessListTxId)) ourBlockEnc, err := rlp.EncodeToBytes(&block) if err != nil { diff --git a/core/types/gen_tx_json.go b/core/types/gen_tx_json.go index e676058ecc4b..da9531ffd5ca 100644 --- a/core/types/gen_tx_json.go +++ b/core/types/gen_tx_json.go @@ -11,91 +11,181 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) -var _ = (*txdataMarshaling)(nil) - -// MarshalJSON marshals as JSON. -func (t txdata) MarshalJSON() ([]byte, error) { +// MarshalJSONWithHash marshals as JSON with a hash. +func (t *Transaction) MarshalJSON() ([]byte, error) { type txdata struct { + Type hexutil.Uint64 `json:"type" rlp:"-"` + Chain *hexutil.Big `json:"chainId" rlp:"-"` AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"` Price *hexutil.Big `json:"gasPrice" gencodec:"required"` GasLimit hexutil.Uint64 `json:"gas" gencodec:"required"` Recipient *common.Address `json:"to" rlp:"nil"` Amount *hexutil.Big `json:"value" gencodec:"required"` Payload hexutil.Bytes `json:"input" gencodec:"required"` + AccessList *AccessList `json:"accessList" rlp:"-"` V *hexutil.Big `json:"v" gencodec:"required"` R *hexutil.Big `json:"r" gencodec:"required"` S *hexutil.Big `json:"s" gencodec:"required"` Hash *common.Hash `json:"hash" rlp:"-"` } var enc txdata - enc.AccountNonce = hexutil.Uint64(t.AccountNonce) - enc.Price = (*hexutil.Big)(t.Price) - enc.GasLimit = hexutil.Uint64(t.GasLimit) - enc.Recipient = t.Recipient - enc.Amount = (*hexutil.Big)(t.Amount) - enc.Payload = t.Payload - enc.V = (*hexutil.Big)(t.V) - enc.R = (*hexutil.Big)(t.R) - enc.S = (*hexutil.Big)(t.S) - enc.Hash = t.Hash + enc.AccountNonce = hexutil.Uint64(t.Nonce()) + enc.Price = (*hexutil.Big)(t.GasPrice()) + enc.GasLimit = hexutil.Uint64(t.Gas()) + enc.Recipient = t.To() + enc.Amount = (*hexutil.Big)(t.Value()) + enc.Payload = t.Data() + v, r, s := t.RawSignatureValues() + enc.V = (*hexutil.Big)(v) + enc.R = (*hexutil.Big)(r) + enc.S = (*hexutil.Big)(s) + hash := t.Hash() + enc.Hash = &hash + if t.Type() == AccessListTxId { + enc.Type = hexutil.Uint64(t.Type()) + enc.Chain = (*hexutil.Big)(t.ChainId()) + enc.AccessList = t.AccessList() + } return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. -func (t *txdata) UnmarshalJSON(input []byte) error { +func (t *Transaction) UnmarshalJSON(input []byte) error { + type typ struct { + Type *hexutil.Uint64 `json:"type" rlp:"-"` + } type txdata struct { + Chain *hexutil.Big `json:"chainId" rlp:"-"` AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"` Price *hexutil.Big `json:"gasPrice" gencodec:"required"` GasLimit *hexutil.Uint64 `json:"gas" gencodec:"required"` Recipient *common.Address `json:"to" rlp:"nil"` Amount *hexutil.Big `json:"value" gencodec:"required"` Payload *hexutil.Bytes `json:"input" gencodec:"required"` + AccessList *AccessList `json:"accessList" rlp:"-"` V *hexutil.Big `json:"v" gencodec:"required"` R *hexutil.Big `json:"r" gencodec:"required"` S *hexutil.Big `json:"s" gencodec:"required"` Hash *common.Hash `json:"hash" rlp:"-"` } - var dec txdata + var ( + decType typ + dec txdata + ) + + if err := json.Unmarshal(input, &decType); err != nil { + return err + } if err := json.Unmarshal(input, &dec); err != nil { return err } if dec.AccountNonce == nil { return errors.New("missing required field 'nonce' for txdata") } - t.AccountNonce = uint64(*dec.AccountNonce) - if dec.Price == nil { - return errors.New("missing required field 'gasPrice' for txdata") - } - t.Price = (*big.Int)(dec.Price) - if dec.GasLimit == nil { - return errors.New("missing required field 'gas' for txdata") - } - t.GasLimit = uint64(*dec.GasLimit) - if dec.Recipient != nil { - t.Recipient = dec.Recipient - } - if dec.Amount == nil { - return errors.New("missing required field 'value' for txdata") - } - t.Amount = (*big.Int)(dec.Amount) - if dec.Payload == nil { - return errors.New("missing required field 'input' for txdata") - } - t.Payload = *dec.Payload - if dec.V == nil { - return errors.New("missing required field 'v' for txdata") - } - t.V = (*big.Int)(dec.V) - if dec.R == nil { - return errors.New("missing required field 'r' for txdata") - } - t.R = (*big.Int)(dec.R) - if dec.S == nil { - return errors.New("missing required field 's' for txdata") - } - t.S = (*big.Int)(dec.S) - if dec.Hash != nil { - t.Hash = dec.Hash + + if decType.Type == nil || *decType.Type == hexutil.Uint64(LegacyTxId) { + var i LegacyTransaction + if dec.AccountNonce == nil { + return errors.New("missing required field 'nonce' for txdata") + } + i.AccountNonce = uint64(*dec.AccountNonce) + if dec.Price == nil { + return errors.New("missing required field 'gasPrice' for txdata") + } + i.Price = (*big.Int)(dec.Price) + if dec.GasLimit == nil { + return errors.New("missing required field 'gas' for txdata") + } + i.GasLimit = uint64(*dec.GasLimit) + if dec.Recipient != nil { + i.Recipient = dec.Recipient + } + if dec.Amount == nil { + return errors.New("missing required field 'value' for txdata") + } + i.Amount = (*big.Int)(dec.Amount) + if dec.Payload == nil { + return errors.New("missing required field 'input' for txdata") + } + i.Payload = *dec.Payload + if dec.V == nil { + return errors.New("missing required field 'v' for txdata") + } + i.V = (*big.Int)(dec.V) + if dec.R == nil { + return errors.New("missing required field 'r' for txdata") + } + i.R = (*big.Int)(dec.R) + if dec.S == nil { + return errors.New("missing required field 's' for txdata") + } + i.S = (*big.Int)(dec.S) + if dec.Hash != nil { + t.hash.Store(*dec.Hash) + } + withSignature := i.V.Sign() != 0 || i.R.Sign() != 0 || i.S.Sign() != 0 + if withSignature { + if err := sanityCheckSignature(i.V, i.R, i.S, true); err != nil { + return err + } + } + t.inner = &i + } else if *decType.Type == hexutil.Uint64(AccessListTxId) { + var i AccessListTransaction + if dec.Chain == nil { + return errors.New("missing required field 'chainId' for txdata") + } + i.Chain = (*big.Int)(dec.Chain) + if dec.AccountNonce == nil { + return errors.New("missing required field 'nonce' for txdata") + } + i.AccountNonce = uint64(*dec.AccountNonce) + if dec.Price == nil { + return errors.New("missing required field 'gasPrice' for txdata") + } + i.Price = (*big.Int)(dec.Price) + if dec.GasLimit == nil { + return errors.New("missing required field 'gas' for txdata") + } + i.GasLimit = uint64(*dec.GasLimit) + if dec.Recipient != nil { + i.Recipient = dec.Recipient + } + if dec.Amount == nil { + return errors.New("missing required field 'value' for txdata") + } + i.Amount = (*big.Int)(dec.Amount) + if dec.Payload == nil { + return errors.New("missing required field 'input' for txdata") + } + i.Payload = *dec.Payload + if dec.AccessList == nil { + return errors.New("missing required field 'accessList' for txdata") + } + i.Accesses = dec.AccessList + if dec.V == nil { + return errors.New("missing required field 'v' for txdata") + } + i.V = (*big.Int)(dec.V) + if dec.R == nil { + return errors.New("missing required field 'r' for txdata") + } + i.R = (*big.Int)(dec.R) + if dec.S == nil { + return errors.New("missing required field 's' for txdata") + } + i.S = (*big.Int)(dec.S) + if dec.Hash != nil { + t.hash.Store(*dec.Hash) + } + withSignature := i.V.Sign() != 0 || i.R.Sign() != 0 || i.S.Sign() != 0 + if withSignature { + if err := sanityCheckSignature(i.V, i.R, i.S, false); err != nil { + return err + } + } + t.inner = &i } + return nil } diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go new file mode 100644 index 000000000000..9ac39158a47b --- /dev/null +++ b/core/types/legacy_tx.go @@ -0,0 +1,101 @@ +// Copyright 2020 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 ( + "math/big" + "time" + + "github.com/ethereum/go-ethereum/common" +) + +type LegacyTransaction struct { + AccountNonce uint64 `json:"nonce" gencodec:"required"` + Price *big.Int `json:"gasPrice" gencodec:"required"` + GasLimit uint64 `json:"gas" gencodec:"required"` + Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation + Amount *big.Int `json:"value" gencodec:"required"` + Payload []byte `json:"input" gencodec:"required"` + + // Signature values + V *big.Int `json:"v" gencodec:"required"` + R *big.Int `json:"r" gencodec:"required"` + S *big.Int `json:"s" gencodec:"required"` +} + +func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { + return newLegacyTransaction(nonce, &to, amount, gasLimit, gasPrice, data) +} + +func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { + return newLegacyTransaction(nonce, nil, amount, gasLimit, gasPrice, data) +} + +func newLegacyTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { + if len(data) > 0 { + data = common.CopyBytes(data) + } + i := LegacyTransaction{ + AccountNonce: nonce, + Recipient: to, + Payload: data, + Amount: new(big.Int), + GasLimit: gasLimit, + Price: new(big.Int), + V: new(big.Int), + R: new(big.Int), + S: new(big.Int), + } + if amount != nil { + i.Amount.Set(amount) + } + if gasPrice != nil { + i.Price.Set(gasPrice) + } + return &Transaction{ + typ: LegacyTxId, + inner: &i, + time: time.Now(), + } +} + +func (tx *LegacyTransaction) ChainId() *big.Int { return deriveChainId(tx.V) } +func (tx *LegacyTransaction) Protected() bool { return isProtectedV(tx.V) } +func (tx *LegacyTransaction) AccessList() *AccessList { return nil } +func (tx *LegacyTransaction) Data() []byte { return common.CopyBytes(tx.Payload) } +func (tx *LegacyTransaction) Gas() uint64 { return tx.GasLimit } +func (tx *LegacyTransaction) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } +func (tx *LegacyTransaction) Value() *big.Int { return new(big.Int).Set(tx.Amount) } +func (tx *LegacyTransaction) Nonce() uint64 { return tx.AccountNonce } +func (tx *LegacyTransaction) CheckNonce() bool { return true } +func (tx *LegacyTransaction) Hash() common.Hash { return rlpHash(tx) } + +// To returns the recipient address of the transaction. +// It returns nil if the transaction is a contract creation. +func (tx *LegacyTransaction) To() *common.Address { + if tx.Recipient == nil { + return nil + } + to := *tx.Recipient + return &to +} + +// RawSignatureValues returns the V, R, S signature values of the transaction. +// The return values should not be modified by the caller. +func (tx *LegacyTransaction) RawSignatureValues() (v, r, s *big.Int) { + return tx.V, tx.R, tx.S +} diff --git a/core/types/receipt.go b/core/types/receipt.go index a96c7525ef3b..5068a753732d 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -49,6 +49,7 @@ const ( // Receipt represents the results of a transaction. type Receipt struct { // Consensus fields: These fields are defined by the Yellow Paper + Type uint8 `json:"type,omitempty"` PostState []byte `json:"root"` Status uint64 `json:"status"` CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"` @@ -115,7 +116,12 @@ type v3StoredReceiptRLP struct { // NewReceipt creates a barebone transaction receipt, copying the init fields. func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt { - r := &Receipt{PostState: common.CopyBytes(root), CumulativeGasUsed: cumulativeGasUsed} + return NewEIP2718Receipt(LegacyTxId, root, failed, cumulativeGasUsed) +} + +// NewEIP2718Receipt creates a barebone transaction receipt for typed transactions, copying the init fields. +func NewEIP2718Receipt(typ uint8, root []byte, failed bool, cumulativeGasUsed uint64) *Receipt { + r := &Receipt{Type: typ, PostState: common.CopyBytes(root), CumulativeGasUsed: cumulativeGasUsed} if failed { r.Status = ReceiptStatusFailed } else { @@ -127,12 +133,28 @@ func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt { // EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt // into an RLP stream. If no post state is present, byzantium fork is assumed. func (r *Receipt) EncodeRLP(w io.Writer) error { + if r.Type != LegacyTxId { + if _, err := w.Write([]byte{r.Type}); err != nil { + return err + } + } return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs}) } // DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt // from an RLP stream. func (r *Receipt) DecodeRLP(s *rlp.Stream) error { + typ := uint64(LegacyTxId) + k, _, err := s.Kind() + if err != nil { + return err + } + // If the receipt isn't a list, it's likely typed - so pop off the first byte. + if k != rlp.List { + if typ, err = s.Uint(); err != nil { + return err + } + } var dec receiptRLP if err := s.Decode(&dec); err != nil { return err @@ -140,7 +162,7 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error { if err := r.setStatus(dec.PostStateOrStatus); err != nil { return err } - r.CumulativeGasUsed, r.Bloom, r.Logs = dec.CumulativeGasUsed, dec.Bloom, dec.Logs + r.Type, r.CumulativeGasUsed, r.Bloom, r.Logs = uint8(typ), dec.CumulativeGasUsed, dec.Bloom, dec.Logs return nil } @@ -302,7 +324,8 @@ func (r Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, num return errors.New("transaction and receipt count mismatch") } for i := 0; i < len(r); i++ { - // The transaction hash can be retrieved from the transaction itself + // The transaction type and hash can be retrieved from the transaction itself + r[i].Type = txs[i].Type() r[i].TxHash = txs[i].Hash() // block location fields diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index 806b3dd2ab88..e4d407fe24a7 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -157,6 +157,7 @@ func TestDeriveFields(t *testing.T) { txs := Transactions{ NewContractCreation(1, big.NewInt(1), 1, big.NewInt(1), nil), NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil), + NewAccessListTransaction(big.NewInt(3), 3, common.HexToAddress("0x3"), big.NewInt(3), 3, big.NewInt(3), nil, nil), } // Create the corresponding receipts receipts := Receipts{ @@ -182,6 +183,18 @@ func TestDeriveFields(t *testing.T) { ContractAddress: common.BytesToAddress([]byte{0x02, 0x22, 0x22}), GasUsed: 2, }, + &Receipt{ + Type: AccessListTxId, + PostState: common.Hash{3}.Bytes(), + CumulativeGasUsed: 6, + Logs: []*Log{ + {Address: common.BytesToAddress([]byte{0x33})}, + {Address: common.BytesToAddress([]byte{0x03, 0x33})}, + }, + TxHash: txs[2].Hash(), + ContractAddress: common.BytesToAddress([]byte{0x03, 0x33, 0x33}), + GasUsed: 3, + }, } // Clear all the computed fields and re-derive them number := big.NewInt(1) @@ -196,6 +209,9 @@ func TestDeriveFields(t *testing.T) { logIndex := uint(0) for i := range receipts { + if receipts[i].Type != txs[i].Type() { + t.Errorf("receipts[%d].Type = %d, want %d", i, receipts[i].Type, txs[i].Type()) + } if receipts[i].TxHash != txs[i].Hash() { t.Errorf("receipts[%d].TxHash = %s, want %s", i, receipts[i].TxHash.String(), txs[i].Hash().String()) } diff --git a/core/types/transaction.go b/core/types/transaction.go index 177bfbb70b55..2ff872358a59 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -25,20 +25,26 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" ) -//go:generate gencodec -type txdata -field-override txdataMarshaling -out gen_tx_json.go - var ( - ErrInvalidSig = errors.New("invalid transaction v, r, s values") + ErrInvalidSig = errors.New("invalid transaction v, r, s values") + ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures") + ErrInvalidTxType = errors.New("transaction type not valid in this context") + ErrTxTypeNotSupported = errors.New("transaction type not supported") +) + +const ( + LegacyTxId = iota + AccessListTxId ) type Transaction struct { - data txdata // Consensus contents of a transaction - time time.Time // Time first seen locally (spam avoidance) + typ uint8 // EIP-2718 transaction type identifier + inner inner // Consensus contents of a transaction + time time.Time // Time first seen locally (spam avoidance) // caches hash atomic.Value @@ -46,83 +52,36 @@ type Transaction struct { from atomic.Value } -type txdata struct { - AccountNonce uint64 `json:"nonce" gencodec:"required"` - Price *big.Int `json:"gasPrice" gencodec:"required"` - GasLimit uint64 `json:"gas" gencodec:"required"` - Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation - Amount *big.Int `json:"value" gencodec:"required"` - Payload []byte `json:"input" gencodec:"required"` - - // Signature values - V *big.Int `json:"v" gencodec:"required"` - R *big.Int `json:"r" gencodec:"required"` - S *big.Int `json:"s" gencodec:"required"` - - // This is only used when marshaling to JSON. - Hash *common.Hash `json:"hash" rlp:"-"` -} - -type txdataMarshaling struct { - AccountNonce hexutil.Uint64 - Price *hexutil.Big - GasLimit hexutil.Uint64 - Amount *hexutil.Big - Payload hexutil.Bytes - V *hexutil.Big - R *hexutil.Big - S *hexutil.Big -} - -func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - return newTransaction(nonce, &to, amount, gasLimit, gasPrice, data) -} - -func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - return newTransaction(nonce, nil, amount, gasLimit, gasPrice, data) -} - -func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - if len(data) > 0 { - data = common.CopyBytes(data) - } - d := txdata{ - AccountNonce: nonce, - Recipient: to, - Payload: data, - Amount: new(big.Int), - GasLimit: gasLimit, - Price: new(big.Int), - V: new(big.Int), - R: new(big.Int), - S: new(big.Int), - } - if amount != nil { - d.Amount.Set(amount) - } - if gasPrice != nil { - d.Price.Set(gasPrice) - } - return &Transaction{ - data: d, - time: time.Now(), - } -} - -// ChainId returns which chain id this transaction was signed for (if at all) -func (tx *Transaction) ChainId() *big.Int { - return deriveChainId(tx.data.V) -} - -// Protected returns whether the transaction is protected from replay protection. -func (tx *Transaction) Protected() bool { - return isProtectedV(tx.data.V) -} +type inner interface { + // ChainId returns which chain id this transaction was signed for (if at all) + ChainId() *big.Int + // Protected returns whether the transaction is protected from replay protection. + Protected() bool + // AccessList returns the transactions optional EIP-2930 access list. + AccessList() *AccessList + Data() []byte + Gas() uint64 + GasPrice() *big.Int + Value() *big.Int + Nonce() uint64 + CheckNonce() bool + Hash() common.Hash + // To returns the recipient address of the transaction. + // It returns nil if the transaction is a contract creation. + To() *common.Address + // RawSignatureValues returns the V, R, S signature values of the transaction. + // The return values should not be modified by the caller. + RawSignatureValues() (v, r, s *big.Int) +} + +func (tx *Transaction) Type() uint8 { return tx.typ } +func (tx *Transaction) ChainId() *big.Int { return tx.inner.ChainId() } +func (tx *Transaction) Protected() bool { return tx.inner.Protected() } func isProtectedV(V *big.Int) bool { if V.BitLen() <= 8 { v := V.Uint64() - return v != 27 && v != 28 + return v != 27 && v != 28 && v != 1 && v != 0 } // anything not 27 or 28 is considered protected return true @@ -130,13 +89,39 @@ func isProtectedV(V *big.Int) bool { // EncodeRLP implements rlp.Encoder func (tx *Transaction) EncodeRLP(w io.Writer) error { - return rlp.Encode(w, &tx.data) + if tx.typ != LegacyTxId { + if _, err := w.Write([]byte{tx.typ}); err != nil { + return err + } + } + return rlp.Encode(w, tx.inner) } // DecodeRLP implements rlp.Decoder func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { - _, size, _ := s.Kind() - err := s.Decode(&tx.data) + typ := uint64(LegacyTxId) + var size uint64 + // If the tx isn't an RLP list, it's likely typed so pop off the first byte. + kind, size, err := s.Kind() + if err != nil { + return err + } else if kind != rlp.List { + if typ, err = s.Uint(); err != nil { + return err + } + } + tx.typ = uint8(typ) + if typ == LegacyTxId { + var i *LegacyTransaction + err = s.Decode(&i) + tx.inner = i + } else if typ == AccessListTxId { + var i *AccessListTransaction + err = s.Decode(&i) + tx.inner = i + } else { + return ErrTxTypeNotSupported + } if err == nil { tx.size.Store(common.StorageSize(rlp.ListSize(size))) tx.time = time.Now() @@ -144,71 +129,61 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { return err } -// MarshalJSON encodes the web3 RPC transaction format. -func (tx *Transaction) MarshalJSON() ([]byte, error) { - hash := tx.Hash() - data := tx.data - data.Hash = &hash - return data.MarshalJSON() -} - -// UnmarshalJSON decodes the web3 RPC transaction format. -func (tx *Transaction) UnmarshalJSON(input []byte) error { - var dec txdata - if err := dec.UnmarshalJSON(input); err != nil { - return err +func sanityCheckSignature(v *big.Int, r *big.Int, s *big.Int, maybeProtected bool) error { + if isProtectedV(v) && !maybeProtected { + return ErrUnexpectedProtection } - withSignature := dec.V.Sign() != 0 || dec.R.Sign() != 0 || dec.S.Sign() != 0 - if withSignature { - var V byte - if isProtectedV(dec.V) { - chainID := deriveChainId(dec.V).Uint64() - V = byte(dec.V.Uint64() - 35 - 2*chainID) - } else { - V = byte(dec.V.Uint64() - 27) - } - if !crypto.ValidateSignatureValues(V, dec.R, dec.S, false) { - return ErrInvalidSig - } + + var plainV byte + if isProtectedV(v) { + chainID := deriveChainId(v).Uint64() + plainV = byte(v.Uint64() - 35 - 2*chainID) + } else if maybeProtected { + // Only EIP-155 signatures can be optionally protected. Since + // we determined this v value is not protected, it must be a + // raw 27 or 28. + plainV = byte(v.Uint64() - 27) + } else { + // If the signature is not optionally protected, we assume it + // must already be equal to the recovery id. + plainV = byte(v.Uint64()) } - *tx = Transaction{ - data: dec, - time: time.Now(), + if !crypto.ValidateSignatureValues(plainV, r, s, false) { + return ErrInvalidSig } + return nil } -func (tx *Transaction) Data() []byte { return common.CopyBytes(tx.data.Payload) } -func (tx *Transaction) Gas() uint64 { return tx.data.GasLimit } -func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.data.Price) } +func (tx *Transaction) Data() []byte { return tx.inner.Data() } +func (tx *Transaction) AccessList() *AccessList { return tx.inner.AccessList() } +func (tx *Transaction) Gas() uint64 { return tx.inner.Gas() } +func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.inner.GasPrice()) } func (tx *Transaction) GasPriceCmp(other *Transaction) int { - return tx.data.Price.Cmp(other.data.Price) + return tx.inner.GasPrice().Cmp(other.GasPrice()) } func (tx *Transaction) GasPriceIntCmp(other *big.Int) int { - return tx.data.Price.Cmp(other) -} -func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.data.Amount) } -func (tx *Transaction) Nonce() uint64 { return tx.data.AccountNonce } -func (tx *Transaction) CheckNonce() bool { return true } - -// To returns the recipient address of the transaction. -// It returns nil if the transaction is a contract creation. -func (tx *Transaction) To() *common.Address { - if tx.data.Recipient == nil { - return nil - } - to := *tx.data.Recipient - return &to + return tx.inner.GasPrice().Cmp(other) } - -// Hash hashes the RLP encoding of tx. -// It uniquely identifies the transaction. +func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.Value()) } +func (tx *Transaction) Nonce() uint64 { return tx.inner.Nonce() } +func (tx *Transaction) CheckNonce() bool { return true } +func (tx *Transaction) To() *common.Address { return tx.inner.To() } func (tx *Transaction) Hash() common.Hash { if hash := tx.hash.Load(); hash != nil { return hash.(common.Hash) } - v := rlpHash(tx) + + var v common.Hash + + if tx.typ == LegacyTxId { + v = rlpHash(tx.inner) + } else { + v = rlpHash([]interface{}{tx.typ, tx.inner}) + } + tx.hash.Store(v) + return v } @@ -219,59 +194,74 @@ func (tx *Transaction) Size() common.StorageSize { return size.(common.StorageSize) } c := writeCounter(0) - rlp.Encode(&c, &tx.data) + rlp.Encode(&c, &tx.inner) tx.size.Store(common.StorageSize(c)) return common.StorageSize(c) } - -// AsMessage returns the transaction as a core.Message. -// -// AsMessage requires a signer to derive the sender. -// -// XXX Rename message to something less arbitrary? -func (tx *Transaction) AsMessage(s Signer) (Message, error) { - msg := Message{ - nonce: tx.data.AccountNonce, - gasLimit: tx.data.GasLimit, - gasPrice: new(big.Int).Set(tx.data.Price), - to: tx.data.Recipient, - amount: tx.data.Amount, - data: tx.data.Payload, - checkNonce: true, - } - - var err error - msg.from, err = Sender(s, tx) - return msg, err -} - -// WithSignature returns a new transaction with the given signature. -// This signature needs to be in the [R || S || V] format where V is 0 or 1. func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error) { r, s, v, err := signer.SignatureValues(tx, sig) if err != nil { return nil, err } - cpy := &Transaction{ - data: tx.data, - time: tx.time, + + var ret *Transaction + if tx.typ == LegacyTxId { + inner := tx.inner.(*LegacyTransaction) + cpy := &LegacyTransaction{ + AccountNonce: inner.AccountNonce, + Price: inner.Price, + GasLimit: inner.GasLimit, + Recipient: inner.Recipient, + Amount: inner.Amount, + Payload: inner.Payload, + + V: inner.V, + R: inner.R, + S: inner.S, + } + cpy.R, cpy.S, cpy.V = r, s, v + + ret = &Transaction{ + typ: LegacyTxId, + inner: cpy, + time: tx.time, + } + } else if tx.typ == AccessListTxId { + inner := tx.inner.(*AccessListTransaction) + cpy := &AccessListTransaction{ + Chain: inner.Chain, + AccountNonce: inner.AccountNonce, + Price: inner.Price, + GasLimit: inner.GasLimit, + Recipient: inner.Recipient, + Amount: inner.Amount, + Payload: inner.Payload, + Accesses: inner.Accesses, + + V: inner.V, + R: inner.R, + S: inner.S, + } + cpy.R, cpy.S, cpy.V = r, s, v + + ret = &Transaction{ + typ: AccessListTxId, + inner: cpy, + time: tx.time, + } + + } else { + return nil, ErrInvalidTxType } - cpy.data.R, cpy.data.S, cpy.data.V = r, s, v - return cpy, nil -} -// Cost returns amount + gasprice * gaslimit. + return ret, nil +} func (tx *Transaction) Cost() *big.Int { - total := new(big.Int).Mul(tx.data.Price, new(big.Int).SetUint64(tx.data.GasLimit)) - total.Add(total, tx.data.Amount) + total := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())) + total.Add(total, tx.Value()) return total } - -// RawSignatureValues returns the V, R, S signature values of the transaction. -// The return values should not be modified by the caller. -func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { - return tx.data.V, tx.data.R, tx.data.S -} +func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { return tx.inner.RawSignatureValues() } // Transactions is a Transaction slice type for basic sorting. type Transactions []*Transaction @@ -312,7 +302,7 @@ func TxDifference(a, b Transactions) Transactions { type TxByNonce Transactions func (s TxByNonce) Len() int { return len(s) } -func (s TxByNonce) Less(i, j int) bool { return s[i].data.AccountNonce < s[j].data.AccountNonce } +func (s TxByNonce) Less(i, j int) bool { return s[i].Nonce() < s[j].Nonce() } func (s TxByNonce) Swap(i, j int) { s[i], s[j] = s[j], s[i] } // TxByPriceAndTime implements both the sort and the heap interface, making it useful @@ -323,7 +313,7 @@ func (s TxByPriceAndTime) Len() int { return len(s) } func (s TxByPriceAndTime) Less(i, j int) bool { // If the prices are equal, use the time the transaction was first seen for // deterministic sorting - cmp := s[i].data.Price.Cmp(s[j].data.Price) + cmp := s[i].GasPrice().Cmp(s[j].GasPrice()) if cmp == 0 { return s[i].time.Before(s[j].time) } @@ -416,10 +406,11 @@ type Message struct { gasLimit uint64 gasPrice *big.Int data []byte + accessList *AccessList checkNonce bool } -func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool) Message { +func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList *AccessList, checkNonce bool) Message { return Message{ from: from, to: to, @@ -428,15 +419,35 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b gasLimit: gasLimit, gasPrice: gasPrice, data: data, + accessList: accessList, checkNonce: checkNonce, } } -func (m Message) From() common.Address { return m.from } -func (m Message) To() *common.Address { return m.to } -func (m Message) GasPrice() *big.Int { return m.gasPrice } -func (m Message) Value() *big.Int { return m.amount } -func (m Message) Gas() uint64 { return m.gasLimit } -func (m Message) Nonce() uint64 { return m.nonce } -func (m Message) Data() []byte { return m.data } -func (m Message) CheckNonce() bool { return m.checkNonce } +// AsMessage returns the transaction as a core.Message. +func (tx *Transaction) AsMessage(s Signer) (Message, error) { + msg := Message{ + nonce: tx.Nonce(), + gasLimit: tx.Gas(), + gasPrice: new(big.Int).Set(tx.GasPrice()), + to: tx.To(), + amount: tx.Value(), + data: tx.Data(), + accessList: tx.AccessList(), + checkNonce: true, + } + + var err error + msg.from, err = Sender(s, tx) + return msg, err +} + +func (m Message) From() common.Address { return m.from } +func (m Message) To() *common.Address { return m.to } +func (m Message) GasPrice() *big.Int { return m.gasPrice } +func (m Message) Value() *big.Int { return m.amount } +func (m Message) Gas() uint64 { return m.gasLimit } +func (m Message) Nonce() uint64 { return m.nonce } +func (m Message) Data() []byte { return m.data } +func (m Message) AccessList() *AccessList { return m.accessList } +func (m Message) CheckNonce() bool { return m.checkNonce } diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 842fedbd03d6..57f91f897a2c 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -42,6 +42,8 @@ type sigCache struct { func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { var signer Signer switch { + case config.IsYoloV2(blockNumber): + signer = NewEIP2718Signer(config.ChainID) case config.IsEIP155(blockNumber): signer = NewEIP155Signer(config.ChainID) case config.IsHomestead(blockNumber): @@ -102,6 +104,84 @@ type Signer interface { Equal(Signer) bool } +type EIP2718Signer struct{ EIP155Signer } + +func NewEIP2718Signer(chainId *big.Int) EIP2718Signer { + return EIP2718Signer{ + NewEIP155Signer(chainId), + } +} + +// Sender returns the recovered addressed from a transaction's signature. +// It assumes V does not store the chain id, unless the tx is of legacy type. +func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { + if !tx.Protected() { + return HomesteadSigner{}.Sender(tx) + } + if tx.ChainId().Cmp(s.chainId) != 0 { + return common.Address{}, ErrInvalidChainId + } + + V, R, S := tx.RawSignatureValues() + + if tx.Type() == LegacyTxId { + V = new(big.Int).Sub(V, s.chainIdMul) + V.Sub(V, big8) + } + if tx.Type() == AccessListTxId { + V = new(big.Int).Add(V, big.NewInt(27)) + } + + return recoverPlain(s.Hash(tx), R, S, V, true) +} + +// SignatureValues returns signature values. +func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) { + R, S, V, err = HomesteadSigner{}.SignatureValues(tx, sig) + if err != nil { + return nil, nil, nil, err + } + if tx.Type() == LegacyTxId && s.chainId.Sign() != 0 { + V = big.NewInt(int64(sig[64] + 35)) + V.Add(V, s.chainIdMul) + } + if tx.Type() == AccessListTxId { + V = big.NewInt(int64(sig[64])) + } + return R, S, V, nil +} + +// Hash returns the hash to be signed by the sender. +// It does not uniquely identify the transaction. +func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { + var h common.Hash + if tx.typ == LegacyTxId { + h = rlpHash([]interface{}{ + tx.Nonce(), + tx.GasPrice(), + tx.Gas(), + tx.To(), + tx.Value(), + tx.Data(), + s.chainId, uint(0), uint(0), + }) + } else if tx.typ == AccessListTxId { + h = rlpHash([]interface{}{ + tx.Type(), + tx.ChainId(), + tx.Nonce(), + tx.GasPrice(), + tx.Gas(), + tx.To(), + tx.Value(), + tx.Data(), + tx.AccessList(), + }) + } + + return h +} + // EIP155Transaction implements Signer using the EIP155 rules. type EIP155Signer struct { chainId, chainIdMul *big.Int @@ -131,9 +211,10 @@ func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error) { if tx.ChainId().Cmp(s.chainId) != 0 { return common.Address{}, ErrInvalidChainId } - V := new(big.Int).Sub(tx.data.V, s.chainIdMul) + V, R, S := tx.RawSignatureValues() + V = new(big.Int).Sub(V, s.chainIdMul) V.Sub(V, big8) - return recoverPlain(s.Hash(tx), tx.data.R, tx.data.S, V, true) + return recoverPlain(s.Hash(tx), R, S, V, true) } // SignatureValues returns signature values. This signature @@ -154,12 +235,12 @@ func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big // It does not uniquely identify the transaction. func (s EIP155Signer) Hash(tx *Transaction) common.Hash { return rlpHash([]interface{}{ - tx.data.AccountNonce, - tx.data.Price, - tx.data.GasLimit, - tx.data.Recipient, - tx.data.Amount, - tx.data.Payload, + tx.Nonce(), + tx.GasPrice(), + tx.Gas(), + tx.To(), + tx.Value(), + tx.Data(), s.chainId, uint(0), uint(0), }) } @@ -180,7 +261,8 @@ func (hs HomesteadSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v } func (hs HomesteadSigner) Sender(tx *Transaction) (common.Address, error) { - return recoverPlain(hs.Hash(tx), tx.data.R, tx.data.S, tx.data.V, true) + v, r, s := tx.RawSignatureValues() + return recoverPlain(hs.Hash(tx), r, s, v, true) } type FrontierSigner struct{} @@ -206,17 +288,18 @@ func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v * // It does not uniquely identify the transaction. func (fs FrontierSigner) Hash(tx *Transaction) common.Hash { return rlpHash([]interface{}{ - tx.data.AccountNonce, - tx.data.Price, - tx.data.GasLimit, - tx.data.Recipient, - tx.data.Amount, - tx.data.Payload, + tx.Nonce(), + tx.GasPrice(), + tx.Gas(), + tx.To(), + tx.Value(), + tx.Data(), }) } func (fs FrontierSigner) Sender(tx *Transaction) (common.Address, error) { - return recoverPlain(fs.Hash(tx), tx.data.R, tx.data.S, tx.data.V, false) + v, r, s := tx.RawSignatureValues() + return recoverPlain(fs.Hash(tx), r, s, v, false) } func recoverPlain(sighash common.Hash, R, S, Vb *big.Int, homestead bool) (common.Address, error) { diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 159cb0c4c4fc..4a1df3360231 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -50,6 +50,31 @@ var ( HomesteadSigner{}, common.Hex2Bytes("98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a301"), ) + + empty2718Tx = NewAccessListTransaction( + big.NewInt(1), + 3, + common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), + big.NewInt(10), + 25000, + big.NewInt(1), + common.FromHex("5544"), + nil, + ) + + signed2718Tx, _ = NewAccessListTransaction( + big.NewInt(1), + 3, + common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), + big.NewInt(10), + 25000, + big.NewInt(1), + common.FromHex("5544"), + nil, + ).WithSignature( + NewEIP2718Signer(big.NewInt(1)), + common.Hex2Bytes("cb51495c66325615bcd591505577c9dde87bd59b04be2e6ba82f6d7bdea576e349e4f02f37666bd91a052a56e91e71e438590df861031ee9a321ce058df3dc2b01"), + ) ) func TestTransactionSigHash(t *testing.T) { @@ -68,6 +93,27 @@ func TestTransactionEncode(t *testing.T) { t.Fatalf("encode error: %v", err) } should := common.FromHex("f86103018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255441ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3") + if !bytes.Equal(txb, should) { + t.Errorf("encoded EIP-2718 transaction RLP mismatch, got %x", txb) + } +} + +func TestEIP2718TransactionSigHash(t *testing.T) { + yolo := NewEIP2718Signer(big.NewInt(1)) + if yolo.Hash(empty2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { + t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", emptyTx.Hash()) + } + if yolo.Hash(signed2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { + t.Errorf("signed EIP-2718 transaction hash mismatch, got %x", rightvrsTx.Hash()) + } +} + +func TestEIP2718TransactionEncode(t *testing.T) { + txb, err := rlp.EncodeToBytes(signed2718Tx) + if err != nil { + t.Fatalf("encode error: %v", err) + } + should := common.FromHex("01f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0cb51495c66325615bcd591505577c9dde87bd59b04be2e6ba82f6d7bdea576e3a049e4f02f37666bd91a052a56e91e71e438590df861031ee9a321ce058df3dc2b") if !bytes.Equal(txb, should) { t.Errorf("encoded RLP mismatch, got %x", txb) } @@ -225,16 +271,25 @@ func TestTransactionJSON(t *testing.T) { if err != nil { t.Fatalf("could not generate key: %v", err) } - signer := NewEIP155Signer(common.Big1) + signer := NewEIP2718Signer(common.Big1) transactions := make([]*Transaction, 0, 50) for i := uint64(0); i < 25; i++ { var tx *Transaction - switch i % 2 { + switch i % 3 { case 0: tx = NewTransaction(i, common.Address{1}, common.Big0, 1, common.Big2, []byte("abcdef")) case 1: tx = NewContractCreation(i, common.Big0, 1, common.Big2, []byte("abcdef")) + case 2: + addr := common.HexToAddress("0x0000000000000000000000000000000000000001") + accesses := AccessList{AccessTuple{ + Address: &addr, + StorageKeys: []*common.Hash{ + {0}, + }, + }} + tx = NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) } transactions = append(transactions, tx) diff --git a/interfaces.go b/interfaces.go index 1ff31f96b6a6..2a5c1bfb4543 100644 --- a/interfaces.go +++ b/interfaces.go @@ -113,12 +113,13 @@ type ChainSyncReader interface { // CallMsg contains parameters for contract calls. type CallMsg struct { - From common.Address // the sender of the 'transaction' - To *common.Address // the destination contract (nil for contract creation) - Gas uint64 // if 0, the call executes with near-infinite gas - GasPrice *big.Int // wei <-> gas exchange ratio - Value *big.Int // amount of wei sent along with the call - Data []byte // input data, usually an ABI-encoded contract method invocation + From common.Address // the sender of the 'transaction' + To *common.Address // the destination contract (nil for contract creation) + Gas uint64 // if 0, the call executes with near-infinite gas + GasPrice *big.Int // wei <-> gas exchange ratio + Value *big.Int // amount of wei sent along with the call + Data []byte // input data, usually an ABI-encoded contract method invocation + AccessList *types.AccessList // EIP-2930 access list } // A ContractCaller provides contract calls, essentially transactions that are executed by diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 52b4f5f506e4..0df2c7e7b3c3 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -791,7 +791,7 @@ func (args *CallArgs) ToMessage(globalGasCap uint64) types.Message { data = *args.Data } - msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, false) + msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, nil, false) return msg } diff --git a/internal/guide/guide_test.go b/internal/guide/guide_test.go index 9c7ad16d182d..abc48e0e4b6a 100644 --- a/internal/guide/guide_test.go +++ b/internal/guide/guide_test.go @@ -31,6 +31,7 @@ import ( "time" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" ) @@ -75,7 +76,8 @@ func TestAccountManagement(t *testing.T) { if err != nil { t.Fatalf("Failed to create signer account: %v", err) } - tx, chain := new(types.Transaction), big.NewInt(1) + tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), nil) + chain := big.NewInt(1) // Sign a transaction with a single authorization if _, err := ks.SignTxWithPassphrase(signer, "Signer password", tx, chain); err != nil { diff --git a/les/odr_test.go b/les/odr_test.go index 2a70a296c843..d3363ab96e4a 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -132,7 +132,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai from := statedb.GetOrNewStateObject(bankAddr) from.SetBalance(math.MaxBig256) - msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false)} + msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, nil, false)} context := core.NewEVMBlockContext(header, bc, nil) txContext := core.NewEVMTxContext(msg) @@ -147,7 +147,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai header := lc.GetHeaderByHash(bhash) state := light.NewState(ctx, header, lc.Odr()) state.SetBalance(bankAddr, math.MaxBig256) - msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false)} + msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, nil, false)} context := core.NewEVMBlockContext(header, lc, nil) txContext := core.NewEVMTxContext(msg) vmenv := vm.NewEVM(context, txContext, state, config, vm.Config{}) diff --git a/light/odr_test.go b/light/odr_test.go index cb22334fdc9f..0fc45b873418 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain // Perform read-only call. st.SetBalance(testBankAddress, math.MaxBig256) - msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, false)} + msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, nil, false)} txContext := core.NewEVMTxContext(msg) context := core.NewEVMBlockContext(header, chain, nil) vmenv := vm.NewEVM(context, txContext, st, config, vm.Config{}) diff --git a/light/txpool.go b/light/txpool.go index 2831de5a653a..7525b13ce8f8 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -69,6 +69,7 @@ type TxPool struct { clearIdx uint64 // earliest block nr that can contain mined tx info istanbul bool // Fork indicator whether we are in the istanbul stage. + yoloV2 bool // Fork indicator whether we are in the yoloV2 stage. } // TxRelayBackend provides an interface to the mechanism that forwards transacions @@ -314,6 +315,7 @@ func (pool *TxPool) setNewHead(head *types.Header) { // Update fork indicator by next pending block number next := new(big.Int).Add(head.Number, big.NewInt(1)) pool.istanbul = pool.config.IsIstanbul(next) + pool.yoloV2 = pool.config.IsYoloV2(next) } // Stop stops the light transaction pool @@ -381,7 +383,7 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error } // Should supply enough intrinsic gas - gas, err := core.IntrinsicGas(tx.Data(), tx.To() == nil, true, pool.istanbul) + gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.yoloV2) if err != nil { return err } diff --git a/miner/worker.go b/miner/worker.go index e81d50e46e38..c5ccd68d5793 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -829,6 +829,11 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin w.current.tcount++ txs.Shift() + case errors.Is(err, core.ErrTxTypeInvalid): + // Pop the unsupported transaction without shifting in the next from the account + log.Trace("Skipping unsupported transaction type", "sender", from, "type", tx.Type()) + txs.Pop() + default: // Strange error, discard the transaction and get the next in line (note, the // nonce-too-high clause will prevent us from executing in vain). diff --git a/params/protocol_params.go b/params/protocol_params.go index ffb901ec3d3b..88f1a06e12d3 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -60,20 +60,23 @@ const ( JumpdestGas uint64 = 1 // Once per JUMPDEST operation. EpochDuration uint64 = 30000 // Duration between proof-of-work epochs. - CreateDataGas uint64 = 200 // - CallCreateDepth uint64 = 1024 // Maximum depth of call/create stack. - ExpGas uint64 = 10 // Once per EXP instruction - LogGas uint64 = 375 // Per LOG* operation. - CopyGas uint64 = 3 // - StackLimit uint64 = 1024 // Maximum size of VM stack allowed. - TierStepGas uint64 = 0 // Once per operation, for a selection of them. - LogTopicGas uint64 = 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. - CreateGas uint64 = 32000 // Once per CREATE operation & contract-creation transaction. - Create2Gas uint64 = 32000 // Once per CREATE2 operation - SelfdestructRefundGas uint64 = 24000 // Refunded following a selfdestruct operation. - MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. - TxDataNonZeroGasFrontier uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - TxDataNonZeroGasEIP2028 uint64 = 16 // Per byte of non zero data attached to a transaction after EIP 2028 (part in Istanbul) + CreateDataGas uint64 = 200 // + CallCreateDepth uint64 = 1024 // Maximum depth of call/create stack. + ExpGas uint64 = 10 // Once per EXP instruction + LogGas uint64 = 375 // Per LOG* operation. + CopyGas uint64 = 3 // + StackLimit uint64 = 1024 // Maximum size of VM stack allowed. + TierStepGas uint64 = 0 // Once per operation, for a selection of them. + LogTopicGas uint64 = 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. + CreateGas uint64 = 32000 // Once per CREATE operation & contract-creation transaction. + Create2Gas uint64 = 32000 // Once per CREATE2 operation + SelfdestructRefundGas uint64 = 24000 // Refunded following a selfdestruct operation. + MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. + + TxDataNonZeroGasFrontier uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. + TxDataNonZeroGasEIP2028 uint64 = 16 // Per byte of non zero data attached to a transaction after EIP 2028 (part in Istanbul) + TxAccessListAddressGas uint64 = 2400 // Per address specified in EIP 2930 access list + TxAccessListStorageKeyGas uint64 = 1900 // Per storage key specified in EIP 2930 access list // These have been changed during the course of the chain CallGasFrontier uint64 = 40 // Once per CALL operation & message call transaction. diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 53c7d955becc..bbb3c4573942 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -300,7 +300,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) { return nil, fmt.Errorf("invalid tx data %q", dataHex) } - msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true) + msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, nil, true) return msg, nil } diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index aea90535c3f4..fd4adfb97678 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -45,7 +45,7 @@ type ttFork struct { } func (tt *TransactionTest) Run(config *params.ChainConfig) error { - validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead bool, isIstanbul bool) (*common.Address, *common.Hash, error) { + validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead bool, isIstanbul bool, isYoloV2 bool) (*common.Address, *common.Hash, error) { tx := new(types.Transaction) if err := rlp.DecodeBytes(rlpData, tx); err != nil { return nil, nil, err @@ -55,7 +55,7 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { return nil, nil, err } // Intrinsic gas - requiredGas, err := core.IntrinsicGas(tx.Data(), tx.To() == nil, isHomestead, isIstanbul) + requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, isYoloV2) if err != nil { return nil, nil, err } @@ -72,16 +72,17 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { fork ttFork isHomestead bool isIstanbul bool + isYoloV2 bool }{ - {"Frontier", types.FrontierSigner{}, tt.Frontier, false, false}, - {"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false}, - {"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false}, - {"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false}, - {"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false}, - {"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false}, - {"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true}, + {"Frontier", types.FrontierSigner{}, tt.Frontier, false, false, false}, + {"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false, false}, + {"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false, false}, + {"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false, false}, + {"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false, false}, + {"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false, false}, + {"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true, false}, } { - sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul) + sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul, testcase.isYoloV2) if testcase.fork.Sender == (common.UnprefixedAddress{}) { if err == nil { From 1a70454e8ac45b98834ee38cc2da1d8dc4378a28 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Wed, 11 Nov 2020 12:05:14 -0700 Subject: [PATCH 02/83] core/types, core/tx_pool: if access list not provided, set to empty list, tx validity core/tx_pool: ensure tx pool only stores txs valid for the current fork core/tx_pool: remove 2718 fork info from intrinsic gas core/types: wrap all typed txs in rlp string core/types: ensure tx is passed as reference to encoder --- core/bench_test.go | 2 +- core/state_transition.go | 7 ++- core/tx_pool.go | 10 +++- core/types/access_list_tx.go | 6 ++- core/types/block.go | 12 ++++- core/types/block_test.go | 4 +- core/types/legacy_tx.go | 1 - core/types/transaction.go | 87 ++++++++++++++++++++----------- core/types/transaction_signing.go | 22 ++++---- core/types/transaction_test.go | 20 +++---- eth/tracers/tracer.go | 2 +- light/txpool.go | 2 +- miner/worker.go | 2 +- rlp/decode.go | 12 +++++ tests/transaction_test_util.go | 21 ++++---- 15 files changed, 133 insertions(+), 77 deletions(-) diff --git a/core/bench_test.go b/core/bench_test.go index 0347bc44318c..85653ea5dbe6 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -85,7 +85,7 @@ func genValueTx(nbytes int) func(int, *BlockGen) { return func(i int, gen *BlockGen) { toaddr := common.Address{} data := make([]byte, nbytes) - gas, _ := IntrinsicGas(data, nil, false, false, false, false) + gas, _ := IntrinsicGas(data, nil, false, false, false) tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(benchRootAddr), toaddr, big.NewInt(1), gas, nil, data), types.HomesteadSigner{}, benchRootKey) gen.AddTx(tx) } diff --git a/core/state_transition.go b/core/state_transition.go index 83e7f2c6362c..1e568c07e8c2 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -107,7 +107,7 @@ func (result *ExecutionResult) Revert() []byte { } // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. -func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP2718 bool) (uint64, error) { +func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation bool, isHomestead, isEIP2028 bool) (uint64, error) { // Set the starting gas for the raw transaction var gas uint64 if isContractCreation && isHomestead { @@ -140,7 +140,7 @@ func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation } gas += z * params.TxDataZeroGas } - if isEIP2718 && accessList != nil { + if accessList != nil { gas += uint64(accessList.Addresses()) * params.TxAccessListAddressGas gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas } @@ -241,11 +241,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { sender := vm.AccountRef(msg.From()) homestead := st.evm.ChainConfig().IsHomestead(st.evm.Context.BlockNumber) istanbul := st.evm.ChainConfig().IsIstanbul(st.evm.Context.BlockNumber) - yoloV2 := st.evm.ChainConfig().IsYoloV2(st.evm.Context.BlockNumber) contractCreation := msg.To() == nil // Check clauses 4-5, subtract intrinsic gas if everything is correct - gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, homestead, istanbul, yoloV2) + gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, homestead, istanbul) if err != nil { return nil, err } diff --git a/core/tx_pool.go b/core/tx_pool.go index 02c786fda25a..e66695649ce2 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -539,6 +539,14 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if pool.currentMaxGas < tx.Gas() { return ErrGasLimit } + // Accept only legacy transactions if before yoloV2. + if tx.Type() != types.LegacyTxId && !pool.yoloV2 { + return ErrTxTypeNotSupported + } + // After yoloV2, accept both legacy transactions and access list transactions. + if pool.yoloV2 && (tx.Type() != types.LegacyTxId && tx.Type() != types.AccessListTxId) { + return ErrTxTypeNotSupported + } // Make sure the transaction is signed properly from, err := types.Sender(pool.signer, tx) if err != nil { @@ -558,7 +566,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrInsufficientFunds } // Ensure the transaction has more gas than the basic tx fee. - intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.yoloV2) + intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul) if err != nil { return err } diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index fa547d3e6a97..af5377735943 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -72,7 +72,7 @@ func newAccessListTransaction(chainId *big.Int, nonce uint64, to *common.Address AccountNonce: nonce, Recipient: to, Payload: data, - Accesses: accesses, + Accesses: &AccessList{}, Amount: new(big.Int), GasLimit: gasLimit, Price: new(big.Int), @@ -89,6 +89,9 @@ func newAccessListTransaction(chainId *big.Int, nonce uint64, to *common.Address if gasPrice != nil { i.Price.Set(gasPrice) } + if accesses != nil { + i.Accesses = accesses + } return &Transaction{ typ: AccessListTxId, inner: &i, @@ -105,7 +108,6 @@ func (tx *AccessListTransaction) GasPrice() *big.Int { return new(big.Int). func (tx *AccessListTransaction) Value() *big.Int { return new(big.Int).Set(tx.Amount) } func (tx *AccessListTransaction) Nonce() uint64 { return tx.AccountNonce } func (tx *AccessListTransaction) CheckNonce() bool { return true } -func (tx *AccessListTransaction) Hash() common.Hash { return rlpHash(tx) } // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. diff --git a/core/types/block.go b/core/types/block.go index 8096ebb75516..310a913b225e 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -147,6 +147,16 @@ func rlpHash(x interface{}) (h common.Hash) { return h } +func typedRlpHash(typ uint8, x interface{}) (h common.Hash) { + sha := hasherPool.Get().(crypto.KeccakState) + defer hasherPool.Put(sha) + sha.Reset() + sha.Write([]byte{typ}) + rlp.Encode(sha, x) + sha.Read(h[:]) + return h +} + // EmptyBody returns true if there is no additional 'body' to complete the header // that is: no transactions and no uncles. func (h *Header) EmptyBody() bool { @@ -169,7 +179,7 @@ type Body struct { type Block struct { header *Header uncles []*Header - transactions Transactions + transactions []*Transaction // caches hash atomic.Value diff --git a/core/types/block_test.go b/core/types/block_test.go index 4f7fb6519335..ed6c81672248 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -69,7 +69,7 @@ func TestBlockEncoding(t *testing.T) { } func TestEIP2718BlockEncoding(t *testing.T) { - blockEnc := common.FromHex("f90316f90211a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a08dae65c92dceddaa2fabec652b550258568abed0de8ae7482e662afa5cd6bef7a0cafe75574d59780665a97fbfd11365c7545aa8f1abf4e5e12e8243334ef7286bb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000820200832fefd882a410845506eb0796636f6f6c65737420626c6f636b206f6e20636861696ea0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4f8fff85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b101f89b01800a8301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000001a078b8236a3b26d56c7d4ba94a36e64c5ea086619e489c005ece0ac7bd8356be22a02fea9f3d5aaff74ac1e996e590f7152ea74ed300c59909b2921b73237c7b0692c0") + blockEnc := common.FromHex("f90319f90211a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0e6e49996c7ec59f7a23d22b83239a60151512c65613bf84a0d7da336399ebc4aa0cafe75574d59780665a97fbfd11365c7545aa8f1abf4e5e12e8243334ef7286bb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000820200832fefd882a410845506eb0796636f6f6c65737420626c6f636b206f6e20636861696ea0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4f90101f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1b89e01f89b01800a8301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000001a03dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335a0476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef14c0") var block Block if err := rlp.DecodeBytes(blockEnc, &block); err != nil { t.Fatal("decode error: ", err) @@ -100,7 +100,7 @@ func TestEIP2718BlockEncoding(t *testing.T) { }, }} tx2 := NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) - tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), common.Hex2Bytes("78b8236a3b26d56c7d4ba94a36e64c5ea086619e489c005ece0ac7bd8356be222fea9f3d5aaff74ac1e996e590f7152ea74ed300c59909b2921b73237c7b069201")) + tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401")) check("len(Transactions)", len(block.Transactions()), 2) check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash()) diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 9ac39158a47b..5ff7c437e66e 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -82,7 +82,6 @@ func (tx *LegacyTransaction) GasPrice() *big.Int { return new(big.Int).Set( func (tx *LegacyTransaction) Value() *big.Int { return new(big.Int).Set(tx.Amount) } func (tx *LegacyTransaction) Nonce() uint64 { return tx.AccountNonce } func (tx *LegacyTransaction) CheckNonce() bool { return true } -func (tx *LegacyTransaction) Hash() common.Hash { return rlpHash(tx) } // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. diff --git a/core/types/transaction.go b/core/types/transaction.go index 2ff872358a59..e7cbaf6f74a8 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -17,6 +17,7 @@ package types import ( + "bytes" "container/heap" "errors" "io" @@ -65,7 +66,6 @@ type inner interface { Value() *big.Int Nonce() uint64 CheckNonce() bool - Hash() common.Hash // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. To() *common.Address @@ -88,44 +88,60 @@ func isProtectedV(V *big.Int) bool { } // EncodeRLP implements rlp.Encoder +// For legacy transactions, it outputs rlp(tx.inner). For typed transactions +// it outputs rlp(tx.type || tx.inner). func (tx *Transaction) EncodeRLP(w io.Writer) error { - if tx.typ != LegacyTxId { - if _, err := w.Write([]byte{tx.typ}); err != nil { - return err - } + if tx.typ == LegacyTxId { + return rlp.Encode(w, tx.inner) } - return rlp.Encode(w, tx.inner) + buf := new(bytes.Buffer) + if _, err := buf.Write([]byte{tx.typ}); err != nil { + return err + } + if err := rlp.Encode(buf, tx.inner); err != nil { + return err + } + return rlp.Encode(w, buf.Bytes()) } // DecodeRLP implements rlp.Decoder func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { - typ := uint64(LegacyTxId) var size uint64 // If the tx isn't an RLP list, it's likely typed so pop off the first byte. kind, size, err := s.Kind() if err != nil { return err - } else if kind != rlp.List { - if typ, err = s.Uint(); err != nil { - return err - } - } - tx.typ = uint8(typ) - if typ == LegacyTxId { + } else if kind == rlp.List { + tx.typ = LegacyTxId var i *LegacyTransaction err = s.Decode(&i) tx.inner = i - } else if typ == AccessListTxId { - var i *AccessListTransaction - err = s.Decode(&i) - tx.inner = i + } else if kind == rlp.String { + var b []byte + b, err = s.Bytes() + if err != nil { + return err + } + + tx.typ = b[0] + size = uint64(len(b)) + + if tx.typ == AccessListTxId { + var i *AccessListTransaction + err = rlp.DecodeBytes(b[1:], &i) + tx.inner = i + } else { + return ErrTxTypeNotSupported + } } else { - return ErrTxTypeNotSupported + return rlp.ErrExpectedList } + if err == nil { tx.size.Store(common.StorageSize(rlp.ListSize(size))) tx.time = time.Now() } + return err } @@ -173,18 +189,11 @@ func (tx *Transaction) Hash() common.Hash { if hash := tx.hash.Load(); hash != nil { return hash.(common.Hash) } + n := rawtx(*tx) + h := rlpHash(&n) + tx.hash.Store(h) - var v common.Hash - - if tx.typ == LegacyTxId { - v = rlpHash(tx.inner) - } else { - v = rlpHash([]interface{}{tx.typ, tx.inner}) - } - - tx.hash.Store(v) - - return v + return h } // Size returns the true RLP encoded storage size of the transaction, either by @@ -263,6 +272,21 @@ func (tx *Transaction) Cost() *big.Int { } func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { return tx.inner.RawSignatureValues() } +// Raw transactions are used for internal processes which need the raw +// consensus representation of typed transactions, not the RLP string +// wrapped version. +type rawtx Transaction + +func (tx *rawtx) EncodeRLP(w io.Writer) error { + if tx.typ != LegacyTxId { + if _, err := w.Write([]byte{tx.typ}); err != nil { + return err + } + } + + return rlp.Encode(w, tx.inner) +} + // Transactions is a Transaction slice type for basic sorting. type Transactions []*Transaction @@ -274,7 +298,8 @@ func (s Transactions) Swap(i, j int) { s[i], s[j] = s[j], s[i] } // GetRlp implements Rlpable and returns the i'th element of s in rlp. func (s Transactions) GetRlp(i int) []byte { - enc, _ := rlp.EncodeToBytes(s[i]) + raw := rawtx(*s[i]) + enc, _ := rlp.EncodeToBytes(&raw) return enc } diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 57f91f897a2c..365e51b2c061 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -166,17 +166,19 @@ func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { s.chainId, uint(0), uint(0), }) } else if tx.typ == AccessListTxId { - h = rlpHash([]interface{}{ + h = typedRlpHash( tx.Type(), - tx.ChainId(), - tx.Nonce(), - tx.GasPrice(), - tx.Gas(), - tx.To(), - tx.Value(), - tx.Data(), - tx.AccessList(), - }) + []interface{}{ + tx.ChainId(), + tx.Nonce(), + tx.GasPrice(), + tx.Gas(), + tx.To(), + tx.Value(), + tx.Data(), + tx.AccessList(), + }, + ) } return h diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 4a1df3360231..519a53a74657 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -51,7 +51,7 @@ var ( common.Hex2Bytes("98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a301"), ) - empty2718Tx = NewAccessListTransaction( + emptyEip2718Tx = NewAccessListTransaction( big.NewInt(1), 3, common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), @@ -62,7 +62,7 @@ var ( nil, ) - signed2718Tx, _ = NewAccessListTransaction( + signedEip2718Tx, _ = NewAccessListTransaction( big.NewInt(1), 3, common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), @@ -73,7 +73,7 @@ var ( nil, ).WithSignature( NewEIP2718Signer(big.NewInt(1)), - common.Hex2Bytes("cb51495c66325615bcd591505577c9dde87bd59b04be2e6ba82f6d7bdea576e349e4f02f37666bd91a052a56e91e71e438590df861031ee9a321ce058df3dc2b01"), + common.Hex2Bytes("da9ad262d794b71067f1530b19314045ed4cf961e6a8ef393e244eaf2721fe016ee9a433a359987bfe5cc28361759a6e1fe94a15e15e4bdf36364e29af12d00400"), ) ) @@ -99,21 +99,21 @@ func TestTransactionEncode(t *testing.T) { } func TestEIP2718TransactionSigHash(t *testing.T) { - yolo := NewEIP2718Signer(big.NewInt(1)) - if yolo.Hash(empty2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { - t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", emptyTx.Hash()) + s := NewEIP2718Signer(big.NewInt(1)) + if s.Hash(emptyEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") { + t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", s.Hash(emptyEip2718Tx)) } - if yolo.Hash(signed2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { - t.Errorf("signed EIP-2718 transaction hash mismatch, got %x", rightvrsTx.Hash()) + if s.Hash(signedEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") { + t.Errorf("signed EIP-2718 transaction hash mismatch, got %x", s.Hash(signedEip2718Tx)) } } func TestEIP2718TransactionEncode(t *testing.T) { - txb, err := rlp.EncodeToBytes(signed2718Tx) + txb, err := rlp.EncodeToBytes(signedEip2718Tx) if err != nil { t.Fatalf("encode error: %v", err) } - should := common.FromHex("01f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0cb51495c66325615bcd591505577c9dde87bd59b04be2e6ba82f6d7bdea576e3a049e4f02f37666bd91a052a56e91e71e438590df861031ee9a321ce058df3dc2b") + should := common.FromHex("b86601f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c080a0da9ad262d794b71067f1530b19314045ed4cf961e6a8ef393e244eaf2721fe01a06ee9a433a359987bfe5cc28361759a6e1fe94a15e15e4bdf36364e29af12d004") if !bytes.Equal(txb, should) { t.Errorf("encoded RLP mismatch, got %x", txb) } diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index dba7ce87cf5b..80775caa8e59 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -556,7 +556,7 @@ func (jst *Tracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost if data, ok := jst.ctx["input"].([]byte); ok { input = data } - intrinsicGas, err := core.IntrinsicGas(input, jst.ctx["type"] == "CREATE", isHomestead, isIstanbul) + intrinsicGas, err := core.IntrinsicGas(input, nil, jst.ctx["type"] == "CREATE", isHomestead, isIstanbul) if err != nil { return err } diff --git a/light/txpool.go b/light/txpool.go index 7525b13ce8f8..a6acce4f6a49 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -383,7 +383,7 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error } // Should supply enough intrinsic gas - gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.yoloV2) + gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul) if err != nil { return err } diff --git a/miner/worker.go b/miner/worker.go index c5ccd68d5793..3c70aadce7f2 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -829,7 +829,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin w.current.tcount++ txs.Shift() - case errors.Is(err, core.ErrTxTypeInvalid): + case errors.Is(err, core.ErrTxTypeNotSupported): // Pop the unsupported transaction without shifting in the next from the account log.Trace("Skipping unsupported transaction type", "sender", from, "type", tx.Type()) txs.Pop() diff --git a/rlp/decode.go b/rlp/decode.go index 79b7ef062664..a28041791482 100644 --- a/rlp/decode.go +++ b/rlp/decode.go @@ -741,6 +741,18 @@ func (s *Stream) ListEnd() error { return nil } +func (s *Stream) ListRemaining() (uint64, error) { + if len(s.stack) == 0 { + return 0, errNotInList + } + tos := s.stack[len(s.stack)-1] + if tos.pos != tos.size { + return tos.size - tos.pos, nil + } else { + return 0, nil + } +} + // Decode decodes a value and stores the result in the value pointed // to by val. Please see the documentation for the Decode function // to learn about the decoding rules. diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index fd4adfb97678..82ee01de15c8 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -45,7 +45,7 @@ type ttFork struct { } func (tt *TransactionTest) Run(config *params.ChainConfig) error { - validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead bool, isIstanbul bool, isYoloV2 bool) (*common.Address, *common.Hash, error) { + validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead bool, isIstanbul bool) (*common.Address, *common.Hash, error) { tx := new(types.Transaction) if err := rlp.DecodeBytes(rlpData, tx); err != nil { return nil, nil, err @@ -55,7 +55,7 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { return nil, nil, err } // Intrinsic gas - requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, isYoloV2) + requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul) if err != nil { return nil, nil, err } @@ -72,17 +72,16 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { fork ttFork isHomestead bool isIstanbul bool - isYoloV2 bool }{ - {"Frontier", types.FrontierSigner{}, tt.Frontier, false, false, false}, - {"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false, false}, - {"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false, false}, - {"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false, false}, - {"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false, false}, - {"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false, false}, - {"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true, false}, + {"Frontier", types.FrontierSigner{}, tt.Frontier, false, false}, + {"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false}, + {"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false}, + {"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false}, + {"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false}, + {"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false}, + {"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true}, } { - sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul, testcase.isYoloV2) + sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul) if testcase.fork.Sender == (common.UnprefixedAddress{}) { if err == nil { From 4ea3eeba422752edd04c68675e575831673d6670 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 10 Nov 2020 16:12:04 +0100 Subject: [PATCH 03/83] core/types: tests for accesslist transactions core/types: revert inadvertent changes core: update comments core/types: sign over rlp list of typed tx core/types: clarify comment core/tx_pool: init pool with 2718 signer core/types/transaction_signing: make sender derivation more readable core/types/transaction_test: fix incorrect error text rlp/decode: remove erroneously added method core/types: update cross client access list tests core/types: fix misspelling in comment core/types: don't check chainid before determining if protected core/types: comment out acl test generator for ci core/types: test acl-blocks with json-files core/types: more tests + regenerate receipt json parser core: change txpool status indicator from yolov2 to eip2718 core: fix block tests for 2718 --- core/blockchain_test.go | 134 ++++++ core/state_processor.go | 4 - core/testdata/acl_block_0.json | 42 ++ core/testdata/acl_block_1.json | 65 +++ core/testdata/acl_block_2.json | 102 ++++ core/testdata/acl_block_3.json | 153 ++++++ core/testdata/acl_block_4.json | 218 +++++++++ core/testdata/acl_block_5.json | 297 ++++++++++++ core/testdata/acl_block_6.json | 390 ++++++++++++++++ core/testdata/acl_block_7.json | 497 ++++++++++++++++++++ core/testdata/acl_block_8.json | 618 ++++++++++++++++++++++++ core/testdata/acl_block_9.json | 753 ++++++++++++++++++++++++++++++ core/testdata/acl_genesis.json | 39 ++ core/tx_pool.go | 13 +- core/types/block.go | 12 +- core/types/block_test.go | 5 + core/types/gen_receipt_json.go | 6 + core/types/transaction.go | 5 +- core/types/transaction_signing.go | 56 +-- core/types/transaction_test.go | 124 +++-- rlp/decode.go | 12 - 21 files changed, 3436 insertions(+), 109 deletions(-) create mode 100644 core/testdata/acl_block_0.json create mode 100644 core/testdata/acl_block_1.json create mode 100644 core/testdata/acl_block_2.json create mode 100644 core/testdata/acl_block_3.json create mode 100644 core/testdata/acl_block_4.json create mode 100644 core/testdata/acl_block_5.json create mode 100644 core/testdata/acl_block_6.json create mode 100644 core/testdata/acl_block_7.json create mode 100644 core/testdata/acl_block_8.json create mode 100644 core/testdata/acl_block_9.json create mode 100644 core/testdata/acl_genesis.json diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 92899540167d..d882af40b161 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -17,6 +17,7 @@ package core import ( + "encoding/json" "errors" "fmt" "io/ioutil" @@ -37,6 +38,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" ) @@ -3031,6 +3033,11 @@ func TestInitThenFailCreateContract(t *testing.T) { } } +// TestEIP2718Transition tests that an EIP-2718 transaction will be accepted +// after the fork block has passed. This is verified by sending an EIP-2930 +// access list transaction, which specifies a single slot access, and then +// checking that the gas usage of a hot SLOAD and a cold SLOAD are calculated +// correctly. func TestEIP2718Transition(t *testing.T) { var ( aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") @@ -3100,3 +3107,130 @@ func TestEIP2718Transition(t *testing.T) { } } + +type blockTest struct { + Header *types.Header `json:"header"` + Txs []*types.Transaction `json:"transactions"` + Uncles []*types.Header `json:"uncles"` + Receipts []*types.Receipt `json:"receipts"` +} +type jsonFormat struct { + Rlp string `json:"rlp"` + Json blockTest `json:"json"` +} + +//XTestGenerateACLJsonFiles creates files in ./testdata/ , to be used for cross-client +//testing +func XTestGenerateACLJsonFilesEip2718(t *testing.T) { + var ( + aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") + // Generate a canonical chain to act as the main dataset + engine = ethash.NewFaker() + db = rawdb.NewMemoryDatabase() + // A sender who makes transactions, has some funds + key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + address = crypto.PubkeyToAddress(key.PublicKey) + funds = big.NewInt(1000000000) + gspec = &Genesis{ + Config: params.YoloV2ChainConfig, + Alloc: GenesisAlloc{ + address: {Balance: funds}, + // The address 0xAAAA sloads 0x00 and 0x01 + aa: { + Code: []byte{ + byte(vm.PC), byte(vm.PC), + byte(vm.SLOAD), byte(vm.SLOAD), + }, + Nonce: 0, + Balance: big.NewInt(0), + }, + }, + } + genesis = gspec.MustCommit(db) + signer = types.NewEIP2718Signer(gspec.Config.ChainID) + nonce uint64 = 0 + ) + var signTx = func(tx *types.Transaction) *types.Transaction { + t.Helper() + signed, err := types.SignTx(tx, signer, key) + if err != nil { + t.Fatal(err) + } + nonce++ + return signed + } + var mkAclTx = func(aclCount int) *types.Transaction { + t.Helper() + var accesses types.AccessList + for ii := 0; ii < aclCount; ii++ { + accesses = append(accesses, types.AccessTuple{ + Address: &common.Address{byte(ii)}, + StorageKeys: []*common.Hash{{0}, {byte(ii)}}, + }) + } + return signTx(types.NewAccessListTransaction(gspec.Config.ChainID, nonce, + aa, big.NewInt(0), 123457, big.NewInt(10), nil, &accesses)) + } + var mkLegacyTx = func(i int) *types.Transaction { + t.Helper() + return signTx(types.NewTransaction(nonce, aa, big.NewInt(0), 123457, big.NewInt(10), nil)) + } + + blocks, _ := GenerateChain(gspec.Config, genesis, engine, db, 10, func(i int, b *BlockGen) { + b.SetCoinbase(common.Address{1}) + // Add n acl transactions + for ii := 0; ii < i; ii++ { + b.AddTx(mkAclTx(i)) + } + // Add one legacy tx + b.AddTx(mkLegacyTx(i)) + }) + // Import the canonical chain + diskdb := rawdb.NewMemoryDatabase() + gspec.MustCommit(diskdb) + + chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) + if err != nil { + t.Fatalf("failed to create tester chain: %v", err) + } + if n, err := chain.InsertChain(blocks); err != nil { + t.Fatalf("block %d: failed to insert into chain: %v", n, err) + } + // export the genesis + { + x, err := json.MarshalIndent(gspec, "", " ") + if err != nil { + t.Fatal(err) + } + outFile, err := os.Create("testdata/acl_genesis.json") + outFile.Write(x) + if err != nil { + t.Fatal(err) + } + outFile.Close() + } + // Export the chain + for i, block := range blocks { + rlpData, err := rlp.EncodeToBytes(block) + if err != nil { + t.Fatal(err) + } + jsonData, err := json.MarshalIndent(&jsonFormat{ + Rlp: fmt.Sprintf("%x", rlpData), + Json: blockTest{ + Header: block.Header(), + Txs: block.Transactions(), + Uncles: block.Uncles(), + }}, + "", " ") + if err != nil { + t.Fatal(err) + } + outFile, err := os.Create(fmt.Sprintf("testdata/acl_block_%d.json", i)) + if err != nil { + t.Fatal(err) + } + defer outFile.Close() + outFile.Write(jsonData) + } +} diff --git a/core/state_processor.go b/core/state_processor.go index 099b079c9a78..21d6d78b3b29 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -89,10 +89,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg return receipts, allLogs, *usedGas, nil } -// ApplyTransaction attempts to apply a transaction to the given state database -// and uses the input parameters for its environment. It returns the receipt -// for the transaction, gas used and an error if the transaction failed, -// indicating the block was invalid. func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { if !config.IsYoloV2(header.Number) && tx.Type() != types.LegacyTxId { return nil, ErrTxTypeNotSupported diff --git a/core/testdata/acl_block_0.json b/core/testdata/acl_block_0.json new file mode 100644 index 000000000000..6e71d89f22f9 --- /dev/null +++ b/core/testdata/acl_block_0.json @@ -0,0 +1,42 @@ +{ + "rlp": "f90263f901f5a0151b04645af991f513d5e11f8ed62e12b73f080af9c7a6a3d98fd6b1503f23faa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0968408b8a2f170bc78230cc2fac3881120a93f7392cf26b609566d8648abfd79a0e8137f2b67ac4680d8103f8b1cd7c05c49f56e4df464b0a79253679f38df9ab4a07f53535270d749f41b9d783aa1abcfceb73cc2a16ecde789cd3bc97a42fbda2ab901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018347e7c48262740a80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f868f866800a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec88a0e7545c5664e63873d7aeb4bb5f92152c3366a9095c9140e5f8453af0998194bea04d24143ac9bc97c0aa07a7074c12ab60484d83d3b447b1e5e6ba5cbf421675bfc0", + "json": { + "header": { + "parentHash": "0x151b04645af991f513d5e11f8ed62e12b73f080af9c7a6a3d98fd6b1503f23fa", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0x968408b8a2f170bc78230cc2fac3881120a93f7392cf26b609566d8648abfd79", + "transactionsRoot": "0xe8137f2b67ac4680d8103f8b1cd7c05c49f56e4df464b0a79253679f38df9ab4", + "receiptsRoot": "0x7f53535270d749f41b9d783aa1abcfceb73cc2a16ecde789cd3bc97a42fbda2a", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x1", + "gasLimit": "0x47e7c4", + "gasUsed": "0x6274", + "timestamp": "0xa", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0x9aa9cdb2afc4ebf893c32b67dedf1dea4291673bf4e80d3227a4e7f8d0feaf68" + }, + "transactions": [ + { + "type": "0x0", + "chainId": null, + "nonce": "0x0", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec88", + "r": "0xe7545c5664e63873d7aeb4bb5f92152c3366a9095c9140e5f8453af0998194be", + "s": "0x4d24143ac9bc97c0aa07a7074c12ab60484d83d3b447b1e5e6ba5cbf421675bf", + "hash": "0x7e122173adcc02b9a3c94da426f65c7d46e724e8e3fdb16be73d5e0405e280b6" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_1.json b/core/testdata/acl_block_1.json new file mode 100644 index 000000000000..614ef3733369 --- /dev/null +++ b/core/testdata/acl_block_1.json @@ -0,0 +1,65 @@ +{ + "rlp": "f9032df901f5a09aa9cdb2afc4ebf893c32b67dedf1dea4291673bf4e80d3227a4e7f8d0feaf68a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0fb70f6c0512e7979903607bba8a4f1b18c2dd1060a8eff1b777a2182d05af524a0dfcad019a36acdf0f3fac6b3db02bf1d70012a0bd3eadabea87b856be9a6f1cca0a7a57ba954834e69b55d9115305f14f7faff9beb83443f7bb5526585848c6aefb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000028347e7c482dd201480a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f90131b8c701f8c486796f6c6f7632010a8301e24194000000000000000000000000000000000000aaaa8080f85bf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000001a0a9efa6b5fd3c2f210c4ec7232058d8dd30c93a456b4f6074429fb09bbd73eb4fa070632eff8bf0933381917c9161a98494e34fc7b836ee150445cae9ab151d267bf866020a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec88a055a39da3ce02c75e976ad84f608771080811a5ef322c6b6536c362f716c60985a018ab5df4198436eacd0e991f59bdeb8da9a75c678067db6b1a4d07881555c7a8c0", + "json": { + "header": { + "parentHash": "0x9aa9cdb2afc4ebf893c32b67dedf1dea4291673bf4e80d3227a4e7f8d0feaf68", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0xfb70f6c0512e7979903607bba8a4f1b18c2dd1060a8eff1b777a2182d05af524", + "transactionsRoot": "0xdfcad019a36acdf0f3fac6b3db02bf1d70012a0bd3eadabea87b856be9a6f1cc", + "receiptsRoot": "0xa7a57ba954834e69b55d9115305f14f7faff9beb83443f7bb5526585848c6aef", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x2", + "gasLimit": "0x47e7c4", + "gasUsed": "0xdd20", + "timestamp": "0x14", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0xe1807e7366284bc72d34c8f02318f81c6598454dbff4c6cdd71e872cd8d5748c" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x1", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0xa9efa6b5fd3c2f210c4ec7232058d8dd30c93a456b4f6074429fb09bbd73eb4f", + "s": "0x70632eff8bf0933381917c9161a98494e34fc7b836ee150445cae9ab151d267b", + "hash": "0x1916413ac8d1d5ee4eda786e5fe29509a109910f800894e0e18eb84abb7564cb" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x2", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec88", + "r": "0x55a39da3ce02c75e976ad84f608771080811a5ef322c6b6536c362f716c60985", + "s": "0x18ab5df4198436eacd0e991f59bdeb8da9a75c678067db6b1a4d07881555c7a8", + "hash": "0x54c6cfb51cbbe2c562e17a0d6ee1324f1b50013a9b9d47589cedcf0ec4ac342a" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_2.json b/core/testdata/acl_block_2.json new file mode 100644 index 000000000000..1d9d84f06902 --- /dev/null +++ b/core/testdata/acl_block_2.json @@ -0,0 +1,102 @@ +{ + "rlp": "f904b1f901f6a0e1807e7366284bc72d34c8f02318f81c6598454dbff4c6cdd71e872cd8d5748ca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a025e5b4b7668760c0aa01d44c061d77e24b53f6d247d3e1d85a91e23646c1d679a0be53a36dd90786b4cd30fb0f3677ad3ce5f804a5615872a7b0512b6be82639a2a076946d9f034a6657c6832a6ad4df3ef0ddf3fa9f3f8be98ea64880fb23bd23e3b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000038347e7c48301883c1e80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f902b4b9012301f9011f86796f6c6f7632030a8301e24194000000000000000000000000000000000000aaaa8080f8b6f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0010000000000000000000000000000000000000000000000000000000000000001a0635c44b8110989ef84c77de11a377f19cbd84660559ed76b37ba0f7fdee1fb40a012e1576d168301614720c68f1a9e9d5ed20e23622dab6c3587b11177155d59f4b9012301f9011f86796f6c6f7632040a8301e24194000000000000000000000000000000000000aaaa8080f8b6f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0010000000000000000000000000000000000000000000000000000000000000001a00380e446bf3992ee1df44b8177a11e948dc52cc3faa8eae059a52b7183126c0fa05206f0f35648d3b8f23092d4d7bdccb926967d840a269cf65b706a8a359b9029f866050a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0ea5de382dbf422aa1bd156547a2bc3a9357d745a68cdc9203b14812307068567a0388f7425b873ae204d43d91f4997ca41d2af6759be49538b174a06f67d5741b5c0", + "json": { + "header": { + "parentHash": "0xe1807e7366284bc72d34c8f02318f81c6598454dbff4c6cdd71e872cd8d5748c", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0x25e5b4b7668760c0aa01d44c061d77e24b53f6d247d3e1d85a91e23646c1d679", + "transactionsRoot": "0xbe53a36dd90786b4cd30fb0f3677ad3ce5f804a5615872a7b0512b6be82639a2", + "receiptsRoot": "0x76946d9f034a6657c6832a6ad4df3ef0ddf3fa9f3f8be98ea64880fb23bd23e3", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x3", + "gasLimit": "0x47e7c4", + "gasUsed": "0x1883c", + "timestamp": "0x1e", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0x1615129d2aa7b437cd40e3aa1a5794af9e40b07b9b017014e4123cefeef785ce" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x3", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x635c44b8110989ef84c77de11a377f19cbd84660559ed76b37ba0f7fdee1fb40", + "s": "0x12e1576d168301614720c68f1a9e9d5ed20e23622dab6c3587b11177155d59f4", + "hash": "0x54471f503901f2c2fe392e43df0377a11f9a1cd9cde0ec5c68c89eac1723e02a" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x4", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x380e446bf3992ee1df44b8177a11e948dc52cc3faa8eae059a52b7183126c0f", + "s": "0x5206f0f35648d3b8f23092d4d7bdccb926967d840a269cf65b706a8a359b9029", + "hash": "0xe3a1354e84d22ebbca0c55751937b075083f0f0e3a47c65fc7249d86f872f268" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x5", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec87", + "r": "0xea5de382dbf422aa1bd156547a2bc3a9357d745a68cdc9203b14812307068567", + "s": "0x388f7425b873ae204d43d91f4997ca41d2af6759be49538b174a06f67d5741b5", + "hash": "0x44b1e9999ac02a3b0daf1391be16bb00a262079706418697094bab5f37b522d7" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_3.json b/core/testdata/acl_block_3.json new file mode 100644 index 000000000000..e44fee7d7835 --- /dev/null +++ b/core/testdata/acl_block_3.json @@ -0,0 +1,153 @@ +{ + "rlp": "f906ebf901f6a01615129d2aa7b437cd40e3aa1a5794af9e40b07b9b017014e4123cefeef785cea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0e2c895d53740e942c84623e1612189e72eea9e767b150cc0d8802b490f2574b2a060b6fa13cd50ea3732f59eb726368639dea2006ab4b67dc5730ea27b0cd75732a058ac726e0fc55cd550539c38baf3f6023615e2657ceedccc21ce7edd6516bc31b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000048347e7c4830263c82880a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f904eeb9017f01f9017b86796f6c6f7632060a8301e24194000000000000000000000000000000000000aaaa8080f90111f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0020000000000000000000000000000000000000000000000000000000000000001a0587b3fd59a84469be7c918ae73047141027d27c47cc63f3cf13c6161bf92efaaa0453d3cd2dffd1f048a58fb1046917327f5e95cc8aedc47f82d41bffebfe31bbdb9017f01f9017b86796f6c6f7632070a8301e24194000000000000000000000000000000000000aaaa8080f90111f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0020000000000000000000000000000000000000000000000000000000000000080a0b1944f4797bf4da4d041a66be9c41c317b40d158894103ccd50de5e4ca174b4aa079d6834c013b40d0039ca6755cecc72938461e5b8cd8d3619ddcdfb15c15b866b9017f01f9017b86796f6c6f7632080a8301e24194000000000000000000000000000000000000aaaa8080f90111f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0020000000000000000000000000000000000000000000000000000000000000001a0793cd38309611e0117269275243fc3761fe233dc371918e450b547c70132c033a07276d4b20788938ca0ff7e4e921aec7739103dc73d3b953f47947ef194720757f866090a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec88a0a6528544064aef10d166e16d3968ae83aa29161beb57f2756dfd1151682adbe7a0507fe2d475ffab209e718345a3ad9fb20fee6e15a8c4980df3ed8ff0a714367ac0", + "json": { + "header": { + "parentHash": "0x1615129d2aa7b437cd40e3aa1a5794af9e40b07b9b017014e4123cefeef785ce", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0xe2c895d53740e942c84623e1612189e72eea9e767b150cc0d8802b490f2574b2", + "transactionsRoot": "0x60b6fa13cd50ea3732f59eb726368639dea2006ab4b67dc5730ea27b0cd75732", + "receiptsRoot": "0x58ac726e0fc55cd550539c38baf3f6023615e2657ceedccc21ce7edd6516bc31", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x4", + "gasLimit": "0x47e7c4", + "gasUsed": "0x263c8", + "timestamp": "0x28", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0xc6340ac0a1b76cae78479a4bc6211031550719fa9b58ae42d773dce7ff7409ce" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x6", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x587b3fd59a84469be7c918ae73047141027d27c47cc63f3cf13c6161bf92efaa", + "s": "0x453d3cd2dffd1f048a58fb1046917327f5e95cc8aedc47f82d41bffebfe31bbd", + "hash": "0xbc9b06b5d31e6e257a3c25048e935ba433c68fdd5fa5d0ddd726d5ab7356aafd" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x7", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xb1944f4797bf4da4d041a66be9c41c317b40d158894103ccd50de5e4ca174b4a", + "s": "0x79d6834c013b40d0039ca6755cecc72938461e5b8cd8d3619ddcdfb15c15b866", + "hash": "0x474ec2766068f9e9d0548aca3769ca406fdde21ba87c254d9230c18be35fe99a" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x8", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x793cd38309611e0117269275243fc3761fe233dc371918e450b547c70132c033", + "s": "0x7276d4b20788938ca0ff7e4e921aec7739103dc73d3b953f47947ef194720757", + "hash": "0xe46963eb63cd75a120990ca597532020bc2dcefc4588025c0d50901681a7aae9" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x9", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec88", + "r": "0xa6528544064aef10d166e16d3968ae83aa29161beb57f2756dfd1151682adbe7", + "s": "0x507fe2d475ffab209e718345a3ad9fb20fee6e15a8c4980df3ed8ff0a714367a", + "hash": "0x61fc16fea6b57d81f269e733cdd15d994bbc10dc6e9b0acbedbe32e6fe70a06c" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_4.json b/core/testdata/acl_block_4.json new file mode 100644 index 000000000000..321596243099 --- /dev/null +++ b/core/testdata/acl_block_4.json @@ -0,0 +1,218 @@ +{ + "rlp": "f909d9f901f6a0c6340ac0a1b76cae78479a4bc6211031550719fa9b58ae42d773dce7ff7409cea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a08bea5accbb5e586ad84279f37b06ccd9cec79f9547e1c34545a361b61117ca66a05266aab4415ef7659530a0baa876d3ab26aff199f13b97084aed767412cf0f88a08899161ab693e740c3ee7323e114f575342c83f25fd7bda246bc1e5722e0b98cb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000058347e7c483036fc43280a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f907dcb901da01f901d686796f6c6f76320a0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000080a07e073e922b0f9195abdd479c2b988c00d3565063baaecbb5bc03d45ec611cbaca07e2d47eb81702ceefbf765d6283586b09c2e9fe2b02ffeea13c72efdd5425aa7b901da01f901d686796f6c6f76320b0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000080a0ad1eb53988eba191181ab17026bc73bfa5744c7feb385ff50c1d135262b4b550a06e0fde038fe6bb5e6a03724e5ed67b76bac528425fa6a31364f498d418c96343b901da01f901d686796f6c6f76320c0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000001a0b819a58c2bd8516b9afbb2410e16de4e4243e8c67ac6901211a931f2f39ff2e2a0053e42e62d88ef4174f01eebe5f3177f4eae4ab0bceaa44f638550678068518eb901da01f901d686796f6c6f76320d0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000001a0dcb383f7cbd502d0d61c5daa2894011476c260daf07f150b52bd8e753929d458a049c149cca5a3e7ee659a1c3205980215d0148369309b8678ea88056f9c4e69a9f8660e0a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0f8305a294ad8c2928246ff9dc008296bec497d70653962a0e17da9cea8618034a05a6ae3809c6fad8ad302100d58d4e08eef51e25634ceb55eee5a07a837e75e03c0", + "json": { + "header": { + "parentHash": "0xc6340ac0a1b76cae78479a4bc6211031550719fa9b58ae42d773dce7ff7409ce", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0x8bea5accbb5e586ad84279f37b06ccd9cec79f9547e1c34545a361b61117ca66", + "transactionsRoot": "0x5266aab4415ef7659530a0baa876d3ab26aff199f13b97084aed767412cf0f88", + "receiptsRoot": "0x8899161ab693e740c3ee7323e114f575342c83f25fd7bda246bc1e5722e0b98c", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x5", + "gasLimit": "0x47e7c4", + "gasUsed": "0x36fc4", + "timestamp": "0x32", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0x43335db66263d3d83223a37683ddd526ee3b81bdcd3ec1a477894b7659e31df5" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0xa", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x7e073e922b0f9195abdd479c2b988c00d3565063baaecbb5bc03d45ec611cbac", + "s": "0x7e2d47eb81702ceefbf765d6283586b09c2e9fe2b02ffeea13c72efdd5425aa7", + "hash": "0x0f4f39a875669b88862f40083726c9c38bb2bd12b787dc59f3840f9a2aa9dad1" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0xb", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xad1eb53988eba191181ab17026bc73bfa5744c7feb385ff50c1d135262b4b550", + "s": "0x6e0fde038fe6bb5e6a03724e5ed67b76bac528425fa6a31364f498d418c96343", + "hash": "0x19f8ea997fa31ab0379efc68fd9b09283dbdd0ed46141f21b4f692c4adb31f1e" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0xc", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0xb819a58c2bd8516b9afbb2410e16de4e4243e8c67ac6901211a931f2f39ff2e2", + "s": "0x53e42e62d88ef4174f01eebe5f3177f4eae4ab0bceaa44f638550678068518e", + "hash": "0xee900bcfba7a74d9e45568af7f8db691c39a357f5088b64bbf4c18bd1e4241bb" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0xd", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0xdcb383f7cbd502d0d61c5daa2894011476c260daf07f150b52bd8e753929d458", + "s": "0x49c149cca5a3e7ee659a1c3205980215d0148369309b8678ea88056f9c4e69a9", + "hash": "0xa74fcf06517f9561b55d31ce00afbaa4f53772291af96521872640e38da51525" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0xe", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec87", + "r": "0xf8305a294ad8c2928246ff9dc008296bec497d70653962a0e17da9cea8618034", + "s": "0x5a6ae3809c6fad8ad302100d58d4e08eef51e25634ceb55eee5a07a837e75e03", + "hash": "0x96739f62b1e4583c97fc3ce618f4490fcb8667186826b99ee18ca3d4e3252136" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_5.json b/core/testdata/acl_block_5.json new file mode 100644 index 000000000000..8df508e133da --- /dev/null +++ b/core/testdata/acl_block_5.json @@ -0,0 +1,297 @@ +{ + "rlp": "f90d7df901f6a043335db66263d3d83223a37683ddd526ee3b81bdcd3ec1a477894b7659e31df5a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a03445ee9a221c8bd9c3a797ef91fe8aa41239a6404a649f289fefd7965d5f6b3da0fa6a9116e469a63a136448d15dd4415bb6c42cd6824a7453788bcf86639b3343a069895a3818b4067d65cbb9b94c3e9caade084f303e10aadcbd4ed2337d6f7e37b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000068347e7c48304ac303c80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f90b80b9023501f9023186796f6c6f76320f0a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a0f84927e5d33e51a97efeeae35148a17aebee690b543f863d55aa0b98cf62803aa01f44785c907379109661088df919b456a0cbcf0d72900237faedc3b2746556c3b9023501f9023186796f6c6f7632100a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a08e2a80d3a51965fd3bf3375329d98bae924f21b84ab1948f822e238a688270d7a051fc270b2b6bebb3a718e06f7a1772029042ce938ec741a9623f5283e84b8442b9023501f9023186796f6c6f7632110a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000001a05541f7da809ec62ec9643748b6d8a64411388f6c1999c8f6a067fae224b7497ca04ce552578d1619c80b14e6f95f472bb7e242b3fdcac449415a58150473feecefb9023501f9023186796f6c6f7632120a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a01f872d6fb4eb7398254fe7811cf405fcbc11b83ea61f50c26feec13c62527ad0a026acd00dbbd0eef10a7c213e616df22f3a9fd1d61d31ed0abb257e0efc8abf06b9023501f9023186796f6c6f7632130a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a03fb9c1360e7a1a9cf45efed449c609b585df3b2ecfa5eb67eecba63c55699f11a072ef40cefb4fbfe2f54df284741effb28c2cf25128e3aec5003d9809c2e82d01f866140a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0a68b33f12348a1053208c0783d7504f90a58da7f9ca2ead1275526cce7d700bda019c01948a0479c1a3774a203686acc9727830503fab6fdeed06b69e60b93755fc0", + "json": { + "header": { + "parentHash": "0x43335db66263d3d83223a37683ddd526ee3b81bdcd3ec1a477894b7659e31df5", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0x3445ee9a221c8bd9c3a797ef91fe8aa41239a6404a649f289fefd7965d5f6b3d", + "transactionsRoot": "0xfa6a9116e469a63a136448d15dd4415bb6c42cd6824a7453788bcf86639b3343", + "receiptsRoot": "0x69895a3818b4067d65cbb9b94c3e9caade084f303e10aadcbd4ed2337d6f7e37", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x6", + "gasLimit": "0x47e7c4", + "gasUsed": "0x4ac30", + "timestamp": "0x3c", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0x00acaefd90b8d42561f10a6e20a23b94f045aa26d7134fabfbc34e5ff1c4e6d5" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0xf", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xf84927e5d33e51a97efeeae35148a17aebee690b543f863d55aa0b98cf62803a", + "s": "0x1f44785c907379109661088df919b456a0cbcf0d72900237faedc3b2746556c3", + "hash": "0xc0ec239a159d9e67d986161ce20d8852e7c70c4e57c27c5fe28ae8fab1038a23" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x10", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x8e2a80d3a51965fd3bf3375329d98bae924f21b84ab1948f822e238a688270d7", + "s": "0x51fc270b2b6bebb3a718e06f7a1772029042ce938ec741a9623f5283e84b8442", + "hash": "0xd4b78fd3de465b52bfbce75278243c0c211d7ff466eda2e4d2c8c4939616c34b" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x11", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x5541f7da809ec62ec9643748b6d8a64411388f6c1999c8f6a067fae224b7497c", + "s": "0x4ce552578d1619c80b14e6f95f472bb7e242b3fdcac449415a58150473feecef", + "hash": "0xbbf1c7cb4e14723a928ca4bc73890ee9449203cd71d987075cb468212e4cf213" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x12", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x1f872d6fb4eb7398254fe7811cf405fcbc11b83ea61f50c26feec13c62527ad0", + "s": "0x26acd00dbbd0eef10a7c213e616df22f3a9fd1d61d31ed0abb257e0efc8abf06", + "hash": "0xb50bdbaa03ec0bddb84f4d9076385d53e4382cb5045dc1f172dce5f60064313c" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x13", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x3fb9c1360e7a1a9cf45efed449c609b585df3b2ecfa5eb67eecba63c55699f11", + "s": "0x72ef40cefb4fbfe2f54df284741effb28c2cf25128e3aec5003d9809c2e82d01", + "hash": "0x8f6cbdeadca58cca5c2d42b7f39d1806db196a4932785eea9c67d644664abb7c" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x14", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec87", + "r": "0xa68b33f12348a1053208c0783d7504f90a58da7f9ca2ead1275526cce7d700bd", + "s": "0x19c01948a0479c1a3774a203686acc9727830503fab6fdeed06b69e60b93755f", + "hash": "0x75376d730e7b5186a1e3e4e32c022308a2d66391f99dff2d59cf39e038b885c7" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_6.json b/core/testdata/acl_block_6.json new file mode 100644 index 000000000000..1e50f53f25db --- /dev/null +++ b/core/testdata/acl_block_6.json @@ -0,0 +1,390 @@ +{ + "rlp": "f911d6f901f6a000acaefd90b8d42561f10a6e20a23b94f045aa26d7134fabfbc34e5ff1c4e6d5a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0acb9bda9ea5166689f2f8f67f60f64318ee0c7aed856eea3bb4249c5f2ad5a58a08af39529cb5c3295713bfac629dc4cc1bde29a12516e83a7cb8b202dea6f9cfca015eecb22e64ad01d793e4d4ff4ddd217d68f454307f933772da76f4ac75b667fb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000078347e7c48306190c4680a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f90fd9b9029001f9028c86796f6c6f7632150a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000001a08a7ce0cf467cf9d04698c542fc7b7ef55651236b567a1dfed8dfc20f008f95d9a02ed15779e036579cd66a997a5ccb9626063fabe129d1a0f84d1addb8f3e30fbcb9028f01f9028b86796f6c6f7632160a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000809f051a77732323ba3f1e6442bff54782d2b80c30be64e1f74fec63eb74e3dadca05ee7edef5e1314dc96391cc67961785d37c597fb428a2498bd242c3dcd52a8f3b9029001f9028c86796f6c6f7632170a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000001a03ad054d140cb8053f42ac9df18fabb57a781a3132cee7d3bc98fcc380e6a1cc6a069c8972ded2412fb79a9dcb676daf6804aa5c7ebd3ff1aedd2a8481731506341b9029001f9028c86796f6c6f7632180a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000080a073ead15ab6ed0d83080db28bf82b89a80e7ecd74880f9a73fe0b8804882b2606a063458665267cffbe0ecfb343aad3559166c4e4c3c1e14eead7f3457fb3ea75eab9029001f9028c86796f6c6f7632190a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000080a04ac58f1d695790cc5156fcebfcf0cf8da35849c91fcc2cd05407055a675419aea05ebaa55e4a32ac00aefc8ca57cc0e36c3b1b4743f5b7274e49a11d6b9cc3047cb9029001f9028c86796f6c6f76321a0a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000080a0e38d4c971e4723dcac613f59975c5ea9b1200bc2b1569b820ddb6766eec521dea07a8f1d82a92f9937039cfe305a13ca54a8e6f22da2839430cfaeba4af65c2427f8661b0a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a075f7b1ed94b4206c1c8aa19422b4e8e9aaff7ad643a41364072880112e0785b4a0185475d900d76df4bf16a218f10ba336b7041134c90da33a0a16c6406564ba46c0", + "json": { + "header": { + "parentHash": "0x00acaefd90b8d42561f10a6e20a23b94f045aa26d7134fabfbc34e5ff1c4e6d5", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0xacb9bda9ea5166689f2f8f67f60f64318ee0c7aed856eea3bb4249c5f2ad5a58", + "transactionsRoot": "0x8af39529cb5c3295713bfac629dc4cc1bde29a12516e83a7cb8b202dea6f9cfc", + "receiptsRoot": "0x15eecb22e64ad01d793e4d4ff4ddd217d68f454307f933772da76f4ac75b667f", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x7", + "gasLimit": "0x47e7c4", + "gasUsed": "0x6190c", + "timestamp": "0x46", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0x2bb50258633ccfdf3f5b07258e3c9866ed9f878a7582230569d4ffc45952a66c" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x15", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x8a7ce0cf467cf9d04698c542fc7b7ef55651236b567a1dfed8dfc20f008f95d9", + "s": "0x2ed15779e036579cd66a997a5ccb9626063fabe129d1a0f84d1addb8f3e30fbc", + "hash": "0xef6960cc8cbb52be918b8e91c3574e8f07c714d2baf7320ffe2c71e20cd39103" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x16", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x51a77732323ba3f1e6442bff54782d2b80c30be64e1f74fec63eb74e3dadc", + "s": "0x5ee7edef5e1314dc96391cc67961785d37c597fb428a2498bd242c3dcd52a8f3", + "hash": "0x910bc3ffde097228c2d20d787bd90b9e277f987ea6972ff659503f8a074b78ff" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x17", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x3ad054d140cb8053f42ac9df18fabb57a781a3132cee7d3bc98fcc380e6a1cc6", + "s": "0x69c8972ded2412fb79a9dcb676daf6804aa5c7ebd3ff1aedd2a8481731506341", + "hash": "0x66dd5793d6ecbd978c41a5d15556f1a16a03fd15149809badab65f8f0b6809c7" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x18", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x73ead15ab6ed0d83080db28bf82b89a80e7ecd74880f9a73fe0b8804882b2606", + "s": "0x63458665267cffbe0ecfb343aad3559166c4e4c3c1e14eead7f3457fb3ea75ea", + "hash": "0xeba7afbdf52f13058232961a6d35b76a2901c32622da72daf20bee4362a457a0" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x19", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x4ac58f1d695790cc5156fcebfcf0cf8da35849c91fcc2cd05407055a675419ae", + "s": "0x5ebaa55e4a32ac00aefc8ca57cc0e36c3b1b4743f5b7274e49a11d6b9cc3047c", + "hash": "0xce8deb76b2475215931a1b5afd4deca2ba9f706bee21ca1e68671ed90177f785" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x1a", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xe38d4c971e4723dcac613f59975c5ea9b1200bc2b1569b820ddb6766eec521de", + "s": "0x7a8f1d82a92f9937039cfe305a13ca54a8e6f22da2839430cfaeba4af65c2427", + "hash": "0x6de8e432fa9a3d8320397c7bece78828a47311a2a055a98e855aa4868bd8e351" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x1b", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec87", + "r": "0x75f7b1ed94b4206c1c8aa19422b4e8e9aaff7ad643a41364072880112e0785b4", + "s": "0x185475d900d76df4bf16a218f10ba336b7041134c90da33a0a16c6406564ba46", + "hash": "0x0dc4c78b1636726787970269ff17c855444e1d27eee8c0fd516e51176f574f71" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_7.json b/core/testdata/acl_block_7.json new file mode 100644 index 000000000000..1194aabc55c6 --- /dev/null +++ b/core/testdata/acl_block_7.json @@ -0,0 +1,497 @@ +{ + "rlp": "f916e7f901f6a02bb50258633ccfdf3f5b07258e3c9866ed9f878a7582230569d4ffc45952a66ca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0a55899fdbfa99a7feaabb51608ce4b0c2912596f2229ffeacb2ef05fb55b71b7a0e28fe6b703978af3d2eda206f6f959e2d833afaf418028a9503271f4f20a40d9a03f8954dac53eb0caa13809bae6c1bbfb729aa10778ac528e62113114b758e633b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000088347e7c48307b6585080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f914eab902eb01f902e786796f6c6f76321c0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a0643459a4e9aba8d232302442f95e7f6d89b06f273443a8710f9bb55496df1994a06e3f8765c4f399486454c64cf54b1396df2812c7d5fdcadb47a66f83ec553cd5b902eb01f902e786796f6c6f76321d0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000001a09862a3737fe1d45c7b256ff22a50d567b88c04212b39396ab41a1e9c62d4f44ea04c797c4b78681cc16aea9a18e59923264c744c17d9861560693473f927c28f54b902eb01f902e786796f6c6f76321e0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a08e24d4c713f644e38223cd600c56c65fd64d74fa3c1659ebf2ef719284c74802a00412a2733ba0c5fa7da40dc6b199351f0c04ed4c455607546d25d6efbc3e9a12b902eb01f902e786796f6c6f76321f0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a0fc7721a6ca78e74eaadbbbbbfd6fa990fd9993a29a6d552f5c12d7256feebaa5a0166a3b40a0e0d86b95dac8a83dd1f0eb61f107bcb6f670cc114c3dd67f193d01b902eb01f902e786796f6c6f7632200a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a0d1dac5d229b36766e7cc6a3d87596c6b72c1b579cccdc62a5b4438a04a46d3fea0053a8afe9e411247a65370e1d4e83cdcec9dc41a0b595999f3e41b07be014d10b902eb01f902e786796f6c6f7632210a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000001a0251ab5147fb99b3c222fc99157ef6a6603659c2465bb9bb2662679fce6c12077a03c4ed0c45754fc479583126bf2d88c0bf323310f2f946f3bbeee44e73bf744c0b902eb01f902e786796f6c6f7632220a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000001a0664de330a9c9b3e4041e347332a30d0f88358063de52c6cefcc5a8ce397f96f3a013ea85012f7a62739610e48ea51e170275c56f0f8d1896520f1ef84d4f3e389ef866230a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0a3bdc8174d2fbe9c404ff490e77555039f1c37bddbe60d8e60c1228f9964f02da015572f4a595159746f9f11554059312ccdbc05e6bf8831469338bb78dcb43b5ac0", + "json": { + "header": { + "parentHash": "0x2bb50258633ccfdf3f5b07258e3c9866ed9f878a7582230569d4ffc45952a66c", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0xa55899fdbfa99a7feaabb51608ce4b0c2912596f2229ffeacb2ef05fb55b71b7", + "transactionsRoot": "0xe28fe6b703978af3d2eda206f6f959e2d833afaf418028a9503271f4f20a40d9", + "receiptsRoot": "0x3f8954dac53eb0caa13809bae6c1bbfb729aa10778ac528e62113114b758e633", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x8", + "gasLimit": "0x47e7c4", + "gasUsed": "0x7b658", + "timestamp": "0x50", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0xfa221b6492050cfc24b906b20ce208b3dc4ba841e564395f2900c4a175158a1e" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x1c", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x643459a4e9aba8d232302442f95e7f6d89b06f273443a8710f9bb55496df1994", + "s": "0x6e3f8765c4f399486454c64cf54b1396df2812c7d5fdcadb47a66f83ec553cd5", + "hash": "0x21840bf8b516a15569f253f9b7900d052f86f9173b02a240ccbddbc38f912498" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x1d", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x9862a3737fe1d45c7b256ff22a50d567b88c04212b39396ab41a1e9c62d4f44e", + "s": "0x4c797c4b78681cc16aea9a18e59923264c744c17d9861560693473f927c28f54", + "hash": "0x5ed7369fea0e90818ced675a993efa699628286583417244fb136a4f73a2e90f" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x1e", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x8e24d4c713f644e38223cd600c56c65fd64d74fa3c1659ebf2ef719284c74802", + "s": "0x412a2733ba0c5fa7da40dc6b199351f0c04ed4c455607546d25d6efbc3e9a12", + "hash": "0x24c0cd928e6bce21401dce170c98a80acd33ef4c6c6be3d0ea58127c0a049185" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x1f", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xfc7721a6ca78e74eaadbbbbbfd6fa990fd9993a29a6d552f5c12d7256feebaa5", + "s": "0x166a3b40a0e0d86b95dac8a83dd1f0eb61f107bcb6f670cc114c3dd67f193d01", + "hash": "0x755cc55d927e952bff7e51f70471c7a8b53cbbb76e855d0fe6148afc099967f8" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x20", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xd1dac5d229b36766e7cc6a3d87596c6b72c1b579cccdc62a5b4438a04a46d3fe", + "s": "0x53a8afe9e411247a65370e1d4e83cdcec9dc41a0b595999f3e41b07be014d10", + "hash": "0xabd736140ee8fe129b0db888c7808298e015be3f52cf530bfb064828b9801806" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x21", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x251ab5147fb99b3c222fc99157ef6a6603659c2465bb9bb2662679fce6c12077", + "s": "0x3c4ed0c45754fc479583126bf2d88c0bf323310f2f946f3bbeee44e73bf744c0", + "hash": "0x1c71ff8b515e449b4597ba4e08f4bd1558716e5253e9fb62c117a01f0c859124" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x22", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x664de330a9c9b3e4041e347332a30d0f88358063de52c6cefcc5a8ce397f96f3", + "s": "0x13ea85012f7a62739610e48ea51e170275c56f0f8d1896520f1ef84d4f3e389e", + "hash": "0x698566ee27aac8dda0c7bfd0b3e5b9c122a9ac81053dce700b3ef9fa156b35f7" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x23", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec87", + "r": "0xa3bdc8174d2fbe9c404ff490e77555039f1c37bddbe60d8e60c1228f9964f02d", + "s": "0x15572f4a595159746f9f11554059312ccdbc05e6bf8831469338bb78dcb43b5a", + "hash": "0x95aa3328bed08bb31056e79cdb10c890d3c645493c928e4546a2d65b821380ca" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_8.json b/core/testdata/acl_block_8.json new file mode 100644 index 000000000000..9437772de135 --- /dev/null +++ b/core/testdata/acl_block_8.json @@ -0,0 +1,618 @@ +{ + "rlp": "f91cadf901f6a0fa221b6492050cfc24b906b20ce208b3dc4ba841e564395f2900c4a175158a1ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0b38b2ff96bb62a36840bd31e6b02a1ded156d8f571b35eef02d08f311fe03f65a08876562acbd95cb180c7599816bd6c954f8feadf02891b7c41b6369fb31c2e1ea0b78dc917392b3a6757a3545c29f0300f401c1d07303215ad0d4023a170a1c99fb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000098347e7c4830984145a80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f91ab0b9034601f9034286796f6c6f7632240a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0d9c848f01ea535491946502971d8abd4640243394078a51efa4577c690910027a046c1247d86cb8b09209974eb3e667c82b81307c622124099c93a46811509dca6b9034601f9034286796f6c6f7632250a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000001a07595a92f015a9aeba3135f9fd3bcf743f058503f7e9dbc470d195d35bcb4eaa3a050cf2c39959208961f5bf9b890ec98473c631ba668b41455ed91c8711bc5c7b2b9034601f9034286796f6c6f7632260a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0949a0a2f11aa9958d32c9e4d734497ed74dd851d57b28981f606e5be517a2f56a05493ccac5f48b724388a824ee3df6c0c54922faea0ed911cd6e7993d72e105b0b9034601f9034286796f6c6f7632270a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a03eae4a21a7648d2b33940a601a37bc24eb1f0472611a3321867edf423970db98a02a87c17c6c8116a0df110e51da727d953569e5f48f61d80f6e7aa67ee88491d0b9034601f9034286796f6c6f7632280a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a07fcccf7db8f6f715b4467798328ecd812de95a9e00b16064108f220c131b1feba00b32d45c342f74907d7999a4bfc13b2bc0f6dee4336fdfb4847e182f80204785b9034601f9034286796f6c6f7632290a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0b25c865ca6bd22c9dc046adc53d7419d9696a13f16baf97593672f2033c200c1a061b26c60cfa8af36154a4555c20501c30af193104a779ac20266e8a09da30b6bb9034601f9034286796f6c6f76322a0a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0f97719ddd5d72d9269b5fe95b7646cc2719d67824a7784bea322afdcd79ce119a022e4250977257258c863fcb766b88494b884750fa6023db8410fac8a0a100eadb9034601f9034286796f6c6f76322b0a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a073c0c49e7f0c7c4343c80d726733c06810b8efeee8907f2fc65519258a93fa67a0140d4d304c84d40e85e98eb5f073698f9f0d44f9051c25e98aa3da1f975cb771f8662c0a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a04a8911c73aa392f7472d0f3b8de07c06df21cec19b50eb5b913f2b4d4e9b3d6aa00a9d8d20c17644f8db37b6a2f00dc330a8c3c09f5fc5aa065f2410e3a3340a9dc0", + "json": { + "header": { + "parentHash": "0xfa221b6492050cfc24b906b20ce208b3dc4ba841e564395f2900c4a175158a1e", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0xb38b2ff96bb62a36840bd31e6b02a1ded156d8f571b35eef02d08f311fe03f65", + "transactionsRoot": "0x8876562acbd95cb180c7599816bd6c954f8feadf02891b7c41b6369fb31c2e1e", + "receiptsRoot": "0xb78dc917392b3a6757a3545c29f0300f401c1d07303215ad0d4023a170a1c99f", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0x9", + "gasLimit": "0x47e7c4", + "gasUsed": "0x98414", + "timestamp": "0x5a", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0x84dda3788f42b7e41a084407d725a58c201ce7cfadd97e886cb976dda22c9921" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x24", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xd9c848f01ea535491946502971d8abd4640243394078a51efa4577c690910027", + "s": "0x46c1247d86cb8b09209974eb3e667c82b81307c622124099c93a46811509dca6", + "hash": "0xaf54d730700aef32f551db22595085bf45e85e605d75484e89a727527e96129b" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x25", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x7595a92f015a9aeba3135f9fd3bcf743f058503f7e9dbc470d195d35bcb4eaa3", + "s": "0x50cf2c39959208961f5bf9b890ec98473c631ba668b41455ed91c8711bc5c7b2", + "hash": "0xde28554defa0795db3c147bda91a23ffcb30b80cf26f28ab96d6ead60a69d2b9" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x26", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x949a0a2f11aa9958d32c9e4d734497ed74dd851d57b28981f606e5be517a2f56", + "s": "0x5493ccac5f48b724388a824ee3df6c0c54922faea0ed911cd6e7993d72e105b0", + "hash": "0x285d3401abaa281c502acc4bf59ec59a6c7bce62f9a46bfc6b3100b97152f528" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x27", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x3eae4a21a7648d2b33940a601a37bc24eb1f0472611a3321867edf423970db98", + "s": "0x2a87c17c6c8116a0df110e51da727d953569e5f48f61d80f6e7aa67ee88491d0", + "hash": "0x85c6d289b56245b7b6e4ccdd514e2b6792c9f3e956ea4968d69593a3030f4499" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x28", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x7fcccf7db8f6f715b4467798328ecd812de95a9e00b16064108f220c131b1feb", + "s": "0xb32d45c342f74907d7999a4bfc13b2bc0f6dee4336fdfb4847e182f80204785", + "hash": "0x846c5fce7829817683d7be03b6f08f39ef79dbeed0ec64e1901962f8d83ddedd" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x29", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xb25c865ca6bd22c9dc046adc53d7419d9696a13f16baf97593672f2033c200c1", + "s": "0x61b26c60cfa8af36154a4555c20501c30af193104a779ac20266e8a09da30b6b", + "hash": "0xeddbe8867f8555f92fdd42d03872467509551a645f7bd92a050fbabaf506865c" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x2a", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xf97719ddd5d72d9269b5fe95b7646cc2719d67824a7784bea322afdcd79ce119", + "s": "0x22e4250977257258c863fcb766b88494b884750fa6023db8410fac8a0a100ead", + "hash": "0x026824663c75c144366419e4448cb29453f70d891245e0264bf94c9478bc28ae" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x2b", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x73c0c49e7f0c7c4343c80d726733c06810b8efeee8907f2fc65519258a93fa67", + "s": "0x140d4d304c84d40e85e98eb5f073698f9f0d44f9051c25e98aa3da1f975cb771", + "hash": "0x877c3067e2ead44ec4be1d4dcda3571213325d93291f32c3f674cff01947cf0a" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x2c", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec87", + "r": "0x4a8911c73aa392f7472d0f3b8de07c06df21cec19b50eb5b913f2b4d4e9b3d6a", + "s": "0xa9d8d20c17644f8db37b6a2f00dc330a8c3c09f5fc5aa065f2410e3a3340a9d", + "hash": "0xca741c6398b7e3bfdafc46c3c97ac22a8c1002744231e1702c0bbc2245d2ba34" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_block_9.json b/core/testdata/acl_block_9.json new file mode 100644 index 000000000000..8b6059a6fe45 --- /dev/null +++ b/core/testdata/acl_block_9.json @@ -0,0 +1,753 @@ +{ + "rlp": "f92329f901f6a084dda3788f42b7e41a084407d725a58c201ce7cfadd97e886cb976dda22c9921a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a091503e4466860227794cecc7e441abc9bad4ef57114c08af408cb6bf58980235a0de7408c49f9332211cbf0ea0d6d6697ee9ebef4b9cb53869168834956153d45ca0c18851ede636a1298652a8dd6bffb065e7c198417660bf20f97731be93d46cefb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200000a8347e7c4830b82406480a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f9212cb903a101f9039d86796f6c6f76322d0a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a0cc5c7d6d2250816d5cebafe393914fd6ff39702ef9647d907c196c4240858446a068082151d6d9fbe47e3fed849328dce66ab6b0976a106d0a5423b18b0be201e2b903a101f9039d86796f6c6f76322e0a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a005620469222dcdb8378eecec565b89c69d653397b14160ff49052ac67699150ea06f343d9c86ee05ff23f562d5b21f763a34ecf00cda60b267f9dc124661dd69c7b903a101f9039d86796f6c6f76322f0a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000080a072b8ee28e31595dc01388151d9a293a832dfca58c22d48d8c24681e5e52b95f0a0156cd769bbcafaca1ce2691542aafc05ec3156dee26988d780e2915f67415437b903a101f9039d86796f6c6f7632300a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a022ffc9f0594be343e16e448e15aa2298f097c88c8e951020e9055f70537e6cbba022d8161cd97590d9fdfe61bc0ce34face1a221f6d9a50c96ffc185c7b6eb1a33b903a101f9039d86796f6c6f7632310a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000080a0e9834fd907d82587ac1c3d1f4998fbe914142834ec86e34293e11d22279eb6f4a0594a4a7b79798e466e41125fcfa9c08e548a4f6bba7bab3a17769d6cd15d4926b903a101f9039d86796f6c6f7632320a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a0cad758b73761dc79fbe62ea6ecae306c2f8a9a614bddd2ee379f9924ecf26d9ba006d5955b0769de282012278bf43d83bbee144dc61893d2d0f1daad9463af9677b903a101f9039d86796f6c6f7632330a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a01bd327017a42d3bdce1b192716c730eda6b990d9f12ee14286872daa5a36ecf8a0407ec3dd532be0377aa774e6352fa12e15f1ce8e09a39a520449b2a6bbf2d0aab903a101f9039d86796f6c6f7632340a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000080a001a2f42cdd339b157cd736cade0641489bf345f6bc0a657075d329797a9ef331a0696ca3e566854a52d4b6514fcfddf796dfa18762ce350d86d14612b0e177ccc2b903a101f9039d86796f6c6f7632350a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a02f63a43500e78623d38149a0bd2a331c616202312aff7d4047ee080c02139e7aa021d1a2144e9fea759d3e650a91f576b9a502c4a84cab745f8c9b8e15618c33cdf866360a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0ed4c15a3ff67c17eef207d8e7beef31af80a63ab8e03738c10f1483f7e8f6203a0495d2bea850f073e20c79fbef96ccab6ca3367059e3fa4704f8f22f48dc318cac0", + "json": { + "header": { + "parentHash": "0x84dda3788f42b7e41a084407d725a58c201ce7cfadd97e886cb976dda22c9921", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0100000000000000000000000000000000000000", + "stateRoot": "0x91503e4466860227794cecc7e441abc9bad4ef57114c08af408cb6bf58980235", + "transactionsRoot": "0xde7408c49f9332211cbf0ea0d6d6697ee9ebef4b9cb53869168834956153d45c", + "receiptsRoot": "0xc18851ede636a1298652a8dd6bffb065e7c198417660bf20f97731be93d46cef", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x20000", + "number": "0xa", + "gasLimit": "0x47e7c4", + "gasUsed": "0xb8240", + "timestamp": "0x64", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "hash": "0xd8e7665bdcb0b053e18bc9dc565765b3c93aaf3938d03a6b24df816dbc44f5df" + }, + "transactions": [ + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x2d", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0xcc5c7d6d2250816d5cebafe393914fd6ff39702ef9647d907c196c4240858446", + "s": "0x68082151d6d9fbe47e3fed849328dce66ab6b0976a106d0a5423b18b0be201e2", + "hash": "0xf59de76965a4c6ab43ba656320bcc151c1c5b2dd3e9c61077bfada88c60f9d91" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x2e", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x5620469222dcdb8378eecec565b89c69d653397b14160ff49052ac67699150e", + "s": "0x6f343d9c86ee05ff23f562d5b21f763a34ecf00cda60b267f9dc124661dd69c7", + "hash": "0xf9800f0463832ba38394196d74415d925b0fe48a6accc44fce76294cef1c6542" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x2f", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x72b8ee28e31595dc01388151d9a293a832dfca58c22d48d8c24681e5e52b95f0", + "s": "0x156cd769bbcafaca1ce2691542aafc05ec3156dee26988d780e2915f67415437", + "hash": "0x8d7f71e167aed00e7f98a3d6efef0455a915affcff0b6d96ac26e65bb65a6ce9" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x30", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x22ffc9f0594be343e16e448e15aa2298f097c88c8e951020e9055f70537e6cbb", + "s": "0x22d8161cd97590d9fdfe61bc0ce34face1a221f6d9a50c96ffc185c7b6eb1a33", + "hash": "0x478e063e01971fa8990da37b2709d4b7f53c3724df94d9bdf685cc1c3eafb459" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x31", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0xe9834fd907d82587ac1c3d1f4998fbe914142834ec86e34293e11d22279eb6f4", + "s": "0x594a4a7b79798e466e41125fcfa9c08e548a4f6bba7bab3a17769d6cd15d4926", + "hash": "0x6e6eb6cfc365c3ee3e4b575d92844c7742505b62aa3d5765a41bcf7f61d787b1" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x32", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0xcad758b73761dc79fbe62ea6ecae306c2f8a9a614bddd2ee379f9924ecf26d9b", + "s": "0x6d5955b0769de282012278bf43d83bbee144dc61893d2d0f1daad9463af9677", + "hash": "0x79de88fa2ac7f1ef13e596f9c4732fd06eaa968b5afd9fd6efa9564ddedd04e4" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x33", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x1bd327017a42d3bdce1b192716c730eda6b990d9f12ee14286872daa5a36ecf8", + "s": "0x407ec3dd532be0377aa774e6352fa12e15f1ce8e09a39a520449b2a6bbf2d0aa", + "hash": "0x849ad53627a411a79641b82d23f40f76544ef7cc185518560810c02cd163dddf" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x34", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x1a2f42cdd339b157cd736cade0641489bf345f6bc0a657075d329797a9ef331", + "s": "0x696ca3e566854a52d4b6514fcfddf796dfa18762ce350d86d14612b0e177ccc2", + "hash": "0xbae361665e925aa04f59f41a7f23bac56bd69ca40262cb55afc6a9446aa12f77" + }, + { + "type": "0x1", + "chainId": "0x796f6c6f7632", + "nonce": "0x35", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0100000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0100000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0200000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0200000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0300000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0300000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0400000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0400000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0500000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0500000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0600000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0600000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0700000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0700000000000000000000000000000000000000000000000000000000000000" + ] + }, + { + "address": "0x0800000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0800000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x1", + "r": "0x2f63a43500e78623d38149a0bd2a331c616202312aff7d4047ee080c02139e7a", + "s": "0x21d1a2144e9fea759d3e650a91f576b9a502c4a84cab745f8c9b8e15618c33cd", + "hash": "0x8d7a600d5de038029800c6d10b5dbd5ace67324fd75dfe3e31f5b48ce6a19b9c" + }, + { + "type": "0x0", + "chainId": null, + "nonce": "0x36", + "gasPrice": "0xa", + "gas": "0x1e241", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x0", + "input": "0x", + "accessList": null, + "v": "0xf2ded8deec87", + "r": "0xed4c15a3ff67c17eef207d8e7beef31af80a63ab8e03738c10f1483f7e8f6203", + "s": "0x495d2bea850f073e20c79fbef96ccab6ca3367059e3fa4704f8f22f48dc318ca", + "hash": "0xefe1036e9043183eb61a8042ca97c8260da7eb2ef1d6969d9404e1e6ec48f490" + } + ], + "uncles": null, + "receipts": null + } +} \ No newline at end of file diff --git a/core/testdata/acl_genesis.json b/core/testdata/acl_genesis.json new file mode 100644 index 000000000000..3fc5f4948bea --- /dev/null +++ b/core/testdata/acl_genesis.json @@ -0,0 +1,39 @@ +{ + "config": { + "chainId": 133519467574834, + "homesteadBlock": 0, + "daoForkSupport": true, + "eip150Block": 0, + "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "yoloV2Block": 0, + "clique": { + "period": 15, + "epoch": 30000 + } + }, + "nonce": "0x0", + "timestamp": "0x0", + "extraData": "0x", + "gasLimit": "0x0", + "difficulty": null, + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "000000000000000000000000000000000000aaaa": { + "code": "0x58585454", + "balance": "0x0" + }, + "71562b71999873db5b286df957af199ec94617f7": { + "balance": "0x3b9aca00" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" +} \ No newline at end of file diff --git a/core/tx_pool.go b/core/tx_pool.go index e66695649ce2..e8241eb9e1df 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -229,7 +229,7 @@ type TxPool struct { mu sync.RWMutex istanbul bool // Fork indicator whether we are in the istanbul stage. - yoloV2 bool // Fork indicator whether we are in the YoloV2 stage. + eip2718 bool // Fork indicator whether we are using EIp-2718 type transactions. currentState *state.StateDB // Current state in the blockchain head pendingNonces *txNoncer // Pending state tracking virtual nonces @@ -269,7 +269,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block config: config, chainconfig: chainconfig, chain: chain, - signer: types.NewEIP155Signer(chainconfig.ChainID), + signer: types.NewEIP2718Signer(chainconfig.ChainID), pending: make(map[common.Address]*txList), queue: make(map[common.Address]*txList), beats: make(map[common.Address]time.Time), @@ -282,9 +282,6 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block reorgShutdownCh: make(chan struct{}), gasPrice: new(big.Int).SetUint64(config.PriceLimit), } - if chainconfig.IsYoloV2(chain.CurrentBlock().Number()) { - pool.signer = types.NewEIP2718Signer(chainconfig.ChainID) - } pool.locals = newAccountSet(pool.signer) for _, addr := range config.Locals { log.Info("Setting new local account", "address", addr) @@ -540,11 +537,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrGasLimit } // Accept only legacy transactions if before yoloV2. - if tx.Type() != types.LegacyTxId && !pool.yoloV2 { + if tx.Type() != types.LegacyTxId && !pool.eip2718 { return ErrTxTypeNotSupported } // After yoloV2, accept both legacy transactions and access list transactions. - if pool.yoloV2 && (tx.Type() != types.LegacyTxId && tx.Type() != types.AccessListTxId) { + if pool.eip2718 && (tx.Type() != types.LegacyTxId && tx.Type() != types.AccessListTxId) { return ErrTxTypeNotSupported } // Make sure the transaction is signed properly @@ -1211,7 +1208,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) { // Update all fork indicator by next pending block number. next := new(big.Int).Add(newHead.Number, big.NewInt(1)) pool.istanbul = pool.chainconfig.IsIstanbul(next) - pool.yoloV2 = pool.chainconfig.IsYoloV2(next) + pool.eip2718 = pool.chainconfig.IsYoloV2(next) } // promoteExecutables moves transactions that have become processable from the diff --git a/core/types/block.go b/core/types/block.go index 310a913b225e..8096ebb75516 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -147,16 +147,6 @@ func rlpHash(x interface{}) (h common.Hash) { return h } -func typedRlpHash(typ uint8, x interface{}) (h common.Hash) { - sha := hasherPool.Get().(crypto.KeccakState) - defer hasherPool.Put(sha) - sha.Reset() - sha.Write([]byte{typ}) - rlp.Encode(sha, x) - sha.Read(h[:]) - return h -} - // EmptyBody returns true if there is no additional 'body' to complete the header // that is: no transactions and no uncles. func (h *Header) EmptyBody() bool { @@ -179,7 +169,7 @@ type Body struct { type Block struct { header *Header uncles []*Header - transactions []*Transaction + transactions Transactions // caches hash atomic.Value diff --git a/core/types/block_test.go b/core/types/block_test.go index ed6c81672248..1e19102e689c 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -18,9 +18,14 @@ package types import ( "bytes" + "encoding/json" + "fmt" "hash" + "io/ioutil" "math/big" + "os" "reflect" + "strings" "testing" "github.com/ethereum/go-ethereum/common" diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index 790ed65b5817..9a4b836ff37f 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -16,6 +16,7 @@ var _ = (*receiptMarshaling)(nil) // MarshalJSON marshals as JSON. func (r Receipt) MarshalJSON() ([]byte, error) { type Receipt struct { + Type uint8 `json:"type,omitempty"` PostState hexutil.Bytes `json:"root"` Status hexutil.Uint64 `json:"status"` CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` @@ -29,6 +30,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) { TransactionIndex hexutil.Uint `json:"transactionIndex"` } var enc Receipt + enc.Type = r.Type enc.PostState = r.PostState enc.Status = hexutil.Uint64(r.Status) enc.CumulativeGasUsed = hexutil.Uint64(r.CumulativeGasUsed) @@ -46,6 +48,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals from JSON. func (r *Receipt) UnmarshalJSON(input []byte) error { type Receipt struct { + Type *uint8 `json:"type,omitempty"` PostState *hexutil.Bytes `json:"root"` Status *hexutil.Uint64 `json:"status"` CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` @@ -62,6 +65,9 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if err := json.Unmarshal(input, &dec); err != nil { return err } + if dec.Type != nil { + r.Type = *dec.Type + } if dec.PostState != nil { r.PostState = *dec.PostState } diff --git a/core/types/transaction.go b/core/types/transaction.go index e7cbaf6f74a8..cc754c536d1d 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -207,6 +207,9 @@ func (tx *Transaction) Size() common.StorageSize { tx.size.Store(common.StorageSize(c)) return common.StorageSize(c) } + +// WithSignature returns a new transaction with the given signature. +// This signature needs to be in the [R || S || V] format where V is 0 or 1. func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error) { r, s, v, err := signer.SignatureValues(tx, sig) if err != nil { @@ -274,7 +277,7 @@ func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { return tx.inner // Raw transactions are used for internal processes which need the raw // consensus representation of typed transactions, not the RLP string -// wrapped version. +// wrapped version (e.g. type || payload vs. rlp(type || payload)). type rawtx Transaction func (tx *rawtx) EncodeRLP(w io.Writer) error { diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 365e51b2c061..373594172c81 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -113,25 +113,23 @@ func NewEIP2718Signer(chainId *big.Int) EIP2718Signer { } // Sender returns the recovered addressed from a transaction's signature. -// It assumes V does not store the chain id, unless the tx is of legacy type. func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { - if !tx.Protected() { - return HomesteadSigner{}.Sender(tx) - } - if tx.ChainId().Cmp(s.chainId) != 0 { - return common.Address{}, ErrInvalidChainId - } - V, R, S := tx.RawSignatureValues() - if tx.Type() == LegacyTxId { + if !tx.Protected() { + return HomesteadSigner{}.Sender(tx) + } V = new(big.Int).Sub(V, s.chainIdMul) V.Sub(V, big8) } if tx.Type() == AccessListTxId { + // ACL txs are defined to use 0 and 1 as their recovery id, add + // 27 to become equivalent to unprotected Homestead signatures. V = new(big.Int).Add(V, big.NewInt(27)) } - + if tx.ChainId().Cmp(s.chainId) != 0 { + return common.Address{}, ErrInvalidChainId + } return recoverPlain(s.Hash(tx), R, S, V, true) } @@ -154,9 +152,9 @@ func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *bi // Hash returns the hash to be signed by the sender. // It does not uniquely identify the transaction. func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { - var h common.Hash - if tx.typ == LegacyTxId { - h = rlpHash([]interface{}{ + switch tx.typ { + case LegacyTxId: + return rlpHash([]interface{}{ tx.Nonce(), tx.GasPrice(), tx.Gas(), @@ -165,23 +163,25 @@ func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { tx.Data(), s.chainId, uint(0), uint(0), }) - } else if tx.typ == AccessListTxId { - h = typedRlpHash( + case AccessListTxId: + return rlpHash([]interface{}{ tx.Type(), - []interface{}{ - tx.ChainId(), - tx.Nonce(), - tx.GasPrice(), - tx.Gas(), - tx.To(), - tx.Value(), - tx.Data(), - tx.AccessList(), - }, - ) + tx.ChainId(), + tx.Nonce(), + tx.GasPrice(), + tx.Gas(), + tx.To(), + tx.Value(), + tx.Data(), + tx.AccessList(), + }) + default: + // This _should_ not happen, but in case someone sends in a bad + // json struct via RPC, it's probably more prudent to return an + // empty hash instead of killing the node with a panic + //panic("Unsupported transaction type: %d", tx.typ) + return common.Hash{} } - - return h } // EIP155Transaction implements Signer using the EIP155 rules. diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 519a53a74657..9fe37349d36f 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -20,7 +20,9 @@ import ( "bytes" "crypto/ecdsa" "encoding/json" + "fmt" "math/big" + "reflect" "testing" "time" @@ -73,7 +75,7 @@ var ( nil, ).WithSignature( NewEIP2718Signer(big.NewInt(1)), - common.Hex2Bytes("da9ad262d794b71067f1530b19314045ed4cf961e6a8ef393e244eaf2721fe016ee9a433a359987bfe5cc28361759a6e1fe94a15e15e4bdf36364e29af12d00400"), + common.Hex2Bytes("c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b266032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d3752101"), ) ) @@ -94,16 +96,16 @@ func TestTransactionEncode(t *testing.T) { } should := common.FromHex("f86103018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255441ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3") if !bytes.Equal(txb, should) { - t.Errorf("encoded EIP-2718 transaction RLP mismatch, got %x", txb) + t.Errorf("encoded RLP mismatch, got %x", txb) } } func TestEIP2718TransactionSigHash(t *testing.T) { s := NewEIP2718Signer(big.NewInt(1)) - if s.Hash(emptyEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") { + if s.Hash(emptyEip2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", s.Hash(emptyEip2718Tx)) } - if s.Hash(signedEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") { + if s.Hash(signedEip2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { t.Errorf("signed EIP-2718 transaction hash mismatch, got %x", s.Hash(signedEip2718Tx)) } } @@ -113,7 +115,7 @@ func TestEIP2718TransactionEncode(t *testing.T) { if err != nil { t.Fatalf("encode error: %v", err) } - should := common.FromHex("b86601f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c080a0da9ad262d794b71067f1530b19314045ed4cf961e6a8ef393e244eaf2721fe01a06ee9a433a359987bfe5cc28361759a6e1fe94a15e15e4bdf36364e29af12d004") + should := common.FromHex("b86601f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b2660a032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d37521") if !bytes.Equal(txb, should) { t.Errorf("encoded RLP mismatch, got %x", txb) } @@ -265,59 +267,91 @@ func TestTransactionTimeSort(t *testing.T) { } } -// TestTransactionJSON tests serializing/de-serializing to/from JSON. -func TestTransactionJSON(t *testing.T) { +func encodeDecodeJSON(tx *Transaction) (*Transaction, error) { + data, err := json.Marshal(tx) + if err != nil { + return nil, fmt.Errorf("json encoding failed: %v", err) + } + var parsedTx = &Transaction{} + if err := json.Unmarshal(data, &parsedTx); err != nil { + return nil, fmt.Errorf("json decoding failed: %v", err) + } + return parsedTx, nil +} + +func encodeDecodeRLP(tx *Transaction) (*Transaction, error) { + data, err := rlp.EncodeToBytes(tx) + if err != nil { + return nil, fmt.Errorf("rlp encoding failed: %v", err) + } + var parsedTx = &Transaction{} + if err := rlp.DecodeBytes(data, parsedTx); err != nil { + return nil, fmt.Errorf("rlp decoding failed: %v", err) + } + return parsedTx, nil +} + +func assertEqual(orig *Transaction, cpy *Transaction) error { + // compare nonce, price, gaslimit, recipient, amount, payload, V, R, S + if want, got := orig.Hash(), cpy.Hash(); want != got { + return fmt.Errorf("parsed tx differs from original tx, want %v, got %v", want, got) + } + if want, got := orig.ChainId(), cpy.ChainId(); want.Cmp(got) != 0 { + return fmt.Errorf("invalid chain id, want %d, got %d", want, got) + } + if orig.AccessList() != nil { + if !reflect.DeepEqual(orig.AccessList(), cpy.AccessList()) { + return fmt.Errorf("access list wrong!") + } + } + return nil +} + +// TestTransactionCoding tests serializing/de-serializing to/from rlp and JSON. +func TestTransactionCoding(t *testing.T) { key, err := crypto.GenerateKey() if err != nil { t.Fatalf("could not generate key: %v", err) } - signer := NewEIP2718Signer(common.Big1) - - transactions := make([]*Transaction, 0, 50) - for i := uint64(0); i < 25; i++ { - var tx *Transaction - switch i % 3 { + var ( + signer = NewEIP2718Signer(common.Big1) + rawTx *Transaction + addr = common.HexToAddress("0x0000000000000000000000000000000000000001") + accesses = AccessList{ + AccessTuple{ + Address: &addr, + StorageKeys: []*common.Hash{{0}}, + }, + } + ) + for i := uint64(0); i < 500; i++ { + switch i % 6 { case 0: - tx = NewTransaction(i, common.Address{1}, common.Big0, 1, common.Big2, []byte("abcdef")) + rawTx = NewTransaction(i, common.Address{1}, common.Big0, 1, common.Big2, []byte("abcdef")) case 1: - tx = NewContractCreation(i, common.Big0, 1, common.Big2, []byte("abcdef")) + rawTx = NewContractCreation(i, common.Big0, 1, common.Big2, []byte("abcdef")) case 2: - addr := common.HexToAddress("0x0000000000000000000000000000000000000001") - accesses := AccessList{AccessTuple{ - Address: &addr, - StorageKeys: []*common.Hash{ - {0}, - }, - }} - tx = NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) + rawTx = NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) + case 4: + rawTx = NewAccessListContractCreation(big.NewInt(1), 0, big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) + case 5: + rawTx = NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, nil) } - transactions = append(transactions, tx) - - signedTx, err := SignTx(tx, signer, key) + tx, err := SignTx(rawTx, signer, key) if err != nil { t.Fatalf("could not sign transaction: %v", err) } - - transactions = append(transactions, signedTx) - } - - for _, tx := range transactions { - data, err := json.Marshal(tx) + // RLP + parsedTx, err := encodeDecodeRLP(tx) if err != nil { - t.Fatalf("json.Marshal failed: %v", err) - } - - var parsedTx *Transaction - if err := json.Unmarshal(data, &parsedTx); err != nil { - t.Fatalf("json.Unmarshal failed: %v", err) + t.Fatal(err) } - - // compare nonce, price, gaslimit, recipient, amount, payload, V, R, S - if tx.Hash() != parsedTx.Hash() { - t.Errorf("parsed tx differs from original tx, want %v, got %v", tx, parsedTx) - } - if tx.ChainId().Cmp(parsedTx.ChainId()) != 0 { - t.Errorf("invalid chain id, want %d, got %d", tx.ChainId(), parsedTx.ChainId()) + assertEqual(parsedTx, tx) + // JSON + parsedTx, err = encodeDecodeJSON(tx) + if err != nil { + t.Fatal(err) } + assertEqual(parsedTx, tx) } } diff --git a/rlp/decode.go b/rlp/decode.go index a28041791482..79b7ef062664 100644 --- a/rlp/decode.go +++ b/rlp/decode.go @@ -741,18 +741,6 @@ func (s *Stream) ListEnd() error { return nil } -func (s *Stream) ListRemaining() (uint64, error) { - if len(s.stack) == 0 { - return 0, errNotInList - } - tos := s.stack[len(s.stack)-1] - if tos.pos != tos.size { - return tos.size - tos.pos, nil - } else { - return 0, nil - } -} - // Decode decodes a value and stores the result in the value pointed // to by val. Please see the documentation for the Decode function // to learn about the decoding rules. From a457ae9ff1e16a55323953bcd4506866dc0d8c25 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 12 Jan 2021 14:31:24 +0100 Subject: [PATCH 04/83] accounts/keystore, internal/ethapi: implement ethapi support for acl transactions, make dev engine use 2930 --- accounts/keystore/keystore.go | 4 +- internal/ethapi/api.go | 69 +++++++++++++++++++++++++++-------- params/config.go | 2 +- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index 9d5e2cf6a2a7..5ea059c3d68f 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -283,9 +283,9 @@ func (ks *KeyStore) SignTx(a accounts.Account, tx *types.Transaction, chainID *b if !found { return nil, ErrLocked } - // Depending on the presence of the chain ID, sign with EIP155 or homestead + // Depending on the presence of the chain ID, sign with 2718 or homestead if chainID != nil { - return types.SignTx(tx, types.NewEIP155Signer(chainID), unlockedKey.PrivateKey) + return types.SignTx(tx, types.NewEIP2718Signer(chainID), unlockedKey.PrivateKey) } return types.SignTx(tx, types.HomesteadSigner{}, unlockedKey.PrivateKey) } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 0df2c7e7b3c3..76a389be67c1 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -748,12 +748,13 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A // CallArgs represents the arguments for a call. type CallArgs struct { - From *common.Address `json:"from"` - To *common.Address `json:"to"` - Gas *hexutil.Uint64 `json:"gas"` - GasPrice *hexutil.Big `json:"gasPrice"` - Value *hexutil.Big `json:"value"` - Data *hexutil.Bytes `json:"data"` + From *common.Address `json:"from"` + To *common.Address `json:"to"` + Gas *hexutil.Uint64 `json:"gas"` + GasPrice *hexutil.Big `json:"gasPrice"` + Value *hexutil.Big `json:"value"` + Data *hexutil.Bytes `json:"data"` + AccessList *types.AccessList `json:"accessList"` } // ToMessage converts CallArgs to the Message type used by the core evm @@ -790,8 +791,7 @@ func (args *CallArgs) ToMessage(globalGasCap uint64) types.Message { if args.Data != nil { data = *args.Data } - - msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, nil, false) + msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, args.AccessList, false) return msg } @@ -872,6 +872,27 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo // Setup the gas pool (also for unmetered requests) // and apply the message. gp := new(core.GasPool).AddGas(math.MaxUint64) + // TODO! Refactor this check to some better place -- right now it's copy-pasted + // all over the place + if evm.ChainConfig().IsYoloV2(header.Number) { + state.AddAddressToAccessList(msg.From()) + if dst := msg.To(); dst != nil { + state.AddAddressToAccessList(*dst) + // If it's a create-tx, the destination will be added inside evm.create + } + for _, addr := range evm.ActivePrecompiles() { + state.AddAddressToAccessList(addr) + } + if al := msg.AccessList(); al != nil { + for _, el := range *al { + state.AddAddressToAccessList(*el.Address) + for _, key := range el.StorageKeys { + state.AddSlotToAccessList(*el.Address, *key) + } + } + } + } + result, err := core.ApplyMessage(evm, msg, gp) if err := vmError(); err != nil { return nil, err @@ -1473,6 +1494,10 @@ type SendTxArgs struct { // newer name and should be preferred by clients. Data *hexutil.Bytes `json:"data"` Input *hexutil.Bytes `json:"input"` + + // For non-legacy transactions + AccessList *types.AccessList `json:"accessList,omitempty"` + ChainID *hexutil.Big `json:"chainId,omitempty"` } // setDefaults is a helper function that fills in default values for unspecified tx fields. @@ -1518,11 +1543,12 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error { input = args.Data } callArgs := CallArgs{ - From: &args.From, // From shouldn't be nil - To: args.To, - GasPrice: args.GasPrice, - Value: args.Value, - Data: input, + From: &args.From, // From shouldn't be nil + To: args.To, + GasPrice: args.GasPrice, + Value: args.Value, + Data: input, + AccessList: args.AccessList, } pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber) estimated, err := DoEstimateGas(ctx, b, callArgs, pendingBlockNr, b.RPCGasCap()) @@ -1532,6 +1558,10 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error { args.Gas = &estimated log.Trace("Estimate gas usage automatically", "gas", args.Gas) } + if args.ChainID == nil { + id := (*hexutil.Big)(b.ChainConfig().ChainID) + args.ChainID = id + } return nil } @@ -1542,10 +1572,19 @@ func (args *SendTxArgs) toTransaction() *types.Transaction { } else if args.Data != nil { input = *args.Data } + if args.AccessList == nil { + // Legacy tx + if args.To == nil { + return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) + } + return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) + } + // Access list tx if args.To == nil { - return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) + return types.NewAccessListContractCreation((*big.Int)(args.ChainID), uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input, args.AccessList) } - return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) + return types.NewAccessListTransaction((*big.Int)(args.ChainID), uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input, args.AccessList) + } // SubmitTransaction is a helper function that submits tx to txPool and logs a message. diff --git a/params/config.go b/params/config.go index 0dbf592d194f..d50b2edee55b 100644 --- a/params/config.go +++ b/params/config.go @@ -246,7 +246,7 @@ var ( // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} + AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, new(EthashConfig), nil} TestRules = TestChainConfig.Rules(new(big.Int)) From b35f4d98d4a24812ffcaf240961b8574a7430ca3 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 21 Jan 2021 23:27:23 +0100 Subject: [PATCH 05/83] core/types, cmd/evm: integrate acl-tx into evm t8n + examples --- cmd/evm/README.md | 17 ++-- cmd/evm/internal/t8ntool/execution.go | 14 +++ cmd/evm/internal/t8ntool/transition.go | 119 ++++++++++++++++++++----- cmd/evm/testdata/8/alloc.json | 11 +++ cmd/evm/testdata/8/env.json | 7 ++ cmd/evm/testdata/8/readme.md | 63 +++++++++++++ cmd/evm/testdata/8/txs.json | 58 ++++++++++++ core/types/gen_tx_json.go | 21 ++--- 8 files changed, 263 insertions(+), 47 deletions(-) create mode 100644 cmd/evm/testdata/8/alloc.json create mode 100644 cmd/evm/testdata/8/env.json create mode 100644 cmd/evm/testdata/8/readme.md create mode 100644 cmd/evm/testdata/8/txs.json diff --git a/cmd/evm/README.md b/cmd/evm/README.md index 8f0848bde80d..7742ccbbb79b 100644 --- a/cmd/evm/README.md +++ b/cmd/evm/README.md @@ -30,7 +30,7 @@ Command line params that has to be supported are --trace.nomemory Disable full memory dump in traces --trace.nostack Disable stack output in traces --trace.noreturndata Disable return data output in traces - --output.basedir value Specifies where output files are placed. Will be created if it does not exist. (default: ".") + --output.basedir value Specifies where output files are placed. Will be created if it does not exist. --output.alloc alloc Determines where to put the alloc of the post-state. `stdout` - into the stdout output `stderr` - into the stderr output @@ -237,10 +237,10 @@ Example where blockhashes are provided: cat trace-0-0x72fadbef39cd251a437eea619cfeda752271a5faaaa2147df012e112159ffb81.jsonl | grep BLOCKHASH -C2 ``` ``` -{"pc":0,"op":96,"gas":"0x5f58ef8","gasCost":"0x3","memory":"0x","memSize":0,"stack":[],"returnStack":[],"returnData":null,"depth":1,"refund":0,"opName":"PUSH1","error":""} -{"pc":2,"op":64,"gas":"0x5f58ef5","gasCost":"0x14","memory":"0x","memSize":0,"stack":["0x1"],"returnStack":[],"returnData":null,"depth":1,"refund":0,"opName":"BLOCKHASH","error":""} -{"pc":3,"op":0,"gas":"0x5f58ee1","gasCost":"0x0","memory":"0x","memSize":0,"stack":["0xdac58aa524e50956d0c0bae7f3f8bb9d35381365d07804dd5b48a5a297c06af4"],"returnStack":[],"returnData":null,"depth":1,"refund":0,"opName":"STOP","error":""} -{"output":"","gasUsed":"0x17","time":112885} +{"pc":0,"op":96,"gas":"0x5f58ef8","gasCost":"0x3","memory":"0x","memSize":0,"stack":[],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"PUSH1","error":""} +{"pc":2,"op":64,"gas":"0x5f58ef5","gasCost":"0x14","memory":"0x","memSize":0,"stack":["0x1"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"BLOCKHASH","error":""} +{"pc":3,"op":0,"gas":"0x5f58ee1","gasCost":"0x0","memory":"0x","memSize":0,"stack":["0xdac58aa524e50956d0c0bae7f3f8bb9d35381365d07804dd5b48a5a297c06af4"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"STOP","error":""} +{"output":"","gasUsed":"0x17","time":142709} ``` In this example, the caller has not provided the required blockhash: @@ -256,9 +256,9 @@ Error code: 4 Another thing that can be done, is to chain invocations: ``` ./evm t8n --input.alloc=./testdata/1/alloc.json --input.txs=./testdata/1/txs.json --input.env=./testdata/1/env.json --output.alloc=stdout | ./evm t8n --input.alloc=stdin --input.env=./testdata/1/env.json --input.txs=./testdata/1/txs.json -INFO [08-03|15:25:15.168] rejected tx index=1 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low" -INFO [08-03|15:25:15.169] rejected tx index=0 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low" -INFO [08-03|15:25:15.169] rejected tx index=1 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low" +INFO [01-21|22:41:22.963] rejected tx index=1 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low: address 0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192, tx: 0 state: 1" +INFO [01-21|22:41:22.966] rejected tx index=0 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low: address 0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192, tx: 0 state: 1" +INFO [01-21|22:41:22.967] rejected tx index=1 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low: address 0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192, tx: 0 state: 1" ``` What happened here, is that we first applied two identical transactions, so the second one was rejected. @@ -267,4 +267,3 @@ the same two transactions: this time, both failed due to too low nonce. In order to meaningfully chain invocations, one would need to provide meaningful new `env`, otherwise the actual blocknumber (exposed to the EVM) would not increase. - diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 525723e3cbf8..a45cf1a6190d 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -154,6 +154,20 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, for _, addr := range evm.ActivePrecompiles() { statedb.AddAddressToAccessList(addr) } + if al := msg.AccessList(); al != nil { + for _, el := range *al { + statedb.AddAddressToAccessList(*el.Address) + for _, key := range el.StorageKeys { + statedb.AddSlotToAccessList(*el.Address, *key) + } + } + } + } else { + if tx.Type() != types.LegacyTxId { + log.Info("rejected tx", "index", i, "hash", tx.Hash(), "error", core.ErrTxTypeNotSupported) + rejectedTxs = append(rejectedTxs, i) + continue + } } snapshot := statedb.Snapshot() // (ret []byte, usedGas uint64, failed bool, err error) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index 5119ed5fb76a..18d89cd03046 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -17,6 +17,7 @@ package t8ntool import ( + "crypto/ecdsa" "encoding/json" "fmt" "io/ioutil" @@ -24,6 +25,7 @@ import ( "os" "path" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" @@ -64,9 +66,9 @@ func (n *NumberedError) Code() int { } type input struct { - Alloc core.GenesisAlloc `json:"alloc,omitempty"` - Env *stEnv `json:"env,omitempty"` - Txs types.Transactions `json:"txs,omitempty"` + Alloc core.GenesisAlloc `json:"alloc,omitempty"` + Env *stEnv `json:"env,omitempty"` + Txs []*txWithKey `json:"txs,omitempty"` } func Main(ctx *cli.Context) error { @@ -135,7 +137,7 @@ func Main(ctx *cli.Context) error { txStr = ctx.String(InputTxsFlag.Name) inputData = &input{} ) - + // Figure out the prestate alloc if allocStr == stdinSelector || envStr == stdinSelector || txStr == stdinSelector { decoder := json.NewDecoder(os.Stdin) decoder.Decode(inputData) @@ -151,7 +153,9 @@ func Main(ctx *cli.Context) error { return NewError(ErrorJson, fmt.Errorf("Failed unmarshaling alloc-file: %v", err)) } } + prestate.Pre = inputData.Alloc + // Set the block environment if envStr != stdinSelector { inFile, err := os.Open(envStr) if err != nil { @@ -165,26 +169,8 @@ func Main(ctx *cli.Context) error { } inputData.Env = &env } - - if txStr != stdinSelector { - inFile, err := os.Open(txStr) - if err != nil { - return NewError(ErrorIO, fmt.Errorf("failed reading txs file: %v", err)) - } - defer inFile.Close() - decoder := json.NewDecoder(inFile) - var txs types.Transactions - if err := decoder.Decode(&txs); err != nil { - return NewError(ErrorJson, fmt.Errorf("Failed unmarshaling txs-file: %v", err)) - } - inputData.Txs = txs - } - - prestate.Pre = inputData.Alloc prestate.Env = *inputData.Env - txs = inputData.Txs - // Iterate over all the tests, run them and aggregate the results vmConfig := vm.Config{ Tracer: tracer, Debug: (tracer != nil), @@ -200,19 +186,106 @@ func Main(ctx *cli.Context) error { // Set the chain id chainConfig.ChainID = big.NewInt(ctx.Int64(ChainIDFlag.Name)) + var txsWithKeys []*txWithKey + if txStr != stdinSelector { + inFile, err := os.Open(txStr) + if err != nil { + return NewError(ErrorIO, fmt.Errorf("failed reading txs file: %v", err)) + } + defer inFile.Close() + decoder := json.NewDecoder(inFile) + if err := decoder.Decode(&txsWithKeys); err != nil { + return NewError(ErrorJson, fmt.Errorf("Failed unmarshaling txs-file: %v", err)) + } + } else { + txsWithKeys = inputData.Txs + } + // We may have to sign the transactions. + signer := types.MakeSigner(chainConfig, big.NewInt(int64(prestate.Env.Number))) + + if txs, err = signUnsignedTransactions(txsWithKeys, signer); err != nil { + return NewError(ErrorJson, fmt.Errorf("Failed signing transactions: %v", err)) + } + + // Iterate over all the tests, run them and aggregate the results + // Run the test and aggregate the result state, result, err := prestate.Apply(vmConfig, chainConfig, txs, ctx.Int64(RewardFlag.Name), getTracer) if err != nil { return err } // Dump the excution result - //postAlloc := state.DumpGenesisFormat(false, false, false) collector := make(Alloc) state.DumpToCollector(collector, false, false, false, nil, -1) return dispatchOutput(ctx, baseDir, result, collector) } +// txWithKey is a helper-struct, to allow us to use the types.Transaction along with +// a `secretKey`-field, for input +type txWithKey struct { + key *ecdsa.PrivateKey + tx *types.Transaction +} + +func (t *txWithKey) UnmarshalJSON(input []byte) error { + // Read the secretKey, if present + type sKey struct { + Key *common.Hash `json:"secretKey"` + } + var key sKey + if err := json.Unmarshal(input, &key); err != nil { + return err + } + if key.Key != nil { + k := key.Key.Hex()[2:] + if ecdsaKey, err := crypto.HexToECDSA(k); err != nil { + return err + } else { + t.key = ecdsaKey + } + } + // Now, read the transaction itself + var tx types.Transaction + if err := json.Unmarshal(input, &tx); err != nil { + return err + } + t.tx = &tx + return nil +} + +// signUnsignedTransactions converts the input txs to canonical transactions. +// +// The transactions can have two forms, either +// 1. unsigned or +// 2. signed +// For (1), r, s, v, need so be zero, and the `secretKey` needs to be set. +// If so, we sign it here and now, with the given `secretKey` +// If the condition above is not met, then it's considered a signed transaction. +// +// To manage this, we read the transactions twice, first trying to read the secretKeys, +// and secondly to read them with the standard tx json format +func signUnsignedTransactions(txs []*txWithKey, signer types.Signer) (types.Transactions, error) { + var signedTxs []*types.Transaction + for i, txWithKey := range txs { + tx := txWithKey.tx + key := txWithKey.key + v, r, s := tx.RawSignatureValues() + if key != nil && v.BitLen()+r.BitLen()+s.BitLen() == 0 { + // This transaction needs to be signed + signed, err := types.SignTx(tx, signer, key) + if err != nil { + return nil, NewError(ErrorJson, fmt.Errorf("Tx %d: failed to sign tx: %v", i, err)) + } + signedTxs = append(signedTxs, signed) + } else { + // Already signed + signedTxs = append(signedTxs, tx) + } + } + return signedTxs, nil +} + type Alloc map[common.Address]core.GenesisAccount func (g Alloc) OnRoot(common.Hash) {} diff --git a/cmd/evm/testdata/8/alloc.json b/cmd/evm/testdata/8/alloc.json new file mode 100644 index 000000000000..1d1b5f86c6e7 --- /dev/null +++ b/cmd/evm/testdata/8/alloc.json @@ -0,0 +1,11 @@ +{ + "0x000000000000000000000000000000000000aaaa": { + "balance": "0x03", + "code": "0x5854505854", + "nonce": "0x1" + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { + "balance": "0x100000", + "nonce": "0x00" + } +} \ No newline at end of file diff --git a/cmd/evm/testdata/8/env.json b/cmd/evm/testdata/8/env.json new file mode 100644 index 000000000000..8b9193472461 --- /dev/null +++ b/cmd/evm/testdata/8/env.json @@ -0,0 +1,7 @@ +{ + "currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty": "0x20000", + "currentGasLimit": "0x1000000000", + "currentNumber": "0x1000000", + "currentTimestamp": "0x04" +} \ No newline at end of file diff --git a/cmd/evm/testdata/8/readme.md b/cmd/evm/testdata/8/readme.md new file mode 100644 index 000000000000..778fc6151ab5 --- /dev/null +++ b/cmd/evm/testdata/8/readme.md @@ -0,0 +1,63 @@ +## EIP-2930 testing + +This test contains testcases for EIP-2930, which uses transactions with access lists. + +### Prestate + +The alloc portion contains one contract (`0x000000000000000000000000000000000000aaaa`), containing the +following code: `0x5854505854`: `PC ;SLOAD; POP; PC; SLOAD`. + +Essentialy, this contract does `SLOAD(0)` and `SLOAD(3)`. + +The alloc also contains some funds on `0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b`. + +## Transactions + +There are three transactions, each invokes the contract above. + +1. ACL-transaction, which contains some non-used slots +2. Regular transaction +3. ACL-transaction, which contains the slots `1` and `3` in `0x000000000000000000000000000000000000aaaa` + +## Execution + +Running it yields: +``` +dir=./testdata/8 && ./evm t8n --state.fork=Berlin --input.alloc=$dir/alloc.json --input.txs=$dir/txs.json --input.env=$dir/env.json --trace && cat trace-* | grep SLOAD +{"pc":1,"op":84,"gas":"0x484be","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x0"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":4,"op":84,"gas":"0x47c86","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x3"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":1,"op":84,"gas":"0x49cf6","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x0"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":4,"op":84,"gas":"0x494be","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x3"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":1,"op":84,"gas":"0x484be","gasCost":"0x64","memory":"0x","memSize":0,"stack":["0x0"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":4,"op":84,"gas":"0x48456","gasCost":"0x64","memory":"0x","memSize":0,"stack":["0x3"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} + +``` + +Simlarly, we can provide the input transactions via `stdin` instead of as file: + +``` +dir=./testdata/8 \ + && cat $dir/txs.json | jq "{txs: .}" \ + | ./evm t8n --state.fork=Berlin \ + --input.alloc=$dir/alloc.json \ + --input.txs=stdin \ + --input.env=$dir/env.json \ + --trace \ + && cat trace-* | grep SLOAD + +{"pc":1,"op":84,"gas":"0x484be","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x0"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":4,"op":84,"gas":"0x47c86","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x3"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":1,"op":84,"gas":"0x49cf6","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x0"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":4,"op":84,"gas":"0x494be","gasCost":"0x834","memory":"0x","memSize":0,"stack":["0x3"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":1,"op":84,"gas":"0x484be","gasCost":"0x64","memory":"0x","memSize":0,"stack":["0x0"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +{"pc":4,"op":84,"gas":"0x48456","gasCost":"0x64","memory":"0x","memSize":0,"stack":["0x3"],"returnStack":[],"returnData":"0x","depth":1,"refund":0,"opName":"SLOAD","error":""} +``` + +If we try to execute it on older rules: +``` +dir=./testdata/8 && ./evm t8n --state.fork=Istanbul --input.alloc=$dir/alloc.json --input.txs=$dir/txs.json --input.env=$dir/env.json +INFO [01-21|23:21:51.265] rejected tx index=0 hash="d2818d…6ab3da" error="tx type not supported" +INFO [01-21|23:21:51.265] rejected tx index=1 hash="26ea00…81c01b" from=0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B error="nonce too high: address 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B, tx: 1 state: 0" +INFO [01-21|23:21:51.265] rejected tx index=2 hash="698d01…369cee" error="tx type not supported" +``` +Number `1` and `3` are not applicable, and therefore number `2` has wrong nonce. \ No newline at end of file diff --git a/cmd/evm/testdata/8/txs.json b/cmd/evm/testdata/8/txs.json new file mode 100644 index 000000000000..35142ba234b0 --- /dev/null +++ b/cmd/evm/testdata/8/txs.json @@ -0,0 +1,58 @@ +[ + { + "gas": "0x4ef00", + "gasPrice": "0x1", + "chainId": "0x1", + "input": "0x", + "nonce": "0x0", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x1", + "type" : "0x1", + "accessList": [ + {"address": "0x0000000000000000000000000000000000000000", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "v": "0x0", + "r": "0x0", + "s": "0x0", + "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" + }, + { + "gas": "0x4ef00", + "gasPrice": "0x1", + "input": "0x", + "nonce": "0x1", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x2", + "v": "0x0", + "r": "0x0", + "s": "0x0", + "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" + }, + { + "gas": "0x4ef00", + "gasPrice": "0x1", + "chainId": "0x1", + "input": "0x", + "nonce": "0x2", + "to": "0x000000000000000000000000000000000000aaaa", + "value": "0x1", + "type" : "0x1", + "accessList": [ + {"address": "0x000000000000000000000000000000000000aaaa", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000003" + ] + } + ], + "v": "0x0", + "r": "0x0", + "s": "0x0", + "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" + } +] diff --git a/core/types/gen_tx_json.go b/core/types/gen_tx_json.go index da9531ffd5ca..bdc4a157ab5c 100644 --- a/core/types/gen_tx_json.go +++ b/core/types/gen_tx_json.go @@ -1,5 +1,3 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - package types import ( @@ -11,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) -// MarshalJSONWithHash marshals as JSON with a hash. +// MarshalJSON marshals as JSON with a hash. func (t *Transaction) MarshalJSON() ([]byte, error) { type txdata struct { Type hexutil.Uint64 `json:"type" rlp:"-"` @@ -51,10 +49,8 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals from JSON. func (t *Transaction) UnmarshalJSON(input []byte) error { - type typ struct { - Type *hexutil.Uint64 `json:"type" rlp:"-"` - } type txdata struct { + Type *hexutil.Uint64 `json:"type" rlp:"-"` Chain *hexutil.Big `json:"chainId" rlp:"-"` AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"` Price *hexutil.Big `json:"gasPrice" gencodec:"required"` @@ -68,14 +64,8 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { S *hexutil.Big `json:"s" gencodec:"required"` Hash *common.Hash `json:"hash" rlp:"-"` } - var ( - decType typ - dec txdata - ) + var dec txdata - if err := json.Unmarshal(input, &decType); err != nil { - return err - } if err := json.Unmarshal(input, &dec); err != nil { return err } @@ -83,7 +73,7 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'nonce' for txdata") } - if decType.Type == nil || *decType.Type == hexutil.Uint64(LegacyTxId) { + if dec.Type == nil || *dec.Type == hexutil.Uint64(LegacyTxId) { var i LegacyTransaction if dec.AccountNonce == nil { return errors.New("missing required field 'nonce' for txdata") @@ -130,7 +120,8 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { } } t.inner = &i - } else if *decType.Type == hexutil.Uint64(AccessListTxId) { + } else if *dec.Type == hexutil.Uint64(AccessListTxId) { + t.typ = AccessListTxId var i AccessListTransaction if dec.Chain == nil { return errors.New("missing required field 'chainId' for txdata") From 03ce4d8eac68c96df338df83a1333efd95f833d0 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Fri, 22 Jan 2021 05:47:26 +0100 Subject: [PATCH 06/83] core/types: rename tx json marshaller --- core/types/{gen_tx_json.go => transaction_marshalling.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename core/types/{gen_tx_json.go => transaction_marshalling.go} (100%) diff --git a/core/types/gen_tx_json.go b/core/types/transaction_marshalling.go similarity index 100% rename from core/types/gen_tx_json.go rename to core/types/transaction_marshalling.go From 27139df944c3be02a1c799a79b48095f6b8c2085 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Sat, 23 Jan 2021 19:12:41 +0100 Subject: [PATCH 07/83] cmd/evm: make evm t8n output block body (optional) core/state: fix panic in state dumping --- cmd/evm/internal/t8ntool/flags.go | 5 +++++ cmd/evm/internal/t8ntool/transition.go | 25 ++++++++++++++++++++----- cmd/evm/main.go | 1 + 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cmd/evm/internal/t8ntool/flags.go b/cmd/evm/internal/t8ntool/flags.go index 424156ba8222..a599462cc61d 100644 --- a/cmd/evm/internal/t8ntool/flags.go +++ b/cmd/evm/internal/t8ntool/flags.go @@ -47,6 +47,11 @@ var ( Usage: "Specifies where output files are placed. Will be created if it does not exist.", Value: "", } + OutputBodyFlag = cli.StringFlag{ + Name: "output.body", + Usage: "If set, the RLP of the transactions (block body) will be written to this file.", + Value: "", + } OutputAllocFlag = cli.StringFlag{ Name: "output.alloc", Usage: "Determines where to put the `alloc` of the post-state.\n" + diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index 18d89cd03046..f69365002db1 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -25,14 +25,15 @@ import ( "os" "path" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "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/log" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/tests" "gopkg.in/urfave/cli.v1" ) @@ -133,9 +134,10 @@ func Main(ctx *cli.Context) error { txs types.Transactions // txs to apply allocStr = ctx.String(InputAllocFlag.Name) - envStr = ctx.String(InputEnvFlag.Name) - txStr = ctx.String(InputTxsFlag.Name) - inputData = &input{} + envStr = ctx.String(InputEnvFlag.Name) + txStr = ctx.String(InputTxsFlag.Name) + bodyOutStr = ctx.String(OutputBodyFlag.Name) + inputData = &input{} ) // Figure out the prestate alloc if allocStr == stdinSelector || envStr == stdinSelector || txStr == stdinSelector { @@ -214,6 +216,17 @@ func Main(ctx *cli.Context) error { if err != nil { return err } + if len(bodyOutStr) != 0 { + // Dump out the "block body" : the transactions in RLP-form + txFile, err := os.Create(bodyOutStr) + if err != nil { + return NewError(ErrorIO, fmt.Errorf("failed writing body file (txs rlp): %v", err)) + } + rlp.Encode(txFile, txs) + txFile.Close() + log.Info("Wrote body file", "file", bodyOutStr, "txs", len(txs)) + } + // Dump the excution result collector := make(Alloc) state.DumpToCollector(collector, false, false, false, nil, -1) @@ -314,9 +327,11 @@ func saveFile(baseDir, filename string, data interface{}) error { if err != nil { return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err)) } - if err = ioutil.WriteFile(path.Join(baseDir, filename), b, 0644); err != nil { + location := path.Join(baseDir, filename) + if err = ioutil.WriteFile(location, b, 0644); err != nil { return NewError(ErrorIO, fmt.Errorf("failed writing output: %v", err)) } + log.Info("Wrote file", "file", location) return nil } diff --git a/cmd/evm/main.go b/cmd/evm/main.go index 35c672142dbe..8a3e4e0ea253 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -149,6 +149,7 @@ var stateTransitionCommand = cli.Command{ t8ntool.OutputBasedir, t8ntool.OutputAllocFlag, t8ntool.OutputResultFlag, + t8ntool.OutputBodyFlag, t8ntool.InputAllocFlag, t8ntool.InputEnvFlag, t8ntool.InputTxsFlag, From 5ae76df671afabebe70e6fbfb772bccce24e5c54 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Sun, 24 Jan 2021 13:45:09 +0100 Subject: [PATCH 08/83] eth: properly handle 2930 in api tracer --- eth/tracers/api.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 1bf59552c919..56a5de35e587 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -756,6 +756,25 @@ func (api *API) traceTx(ctx context.Context, message core.Message, vmctx vm.Bloc // Run the transaction with tracing enabled. vmenv := vm.NewEVM(vmctx, txContext, statedb, api.backend.ChainConfig(), vm.Config{Debug: true, Tracer: tracer}) + if api.backend.ChainConfig().IsYoloV2(vmctx.BlockNumber) { + statedb.AddAddressToAccessList(message.From()) + if dst := message.To(); dst != nil { + statedb.AddAddressToAccessList(*dst) + // If it's a create-tx, the destination will be added inside evm.create + } + for _, addr := range vmenv.ActivePrecompiles() { + statedb.AddAddressToAccessList(addr) + } + if al := message.AccessList(); al != nil { + for _, el := range *al { + statedb.AddAddressToAccessList(*el.Address) + for _, key := range el.StorageKeys { + statedb.AddSlotToAccessList(*el.Address, *key) + } + } + } + } + result, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) if err != nil { return nil, fmt.Errorf("tracing failed: %v", err) From ab662a86cf1d18dd20bdf15e2fa5ea8864436115 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 29 Jan 2021 10:09:08 +0100 Subject: [PATCH 09/83] core, eth, internal, light: fix rebase issues yolov2 -> yolov3 --- core/state_processor.go | 4 ++-- core/tx_pool.go | 6 +++--- core/types/transaction_signing.go | 2 +- eth/tracers/api.go | 2 +- internal/ethapi/api.go | 2 +- light/txpool.go | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index 21d6d78b3b29..6dc8ceff7b8c 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -90,7 +90,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { - if !config.IsYoloV2(header.Number) && tx.Type() != types.LegacyTxId { + if !config.IsYoloV3(header.Number) && tx.Type() != types.LegacyTxId { return nil, ErrTxTypeNotSupported } // Create a new context to be used in the EVM environment @@ -134,7 +134,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon // Create a new receipt for the transaction, storing the intermediate root and gas used by the tx // based on the eip phase, we're passing whether the root touch-delete accounts. var receipt *types.Receipt - if config.IsYoloV2(header.Number) { + if config.IsYoloV3(header.Number) { receipt = types.NewEIP2718Receipt(tx.Type(), root, result.Failed(), *usedGas) } else { receipt = types.NewReceipt(root, result.Failed(), *usedGas) diff --git a/core/tx_pool.go b/core/tx_pool.go index e8241eb9e1df..e3f20f0fdfba 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -536,11 +536,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if pool.currentMaxGas < tx.Gas() { return ErrGasLimit } - // Accept only legacy transactions if before yoloV2. + // Accept only legacy transactions if before 2718/2930. if tx.Type() != types.LegacyTxId && !pool.eip2718 { return ErrTxTypeNotSupported } - // After yoloV2, accept both legacy transactions and access list transactions. + // After 2718/2930, accept both legacy transactions and access list transactions. if pool.eip2718 && (tx.Type() != types.LegacyTxId && tx.Type() != types.AccessListTxId) { return ErrTxTypeNotSupported } @@ -1208,7 +1208,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) { // Update all fork indicator by next pending block number. next := new(big.Int).Add(newHead.Number, big.NewInt(1)) pool.istanbul = pool.chainconfig.IsIstanbul(next) - pool.eip2718 = pool.chainconfig.IsYoloV2(next) + pool.eip2718 = pool.chainconfig.IsYoloV3(next) } // promoteExecutables moves transactions that have become processable from the diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 373594172c81..660d0c159da8 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -42,7 +42,7 @@ type sigCache struct { func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { var signer Signer switch { - case config.IsYoloV2(blockNumber): + case config.IsYoloV3(blockNumber): signer = NewEIP2718Signer(config.ChainID) case config.IsEIP155(blockNumber): signer = NewEIP155Signer(config.ChainID) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 56a5de35e587..128397eadf9f 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -756,7 +756,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, vmctx vm.Bloc // Run the transaction with tracing enabled. vmenv := vm.NewEVM(vmctx, txContext, statedb, api.backend.ChainConfig(), vm.Config{Debug: true, Tracer: tracer}) - if api.backend.ChainConfig().IsYoloV2(vmctx.BlockNumber) { + if api.backend.ChainConfig().IsYoloV3(vmctx.BlockNumber) { statedb.AddAddressToAccessList(message.From()) if dst := message.To(); dst != nil { statedb.AddAddressToAccessList(*dst) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 76a389be67c1..02d84f46754f 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -874,7 +874,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo gp := new(core.GasPool).AddGas(math.MaxUint64) // TODO! Refactor this check to some better place -- right now it's copy-pasted // all over the place - if evm.ChainConfig().IsYoloV2(header.Number) { + if evm.ChainConfig().IsYoloV3(header.Number) { state.AddAddressToAccessList(msg.From()) if dst := msg.To(); dst != nil { state.AddAddressToAccessList(*dst) diff --git a/light/txpool.go b/light/txpool.go index a6acce4f6a49..5ec2fca1f38b 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -69,7 +69,7 @@ type TxPool struct { clearIdx uint64 // earliest block nr that can contain mined tx info istanbul bool // Fork indicator whether we are in the istanbul stage. - yoloV2 bool // Fork indicator whether we are in the yoloV2 stage. + eip2718 bool // Fork indicator whether we are in the eip2718 stage. } // TxRelayBackend provides an interface to the mechanism that forwards transacions @@ -315,7 +315,7 @@ func (pool *TxPool) setNewHead(head *types.Header) { // Update fork indicator by next pending block number next := new(big.Int).Add(head.Number, big.NewInt(1)) pool.istanbul = pool.config.IsIstanbul(next) - pool.yoloV2 = pool.config.IsYoloV2(next) + pool.eip2718 = pool.config.IsYoloV3(next) } // Stop stops the light transaction pool From a990187c898134322adf2ef2b0f19f9d2d51f8cd Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 29 Jan 2021 10:11:19 +0100 Subject: [PATCH 10/83] cmd/geth, utils, params: re-enable --yolov3 switch + fix datadir + correct chainId --- cmd/geth/main.go | 4 +--- cmd/geth/usage.go | 3 +-- cmd/utils/flags.go | 2 +- params/config.go | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index d48bfdd42f9f..5b27a20d9cd6 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -139,9 +139,7 @@ var ( utils.RopstenFlag, utils.RinkebyFlag, utils.GoerliFlag, - // YOLOv3 is not yet complete! - // TODO: enable this once 2718/2930 is added - //utils.YoloV3Flag, + utils.YoloV3Flag, utils.VMEnableDebugFlag, utils.NetworkIdFlag, utils.EthStatsURLFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index cae388c1d3a2..36d615e40c06 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -44,8 +44,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ utils.MainnetFlag, utils.GoerliFlag, utils.RinkebyFlag, - // TODO: Re-enable this when 2718/2930 is added - //utils.YoloV3Flag, + utils.YoloV3Flag, utils.RopstenFlag, utils.SyncModeFlag, utils.ExitWhenSyncedFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 817041c58915..aad1d697998e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1270,7 +1270,7 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) { case ctx.GlobalBool(GoerliFlag.Name) && cfg.DataDir == node.DefaultDataDir(): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli") case ctx.GlobalBool(YoloV3Flag.Name) && cfg.DataDir == node.DefaultDataDir(): - cfg.DataDir = filepath.Join(node.DefaultDataDir(), "yolo-v2") + cfg.DataDir = filepath.Join(node.DefaultDataDir(), "yolo-v3") } } diff --git a/params/config.go b/params/config.go index d50b2edee55b..5690d708b5d9 100644 --- a/params/config.go +++ b/params/config.go @@ -215,7 +215,7 @@ var ( // YoloV3ChainConfig contains the chain parameters to run a node on the YOLOv3 test network. YoloV3ChainConfig = &ChainConfig{ - ChainID: big.NewInt(133519467574834), + ChainID: new(big.Int).SetBytes([]byte("yolov3")), HomesteadBlock: big.NewInt(0), DAOForkBlock: nil, DAOForkSupport: true, From 4b278116aec95b1d76a68c908c828e74a60b6258 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 29 Jan 2021 19:05:52 +0100 Subject: [PATCH 11/83] internal/ethapi: add access list tx fields to RPC responses + fix sender derivation --- internal/ethapi/api.go | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 02d84f46754f..67ff64479038 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1221,27 +1221,32 @@ func (s *PublicBlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Bloc // RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction type RPCTransaction struct { - BlockHash *common.Hash `json:"blockHash"` - BlockNumber *hexutil.Big `json:"blockNumber"` - From common.Address `json:"from"` - Gas hexutil.Uint64 `json:"gas"` - GasPrice *hexutil.Big `json:"gasPrice"` - Hash common.Hash `json:"hash"` - Input hexutil.Bytes `json:"input"` - Nonce hexutil.Uint64 `json:"nonce"` - To *common.Address `json:"to"` - TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` - Value *hexutil.Big `json:"value"` - V *hexutil.Big `json:"v"` - R *hexutil.Big `json:"r"` - S *hexutil.Big `json:"s"` + BlockHash *common.Hash `json:"blockHash"` + BlockNumber *hexutil.Big `json:"blockNumber"` + From common.Address `json:"from"` + Gas hexutil.Uint64 `json:"gas"` + GasPrice *hexutil.Big `json:"gasPrice"` + Hash common.Hash `json:"hash"` + Input hexutil.Bytes `json:"input"` + Nonce hexutil.Uint64 `json:"nonce"` + To *common.Address `json:"to"` + TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` + Value *hexutil.Big `json:"value"` + Accesses *types.AccessList `json:"accessList,omitempty"` + Type hexutil.Uint64 `json:"type,omitempty"` + ChainID *hexutil.Big `json:"chainId,omitempty"` + V *hexutil.Big `json:"v"` + R *hexutil.Big `json:"r"` + S *hexutil.Big `json:"s"` } // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { var signer types.Signer = types.FrontierSigner{} - if tx.Protected() { + if tx.Type() == types.AccessListTxId { + signer = types.NewEIP2718Signer(tx.ChainId()) + } else if tx.Protected() { signer = types.NewEIP155Signer(tx.ChainId()) } from, _ := types.Sender(signer, tx) @@ -1265,6 +1270,11 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) result.TransactionIndex = (*hexutil.Uint64)(&index) } + if tx.Type() == types.AccessListTxId { + result.Type = hexutil.Uint64(tx.Type()) + result.Accesses = tx.AccessList() + result.ChainID = (*hexutil.Big)(tx.ChainId()) + } return result } From 3871a11141211b8a6fb8d5998de711c13cdc7854 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Sat, 30 Jan 2021 04:00:38 +0100 Subject: [PATCH 12/83] core: remove json blockchain tests, fix unused imports --- core/blockchain_test.go | 131 +----- core/testdata/acl_block_0.json | 42 -- core/testdata/acl_block_1.json | 65 --- core/testdata/acl_block_2.json | 102 ----- core/testdata/acl_block_3.json | 153 ------- core/testdata/acl_block_4.json | 218 ---------- core/testdata/acl_block_5.json | 297 ------------- core/testdata/acl_block_6.json | 390 ----------------- core/testdata/acl_block_7.json | 497 ---------------------- core/testdata/acl_block_8.json | 618 --------------------------- core/testdata/acl_block_9.json | 753 --------------------------------- core/testdata/acl_genesis.json | 39 -- core/types/block_test.go | 5 - 13 files changed, 1 insertion(+), 3309 deletions(-) delete mode 100644 core/testdata/acl_block_0.json delete mode 100644 core/testdata/acl_block_1.json delete mode 100644 core/testdata/acl_block_2.json delete mode 100644 core/testdata/acl_block_3.json delete mode 100644 core/testdata/acl_block_4.json delete mode 100644 core/testdata/acl_block_5.json delete mode 100644 core/testdata/acl_block_6.json delete mode 100644 core/testdata/acl_block_7.json delete mode 100644 core/testdata/acl_block_8.json delete mode 100644 core/testdata/acl_block_9.json delete mode 100644 core/testdata/acl_genesis.json diff --git a/core/blockchain_test.go b/core/blockchain_test.go index d882af40b161..b2a9bc0fc769 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -17,7 +17,6 @@ package core import ( - "encoding/json" "errors" "fmt" "io/ioutil" @@ -38,7 +37,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" ) @@ -3051,7 +3049,7 @@ func TestEIP2718Transition(t *testing.T) { address = crypto.PubkeyToAddress(key.PublicKey) funds = big.NewInt(1000000000) gspec = &Genesis{ - Config: params.YoloV2ChainConfig, + Config: params.YoloV3ChainConfig, Alloc: GenesisAlloc{ address: {Balance: funds}, // The address 0xAAAA sloads 0x00 and 0x01 @@ -3107,130 +3105,3 @@ func TestEIP2718Transition(t *testing.T) { } } - -type blockTest struct { - Header *types.Header `json:"header"` - Txs []*types.Transaction `json:"transactions"` - Uncles []*types.Header `json:"uncles"` - Receipts []*types.Receipt `json:"receipts"` -} -type jsonFormat struct { - Rlp string `json:"rlp"` - Json blockTest `json:"json"` -} - -//XTestGenerateACLJsonFiles creates files in ./testdata/ , to be used for cross-client -//testing -func XTestGenerateACLJsonFilesEip2718(t *testing.T) { - var ( - aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") - // Generate a canonical chain to act as the main dataset - engine = ethash.NewFaker() - db = rawdb.NewMemoryDatabase() - // A sender who makes transactions, has some funds - key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - address = crypto.PubkeyToAddress(key.PublicKey) - funds = big.NewInt(1000000000) - gspec = &Genesis{ - Config: params.YoloV2ChainConfig, - Alloc: GenesisAlloc{ - address: {Balance: funds}, - // The address 0xAAAA sloads 0x00 and 0x01 - aa: { - Code: []byte{ - byte(vm.PC), byte(vm.PC), - byte(vm.SLOAD), byte(vm.SLOAD), - }, - Nonce: 0, - Balance: big.NewInt(0), - }, - }, - } - genesis = gspec.MustCommit(db) - signer = types.NewEIP2718Signer(gspec.Config.ChainID) - nonce uint64 = 0 - ) - var signTx = func(tx *types.Transaction) *types.Transaction { - t.Helper() - signed, err := types.SignTx(tx, signer, key) - if err != nil { - t.Fatal(err) - } - nonce++ - return signed - } - var mkAclTx = func(aclCount int) *types.Transaction { - t.Helper() - var accesses types.AccessList - for ii := 0; ii < aclCount; ii++ { - accesses = append(accesses, types.AccessTuple{ - Address: &common.Address{byte(ii)}, - StorageKeys: []*common.Hash{{0}, {byte(ii)}}, - }) - } - return signTx(types.NewAccessListTransaction(gspec.Config.ChainID, nonce, - aa, big.NewInt(0), 123457, big.NewInt(10), nil, &accesses)) - } - var mkLegacyTx = func(i int) *types.Transaction { - t.Helper() - return signTx(types.NewTransaction(nonce, aa, big.NewInt(0), 123457, big.NewInt(10), nil)) - } - - blocks, _ := GenerateChain(gspec.Config, genesis, engine, db, 10, func(i int, b *BlockGen) { - b.SetCoinbase(common.Address{1}) - // Add n acl transactions - for ii := 0; ii < i; ii++ { - b.AddTx(mkAclTx(i)) - } - // Add one legacy tx - b.AddTx(mkLegacyTx(i)) - }) - // Import the canonical chain - diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb) - - chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) - if err != nil { - t.Fatalf("failed to create tester chain: %v", err) - } - if n, err := chain.InsertChain(blocks); err != nil { - t.Fatalf("block %d: failed to insert into chain: %v", n, err) - } - // export the genesis - { - x, err := json.MarshalIndent(gspec, "", " ") - if err != nil { - t.Fatal(err) - } - outFile, err := os.Create("testdata/acl_genesis.json") - outFile.Write(x) - if err != nil { - t.Fatal(err) - } - outFile.Close() - } - // Export the chain - for i, block := range blocks { - rlpData, err := rlp.EncodeToBytes(block) - if err != nil { - t.Fatal(err) - } - jsonData, err := json.MarshalIndent(&jsonFormat{ - Rlp: fmt.Sprintf("%x", rlpData), - Json: blockTest{ - Header: block.Header(), - Txs: block.Transactions(), - Uncles: block.Uncles(), - }}, - "", " ") - if err != nil { - t.Fatal(err) - } - outFile, err := os.Create(fmt.Sprintf("testdata/acl_block_%d.json", i)) - if err != nil { - t.Fatal(err) - } - defer outFile.Close() - outFile.Write(jsonData) - } -} diff --git a/core/testdata/acl_block_0.json b/core/testdata/acl_block_0.json deleted file mode 100644 index 6e71d89f22f9..000000000000 --- a/core/testdata/acl_block_0.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "rlp": "f90263f901f5a0151b04645af991f513d5e11f8ed62e12b73f080af9c7a6a3d98fd6b1503f23faa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0968408b8a2f170bc78230cc2fac3881120a93f7392cf26b609566d8648abfd79a0e8137f2b67ac4680d8103f8b1cd7c05c49f56e4df464b0a79253679f38df9ab4a07f53535270d749f41b9d783aa1abcfceb73cc2a16ecde789cd3bc97a42fbda2ab901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018347e7c48262740a80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f868f866800a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec88a0e7545c5664e63873d7aeb4bb5f92152c3366a9095c9140e5f8453af0998194bea04d24143ac9bc97c0aa07a7074c12ab60484d83d3b447b1e5e6ba5cbf421675bfc0", - "json": { - "header": { - "parentHash": "0x151b04645af991f513d5e11f8ed62e12b73f080af9c7a6a3d98fd6b1503f23fa", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0x968408b8a2f170bc78230cc2fac3881120a93f7392cf26b609566d8648abfd79", - "transactionsRoot": "0xe8137f2b67ac4680d8103f8b1cd7c05c49f56e4df464b0a79253679f38df9ab4", - "receiptsRoot": "0x7f53535270d749f41b9d783aa1abcfceb73cc2a16ecde789cd3bc97a42fbda2a", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x1", - "gasLimit": "0x47e7c4", - "gasUsed": "0x6274", - "timestamp": "0xa", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0x9aa9cdb2afc4ebf893c32b67dedf1dea4291673bf4e80d3227a4e7f8d0feaf68" - }, - "transactions": [ - { - "type": "0x0", - "chainId": null, - "nonce": "0x0", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec88", - "r": "0xe7545c5664e63873d7aeb4bb5f92152c3366a9095c9140e5f8453af0998194be", - "s": "0x4d24143ac9bc97c0aa07a7074c12ab60484d83d3b447b1e5e6ba5cbf421675bf", - "hash": "0x7e122173adcc02b9a3c94da426f65c7d46e724e8e3fdb16be73d5e0405e280b6" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_1.json b/core/testdata/acl_block_1.json deleted file mode 100644 index 614ef3733369..000000000000 --- a/core/testdata/acl_block_1.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "rlp": "f9032df901f5a09aa9cdb2afc4ebf893c32b67dedf1dea4291673bf4e80d3227a4e7f8d0feaf68a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0fb70f6c0512e7979903607bba8a4f1b18c2dd1060a8eff1b777a2182d05af524a0dfcad019a36acdf0f3fac6b3db02bf1d70012a0bd3eadabea87b856be9a6f1cca0a7a57ba954834e69b55d9115305f14f7faff9beb83443f7bb5526585848c6aefb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000028347e7c482dd201480a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f90131b8c701f8c486796f6c6f7632010a8301e24194000000000000000000000000000000000000aaaa8080f85bf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000001a0a9efa6b5fd3c2f210c4ec7232058d8dd30c93a456b4f6074429fb09bbd73eb4fa070632eff8bf0933381917c9161a98494e34fc7b836ee150445cae9ab151d267bf866020a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec88a055a39da3ce02c75e976ad84f608771080811a5ef322c6b6536c362f716c60985a018ab5df4198436eacd0e991f59bdeb8da9a75c678067db6b1a4d07881555c7a8c0", - "json": { - "header": { - "parentHash": "0x9aa9cdb2afc4ebf893c32b67dedf1dea4291673bf4e80d3227a4e7f8d0feaf68", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0xfb70f6c0512e7979903607bba8a4f1b18c2dd1060a8eff1b777a2182d05af524", - "transactionsRoot": "0xdfcad019a36acdf0f3fac6b3db02bf1d70012a0bd3eadabea87b856be9a6f1cc", - "receiptsRoot": "0xa7a57ba954834e69b55d9115305f14f7faff9beb83443f7bb5526585848c6aef", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x2", - "gasLimit": "0x47e7c4", - "gasUsed": "0xdd20", - "timestamp": "0x14", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0xe1807e7366284bc72d34c8f02318f81c6598454dbff4c6cdd71e872cd8d5748c" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x1", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0xa9efa6b5fd3c2f210c4ec7232058d8dd30c93a456b4f6074429fb09bbd73eb4f", - "s": "0x70632eff8bf0933381917c9161a98494e34fc7b836ee150445cae9ab151d267b", - "hash": "0x1916413ac8d1d5ee4eda786e5fe29509a109910f800894e0e18eb84abb7564cb" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x2", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec88", - "r": "0x55a39da3ce02c75e976ad84f608771080811a5ef322c6b6536c362f716c60985", - "s": "0x18ab5df4198436eacd0e991f59bdeb8da9a75c678067db6b1a4d07881555c7a8", - "hash": "0x54c6cfb51cbbe2c562e17a0d6ee1324f1b50013a9b9d47589cedcf0ec4ac342a" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_2.json b/core/testdata/acl_block_2.json deleted file mode 100644 index 1d9d84f06902..000000000000 --- a/core/testdata/acl_block_2.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "rlp": "f904b1f901f6a0e1807e7366284bc72d34c8f02318f81c6598454dbff4c6cdd71e872cd8d5748ca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a025e5b4b7668760c0aa01d44c061d77e24b53f6d247d3e1d85a91e23646c1d679a0be53a36dd90786b4cd30fb0f3677ad3ce5f804a5615872a7b0512b6be82639a2a076946d9f034a6657c6832a6ad4df3ef0ddf3fa9f3f8be98ea64880fb23bd23e3b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000038347e7c48301883c1e80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f902b4b9012301f9011f86796f6c6f7632030a8301e24194000000000000000000000000000000000000aaaa8080f8b6f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0010000000000000000000000000000000000000000000000000000000000000001a0635c44b8110989ef84c77de11a377f19cbd84660559ed76b37ba0f7fdee1fb40a012e1576d168301614720c68f1a9e9d5ed20e23622dab6c3587b11177155d59f4b9012301f9011f86796f6c6f7632040a8301e24194000000000000000000000000000000000000aaaa8080f8b6f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0010000000000000000000000000000000000000000000000000000000000000001a00380e446bf3992ee1df44b8177a11e948dc52cc3faa8eae059a52b7183126c0fa05206f0f35648d3b8f23092d4d7bdccb926967d840a269cf65b706a8a359b9029f866050a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0ea5de382dbf422aa1bd156547a2bc3a9357d745a68cdc9203b14812307068567a0388f7425b873ae204d43d91f4997ca41d2af6759be49538b174a06f67d5741b5c0", - "json": { - "header": { - "parentHash": "0xe1807e7366284bc72d34c8f02318f81c6598454dbff4c6cdd71e872cd8d5748c", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0x25e5b4b7668760c0aa01d44c061d77e24b53f6d247d3e1d85a91e23646c1d679", - "transactionsRoot": "0xbe53a36dd90786b4cd30fb0f3677ad3ce5f804a5615872a7b0512b6be82639a2", - "receiptsRoot": "0x76946d9f034a6657c6832a6ad4df3ef0ddf3fa9f3f8be98ea64880fb23bd23e3", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x3", - "gasLimit": "0x47e7c4", - "gasUsed": "0x1883c", - "timestamp": "0x1e", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0x1615129d2aa7b437cd40e3aa1a5794af9e40b07b9b017014e4123cefeef785ce" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x3", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x635c44b8110989ef84c77de11a377f19cbd84660559ed76b37ba0f7fdee1fb40", - "s": "0x12e1576d168301614720c68f1a9e9d5ed20e23622dab6c3587b11177155d59f4", - "hash": "0x54471f503901f2c2fe392e43df0377a11f9a1cd9cde0ec5c68c89eac1723e02a" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x4", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x380e446bf3992ee1df44b8177a11e948dc52cc3faa8eae059a52b7183126c0f", - "s": "0x5206f0f35648d3b8f23092d4d7bdccb926967d840a269cf65b706a8a359b9029", - "hash": "0xe3a1354e84d22ebbca0c55751937b075083f0f0e3a47c65fc7249d86f872f268" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x5", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec87", - "r": "0xea5de382dbf422aa1bd156547a2bc3a9357d745a68cdc9203b14812307068567", - "s": "0x388f7425b873ae204d43d91f4997ca41d2af6759be49538b174a06f67d5741b5", - "hash": "0x44b1e9999ac02a3b0daf1391be16bb00a262079706418697094bab5f37b522d7" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_3.json b/core/testdata/acl_block_3.json deleted file mode 100644 index e44fee7d7835..000000000000 --- a/core/testdata/acl_block_3.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "rlp": "f906ebf901f6a01615129d2aa7b437cd40e3aa1a5794af9e40b07b9b017014e4123cefeef785cea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0e2c895d53740e942c84623e1612189e72eea9e767b150cc0d8802b490f2574b2a060b6fa13cd50ea3732f59eb726368639dea2006ab4b67dc5730ea27b0cd75732a058ac726e0fc55cd550539c38baf3f6023615e2657ceedccc21ce7edd6516bc31b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000048347e7c4830263c82880a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f904eeb9017f01f9017b86796f6c6f7632060a8301e24194000000000000000000000000000000000000aaaa8080f90111f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0020000000000000000000000000000000000000000000000000000000000000001a0587b3fd59a84469be7c918ae73047141027d27c47cc63f3cf13c6161bf92efaaa0453d3cd2dffd1f048a58fb1046917327f5e95cc8aedc47f82d41bffebfe31bbdb9017f01f9017b86796f6c6f7632070a8301e24194000000000000000000000000000000000000aaaa8080f90111f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0020000000000000000000000000000000000000000000000000000000000000080a0b1944f4797bf4da4d041a66be9c41c317b40d158894103ccd50de5e4ca174b4aa079d6834c013b40d0039ca6755cecc72938461e5b8cd8d3619ddcdfb15c15b866b9017f01f9017b86796f6c6f7632080a8301e24194000000000000000000000000000000000000aaaa8080f90111f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0020000000000000000000000000000000000000000000000000000000000000001a0793cd38309611e0117269275243fc3761fe233dc371918e450b547c70132c033a07276d4b20788938ca0ff7e4e921aec7739103dc73d3b953f47947ef194720757f866090a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec88a0a6528544064aef10d166e16d3968ae83aa29161beb57f2756dfd1151682adbe7a0507fe2d475ffab209e718345a3ad9fb20fee6e15a8c4980df3ed8ff0a714367ac0", - "json": { - "header": { - "parentHash": "0x1615129d2aa7b437cd40e3aa1a5794af9e40b07b9b017014e4123cefeef785ce", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0xe2c895d53740e942c84623e1612189e72eea9e767b150cc0d8802b490f2574b2", - "transactionsRoot": "0x60b6fa13cd50ea3732f59eb726368639dea2006ab4b67dc5730ea27b0cd75732", - "receiptsRoot": "0x58ac726e0fc55cd550539c38baf3f6023615e2657ceedccc21ce7edd6516bc31", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x4", - "gasLimit": "0x47e7c4", - "gasUsed": "0x263c8", - "timestamp": "0x28", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0xc6340ac0a1b76cae78479a4bc6211031550719fa9b58ae42d773dce7ff7409ce" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x6", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x587b3fd59a84469be7c918ae73047141027d27c47cc63f3cf13c6161bf92efaa", - "s": "0x453d3cd2dffd1f048a58fb1046917327f5e95cc8aedc47f82d41bffebfe31bbd", - "hash": "0xbc9b06b5d31e6e257a3c25048e935ba433c68fdd5fa5d0ddd726d5ab7356aafd" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x7", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xb1944f4797bf4da4d041a66be9c41c317b40d158894103ccd50de5e4ca174b4a", - "s": "0x79d6834c013b40d0039ca6755cecc72938461e5b8cd8d3619ddcdfb15c15b866", - "hash": "0x474ec2766068f9e9d0548aca3769ca406fdde21ba87c254d9230c18be35fe99a" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x8", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x793cd38309611e0117269275243fc3761fe233dc371918e450b547c70132c033", - "s": "0x7276d4b20788938ca0ff7e4e921aec7739103dc73d3b953f47947ef194720757", - "hash": "0xe46963eb63cd75a120990ca597532020bc2dcefc4588025c0d50901681a7aae9" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x9", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec88", - "r": "0xa6528544064aef10d166e16d3968ae83aa29161beb57f2756dfd1151682adbe7", - "s": "0x507fe2d475ffab209e718345a3ad9fb20fee6e15a8c4980df3ed8ff0a714367a", - "hash": "0x61fc16fea6b57d81f269e733cdd15d994bbc10dc6e9b0acbedbe32e6fe70a06c" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_4.json b/core/testdata/acl_block_4.json deleted file mode 100644 index 321596243099..000000000000 --- a/core/testdata/acl_block_4.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "rlp": "f909d9f901f6a0c6340ac0a1b76cae78479a4bc6211031550719fa9b58ae42d773dce7ff7409cea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a08bea5accbb5e586ad84279f37b06ccd9cec79f9547e1c34545a361b61117ca66a05266aab4415ef7659530a0baa876d3ab26aff199f13b97084aed767412cf0f88a08899161ab693e740c3ee7323e114f575342c83f25fd7bda246bc1e5722e0b98cb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000058347e7c483036fc43280a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f907dcb901da01f901d686796f6c6f76320a0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000080a07e073e922b0f9195abdd479c2b988c00d3565063baaecbb5bc03d45ec611cbaca07e2d47eb81702ceefbf765d6283586b09c2e9fe2b02ffeea13c72efdd5425aa7b901da01f901d686796f6c6f76320b0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000080a0ad1eb53988eba191181ab17026bc73bfa5744c7feb385ff50c1d135262b4b550a06e0fde038fe6bb5e6a03724e5ed67b76bac528425fa6a31364f498d418c96343b901da01f901d686796f6c6f76320c0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000001a0b819a58c2bd8516b9afbb2410e16de4e4243e8c67ac6901211a931f2f39ff2e2a0053e42e62d88ef4174f01eebe5f3177f4eae4ab0bceaa44f638550678068518eb901da01f901d686796f6c6f76320d0a8301e24194000000000000000000000000000000000000aaaa8080f9016cf859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0030000000000000000000000000000000000000000000000000000000000000001a0dcb383f7cbd502d0d61c5daa2894011476c260daf07f150b52bd8e753929d458a049c149cca5a3e7ee659a1c3205980215d0148369309b8678ea88056f9c4e69a9f8660e0a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0f8305a294ad8c2928246ff9dc008296bec497d70653962a0e17da9cea8618034a05a6ae3809c6fad8ad302100d58d4e08eef51e25634ceb55eee5a07a837e75e03c0", - "json": { - "header": { - "parentHash": "0xc6340ac0a1b76cae78479a4bc6211031550719fa9b58ae42d773dce7ff7409ce", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0x8bea5accbb5e586ad84279f37b06ccd9cec79f9547e1c34545a361b61117ca66", - "transactionsRoot": "0x5266aab4415ef7659530a0baa876d3ab26aff199f13b97084aed767412cf0f88", - "receiptsRoot": "0x8899161ab693e740c3ee7323e114f575342c83f25fd7bda246bc1e5722e0b98c", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x5", - "gasLimit": "0x47e7c4", - "gasUsed": "0x36fc4", - "timestamp": "0x32", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0x43335db66263d3d83223a37683ddd526ee3b81bdcd3ec1a477894b7659e31df5" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0xa", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x7e073e922b0f9195abdd479c2b988c00d3565063baaecbb5bc03d45ec611cbac", - "s": "0x7e2d47eb81702ceefbf765d6283586b09c2e9fe2b02ffeea13c72efdd5425aa7", - "hash": "0x0f4f39a875669b88862f40083726c9c38bb2bd12b787dc59f3840f9a2aa9dad1" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0xb", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xad1eb53988eba191181ab17026bc73bfa5744c7feb385ff50c1d135262b4b550", - "s": "0x6e0fde038fe6bb5e6a03724e5ed67b76bac528425fa6a31364f498d418c96343", - "hash": "0x19f8ea997fa31ab0379efc68fd9b09283dbdd0ed46141f21b4f692c4adb31f1e" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0xc", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0xb819a58c2bd8516b9afbb2410e16de4e4243e8c67ac6901211a931f2f39ff2e2", - "s": "0x53e42e62d88ef4174f01eebe5f3177f4eae4ab0bceaa44f638550678068518e", - "hash": "0xee900bcfba7a74d9e45568af7f8db691c39a357f5088b64bbf4c18bd1e4241bb" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0xd", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0xdcb383f7cbd502d0d61c5daa2894011476c260daf07f150b52bd8e753929d458", - "s": "0x49c149cca5a3e7ee659a1c3205980215d0148369309b8678ea88056f9c4e69a9", - "hash": "0xa74fcf06517f9561b55d31ce00afbaa4f53772291af96521872640e38da51525" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0xe", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec87", - "r": "0xf8305a294ad8c2928246ff9dc008296bec497d70653962a0e17da9cea8618034", - "s": "0x5a6ae3809c6fad8ad302100d58d4e08eef51e25634ceb55eee5a07a837e75e03", - "hash": "0x96739f62b1e4583c97fc3ce618f4490fcb8667186826b99ee18ca3d4e3252136" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_5.json b/core/testdata/acl_block_5.json deleted file mode 100644 index 8df508e133da..000000000000 --- a/core/testdata/acl_block_5.json +++ /dev/null @@ -1,297 +0,0 @@ -{ - "rlp": "f90d7df901f6a043335db66263d3d83223a37683ddd526ee3b81bdcd3ec1a477894b7659e31df5a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a03445ee9a221c8bd9c3a797ef91fe8aa41239a6404a649f289fefd7965d5f6b3da0fa6a9116e469a63a136448d15dd4415bb6c42cd6824a7453788bcf86639b3343a069895a3818b4067d65cbb9b94c3e9caade084f303e10aadcbd4ed2337d6f7e37b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000068347e7c48304ac303c80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f90b80b9023501f9023186796f6c6f76320f0a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a0f84927e5d33e51a97efeeae35148a17aebee690b543f863d55aa0b98cf62803aa01f44785c907379109661088df919b456a0cbcf0d72900237faedc3b2746556c3b9023501f9023186796f6c6f7632100a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a08e2a80d3a51965fd3bf3375329d98bae924f21b84ab1948f822e238a688270d7a051fc270b2b6bebb3a718e06f7a1772029042ce938ec741a9623f5283e84b8442b9023501f9023186796f6c6f7632110a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000001a05541f7da809ec62ec9643748b6d8a64411388f6c1999c8f6a067fae224b7497ca04ce552578d1619c80b14e6f95f472bb7e242b3fdcac449415a58150473feecefb9023501f9023186796f6c6f7632120a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a01f872d6fb4eb7398254fe7811cf405fcbc11b83ea61f50c26feec13c62527ad0a026acd00dbbd0eef10a7c213e616df22f3a9fd1d61d31ed0abb257e0efc8abf06b9023501f9023186796f6c6f7632130a8301e24194000000000000000000000000000000000000aaaa8080f901c7f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0040000000000000000000000000000000000000000000000000000000000000080a03fb9c1360e7a1a9cf45efed449c609b585df3b2ecfa5eb67eecba63c55699f11a072ef40cefb4fbfe2f54df284741effb28c2cf25128e3aec5003d9809c2e82d01f866140a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0a68b33f12348a1053208c0783d7504f90a58da7f9ca2ead1275526cce7d700bda019c01948a0479c1a3774a203686acc9727830503fab6fdeed06b69e60b93755fc0", - "json": { - "header": { - "parentHash": "0x43335db66263d3d83223a37683ddd526ee3b81bdcd3ec1a477894b7659e31df5", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0x3445ee9a221c8bd9c3a797ef91fe8aa41239a6404a649f289fefd7965d5f6b3d", - "transactionsRoot": "0xfa6a9116e469a63a136448d15dd4415bb6c42cd6824a7453788bcf86639b3343", - "receiptsRoot": "0x69895a3818b4067d65cbb9b94c3e9caade084f303e10aadcbd4ed2337d6f7e37", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x6", - "gasLimit": "0x47e7c4", - "gasUsed": "0x4ac30", - "timestamp": "0x3c", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0x00acaefd90b8d42561f10a6e20a23b94f045aa26d7134fabfbc34e5ff1c4e6d5" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0xf", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xf84927e5d33e51a97efeeae35148a17aebee690b543f863d55aa0b98cf62803a", - "s": "0x1f44785c907379109661088df919b456a0cbcf0d72900237faedc3b2746556c3", - "hash": "0xc0ec239a159d9e67d986161ce20d8852e7c70c4e57c27c5fe28ae8fab1038a23" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x10", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x8e2a80d3a51965fd3bf3375329d98bae924f21b84ab1948f822e238a688270d7", - "s": "0x51fc270b2b6bebb3a718e06f7a1772029042ce938ec741a9623f5283e84b8442", - "hash": "0xd4b78fd3de465b52bfbce75278243c0c211d7ff466eda2e4d2c8c4939616c34b" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x11", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x5541f7da809ec62ec9643748b6d8a64411388f6c1999c8f6a067fae224b7497c", - "s": "0x4ce552578d1619c80b14e6f95f472bb7e242b3fdcac449415a58150473feecef", - "hash": "0xbbf1c7cb4e14723a928ca4bc73890ee9449203cd71d987075cb468212e4cf213" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x12", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x1f872d6fb4eb7398254fe7811cf405fcbc11b83ea61f50c26feec13c62527ad0", - "s": "0x26acd00dbbd0eef10a7c213e616df22f3a9fd1d61d31ed0abb257e0efc8abf06", - "hash": "0xb50bdbaa03ec0bddb84f4d9076385d53e4382cb5045dc1f172dce5f60064313c" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x13", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x3fb9c1360e7a1a9cf45efed449c609b585df3b2ecfa5eb67eecba63c55699f11", - "s": "0x72ef40cefb4fbfe2f54df284741effb28c2cf25128e3aec5003d9809c2e82d01", - "hash": "0x8f6cbdeadca58cca5c2d42b7f39d1806db196a4932785eea9c67d644664abb7c" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x14", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec87", - "r": "0xa68b33f12348a1053208c0783d7504f90a58da7f9ca2ead1275526cce7d700bd", - "s": "0x19c01948a0479c1a3774a203686acc9727830503fab6fdeed06b69e60b93755f", - "hash": "0x75376d730e7b5186a1e3e4e32c022308a2d66391f99dff2d59cf39e038b885c7" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_6.json b/core/testdata/acl_block_6.json deleted file mode 100644 index 1e50f53f25db..000000000000 --- a/core/testdata/acl_block_6.json +++ /dev/null @@ -1,390 +0,0 @@ -{ - "rlp": "f911d6f901f6a000acaefd90b8d42561f10a6e20a23b94f045aa26d7134fabfbc34e5ff1c4e6d5a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0acb9bda9ea5166689f2f8f67f60f64318ee0c7aed856eea3bb4249c5f2ad5a58a08af39529cb5c3295713bfac629dc4cc1bde29a12516e83a7cb8b202dea6f9cfca015eecb22e64ad01d793e4d4ff4ddd217d68f454307f933772da76f4ac75b667fb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000078347e7c48306190c4680a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f90fd9b9029001f9028c86796f6c6f7632150a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000001a08a7ce0cf467cf9d04698c542fc7b7ef55651236b567a1dfed8dfc20f008f95d9a02ed15779e036579cd66a997a5ccb9626063fabe129d1a0f84d1addb8f3e30fbcb9028f01f9028b86796f6c6f7632160a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000809f051a77732323ba3f1e6442bff54782d2b80c30be64e1f74fec63eb74e3dadca05ee7edef5e1314dc96391cc67961785d37c597fb428a2498bd242c3dcd52a8f3b9029001f9028c86796f6c6f7632170a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000001a03ad054d140cb8053f42ac9df18fabb57a781a3132cee7d3bc98fcc380e6a1cc6a069c8972ded2412fb79a9dcb676daf6804aa5c7ebd3ff1aedd2a8481731506341b9029001f9028c86796f6c6f7632180a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000080a073ead15ab6ed0d83080db28bf82b89a80e7ecd74880f9a73fe0b8804882b2606a063458665267cffbe0ecfb343aad3559166c4e4c3c1e14eead7f3457fb3ea75eab9029001f9028c86796f6c6f7632190a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000080a04ac58f1d695790cc5156fcebfcf0cf8da35849c91fcc2cd05407055a675419aea05ebaa55e4a32ac00aefc8ca57cc0e36c3b1b4743f5b7274e49a11d6b9cc3047cb9029001f9028c86796f6c6f76321a0a8301e24194000000000000000000000000000000000000aaaa8080f90222f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0050000000000000000000000000000000000000000000000000000000000000080a0e38d4c971e4723dcac613f59975c5ea9b1200bc2b1569b820ddb6766eec521dea07a8f1d82a92f9937039cfe305a13ca54a8e6f22da2839430cfaeba4af65c2427f8661b0a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a075f7b1ed94b4206c1c8aa19422b4e8e9aaff7ad643a41364072880112e0785b4a0185475d900d76df4bf16a218f10ba336b7041134c90da33a0a16c6406564ba46c0", - "json": { - "header": { - "parentHash": "0x00acaefd90b8d42561f10a6e20a23b94f045aa26d7134fabfbc34e5ff1c4e6d5", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0xacb9bda9ea5166689f2f8f67f60f64318ee0c7aed856eea3bb4249c5f2ad5a58", - "transactionsRoot": "0x8af39529cb5c3295713bfac629dc4cc1bde29a12516e83a7cb8b202dea6f9cfc", - "receiptsRoot": "0x15eecb22e64ad01d793e4d4ff4ddd217d68f454307f933772da76f4ac75b667f", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x7", - "gasLimit": "0x47e7c4", - "gasUsed": "0x6190c", - "timestamp": "0x46", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0x2bb50258633ccfdf3f5b07258e3c9866ed9f878a7582230569d4ffc45952a66c" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x15", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x8a7ce0cf467cf9d04698c542fc7b7ef55651236b567a1dfed8dfc20f008f95d9", - "s": "0x2ed15779e036579cd66a997a5ccb9626063fabe129d1a0f84d1addb8f3e30fbc", - "hash": "0xef6960cc8cbb52be918b8e91c3574e8f07c714d2baf7320ffe2c71e20cd39103" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x16", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x51a77732323ba3f1e6442bff54782d2b80c30be64e1f74fec63eb74e3dadc", - "s": "0x5ee7edef5e1314dc96391cc67961785d37c597fb428a2498bd242c3dcd52a8f3", - "hash": "0x910bc3ffde097228c2d20d787bd90b9e277f987ea6972ff659503f8a074b78ff" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x17", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x3ad054d140cb8053f42ac9df18fabb57a781a3132cee7d3bc98fcc380e6a1cc6", - "s": "0x69c8972ded2412fb79a9dcb676daf6804aa5c7ebd3ff1aedd2a8481731506341", - "hash": "0x66dd5793d6ecbd978c41a5d15556f1a16a03fd15149809badab65f8f0b6809c7" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x18", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x73ead15ab6ed0d83080db28bf82b89a80e7ecd74880f9a73fe0b8804882b2606", - "s": "0x63458665267cffbe0ecfb343aad3559166c4e4c3c1e14eead7f3457fb3ea75ea", - "hash": "0xeba7afbdf52f13058232961a6d35b76a2901c32622da72daf20bee4362a457a0" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x19", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x4ac58f1d695790cc5156fcebfcf0cf8da35849c91fcc2cd05407055a675419ae", - "s": "0x5ebaa55e4a32ac00aefc8ca57cc0e36c3b1b4743f5b7274e49a11d6b9cc3047c", - "hash": "0xce8deb76b2475215931a1b5afd4deca2ba9f706bee21ca1e68671ed90177f785" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x1a", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xe38d4c971e4723dcac613f59975c5ea9b1200bc2b1569b820ddb6766eec521de", - "s": "0x7a8f1d82a92f9937039cfe305a13ca54a8e6f22da2839430cfaeba4af65c2427", - "hash": "0x6de8e432fa9a3d8320397c7bece78828a47311a2a055a98e855aa4868bd8e351" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x1b", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec87", - "r": "0x75f7b1ed94b4206c1c8aa19422b4e8e9aaff7ad643a41364072880112e0785b4", - "s": "0x185475d900d76df4bf16a218f10ba336b7041134c90da33a0a16c6406564ba46", - "hash": "0x0dc4c78b1636726787970269ff17c855444e1d27eee8c0fd516e51176f574f71" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_7.json b/core/testdata/acl_block_7.json deleted file mode 100644 index 1194aabc55c6..000000000000 --- a/core/testdata/acl_block_7.json +++ /dev/null @@ -1,497 +0,0 @@ -{ - "rlp": "f916e7f901f6a02bb50258633ccfdf3f5b07258e3c9866ed9f878a7582230569d4ffc45952a66ca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0a55899fdbfa99a7feaabb51608ce4b0c2912596f2229ffeacb2ef05fb55b71b7a0e28fe6b703978af3d2eda206f6f959e2d833afaf418028a9503271f4f20a40d9a03f8954dac53eb0caa13809bae6c1bbfb729aa10778ac528e62113114b758e633b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000088347e7c48307b6585080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f914eab902eb01f902e786796f6c6f76321c0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a0643459a4e9aba8d232302442f95e7f6d89b06f273443a8710f9bb55496df1994a06e3f8765c4f399486454c64cf54b1396df2812c7d5fdcadb47a66f83ec553cd5b902eb01f902e786796f6c6f76321d0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000001a09862a3737fe1d45c7b256ff22a50d567b88c04212b39396ab41a1e9c62d4f44ea04c797c4b78681cc16aea9a18e59923264c744c17d9861560693473f927c28f54b902eb01f902e786796f6c6f76321e0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a08e24d4c713f644e38223cd600c56c65fd64d74fa3c1659ebf2ef719284c74802a00412a2733ba0c5fa7da40dc6b199351f0c04ed4c455607546d25d6efbc3e9a12b902eb01f902e786796f6c6f76321f0a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a0fc7721a6ca78e74eaadbbbbbfd6fa990fd9993a29a6d552f5c12d7256feebaa5a0166a3b40a0e0d86b95dac8a83dd1f0eb61f107bcb6f670cc114c3dd67f193d01b902eb01f902e786796f6c6f7632200a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000080a0d1dac5d229b36766e7cc6a3d87596c6b72c1b579cccdc62a5b4438a04a46d3fea0053a8afe9e411247a65370e1d4e83cdcec9dc41a0b595999f3e41b07be014d10b902eb01f902e786796f6c6f7632210a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000001a0251ab5147fb99b3c222fc99157ef6a6603659c2465bb9bb2662679fce6c12077a03c4ed0c45754fc479583126bf2d88c0bf323310f2f946f3bbeee44e73bf744c0b902eb01f902e786796f6c6f7632220a8301e24194000000000000000000000000000000000000aaaa8080f9027df859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0060000000000000000000000000000000000000000000000000000000000000001a0664de330a9c9b3e4041e347332a30d0f88358063de52c6cefcc5a8ce397f96f3a013ea85012f7a62739610e48ea51e170275c56f0f8d1896520f1ef84d4f3e389ef866230a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0a3bdc8174d2fbe9c404ff490e77555039f1c37bddbe60d8e60c1228f9964f02da015572f4a595159746f9f11554059312ccdbc05e6bf8831469338bb78dcb43b5ac0", - "json": { - "header": { - "parentHash": "0x2bb50258633ccfdf3f5b07258e3c9866ed9f878a7582230569d4ffc45952a66c", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0xa55899fdbfa99a7feaabb51608ce4b0c2912596f2229ffeacb2ef05fb55b71b7", - "transactionsRoot": "0xe28fe6b703978af3d2eda206f6f959e2d833afaf418028a9503271f4f20a40d9", - "receiptsRoot": "0x3f8954dac53eb0caa13809bae6c1bbfb729aa10778ac528e62113114b758e633", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x8", - "gasLimit": "0x47e7c4", - "gasUsed": "0x7b658", - "timestamp": "0x50", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0xfa221b6492050cfc24b906b20ce208b3dc4ba841e564395f2900c4a175158a1e" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x1c", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x643459a4e9aba8d232302442f95e7f6d89b06f273443a8710f9bb55496df1994", - "s": "0x6e3f8765c4f399486454c64cf54b1396df2812c7d5fdcadb47a66f83ec553cd5", - "hash": "0x21840bf8b516a15569f253f9b7900d052f86f9173b02a240ccbddbc38f912498" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x1d", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x9862a3737fe1d45c7b256ff22a50d567b88c04212b39396ab41a1e9c62d4f44e", - "s": "0x4c797c4b78681cc16aea9a18e59923264c744c17d9861560693473f927c28f54", - "hash": "0x5ed7369fea0e90818ced675a993efa699628286583417244fb136a4f73a2e90f" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x1e", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x8e24d4c713f644e38223cd600c56c65fd64d74fa3c1659ebf2ef719284c74802", - "s": "0x412a2733ba0c5fa7da40dc6b199351f0c04ed4c455607546d25d6efbc3e9a12", - "hash": "0x24c0cd928e6bce21401dce170c98a80acd33ef4c6c6be3d0ea58127c0a049185" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x1f", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xfc7721a6ca78e74eaadbbbbbfd6fa990fd9993a29a6d552f5c12d7256feebaa5", - "s": "0x166a3b40a0e0d86b95dac8a83dd1f0eb61f107bcb6f670cc114c3dd67f193d01", - "hash": "0x755cc55d927e952bff7e51f70471c7a8b53cbbb76e855d0fe6148afc099967f8" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x20", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xd1dac5d229b36766e7cc6a3d87596c6b72c1b579cccdc62a5b4438a04a46d3fe", - "s": "0x53a8afe9e411247a65370e1d4e83cdcec9dc41a0b595999f3e41b07be014d10", - "hash": "0xabd736140ee8fe129b0db888c7808298e015be3f52cf530bfb064828b9801806" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x21", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x251ab5147fb99b3c222fc99157ef6a6603659c2465bb9bb2662679fce6c12077", - "s": "0x3c4ed0c45754fc479583126bf2d88c0bf323310f2f946f3bbeee44e73bf744c0", - "hash": "0x1c71ff8b515e449b4597ba4e08f4bd1558716e5253e9fb62c117a01f0c859124" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x22", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x664de330a9c9b3e4041e347332a30d0f88358063de52c6cefcc5a8ce397f96f3", - "s": "0x13ea85012f7a62739610e48ea51e170275c56f0f8d1896520f1ef84d4f3e389e", - "hash": "0x698566ee27aac8dda0c7bfd0b3e5b9c122a9ac81053dce700b3ef9fa156b35f7" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x23", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec87", - "r": "0xa3bdc8174d2fbe9c404ff490e77555039f1c37bddbe60d8e60c1228f9964f02d", - "s": "0x15572f4a595159746f9f11554059312ccdbc05e6bf8831469338bb78dcb43b5a", - "hash": "0x95aa3328bed08bb31056e79cdb10c890d3c645493c928e4546a2d65b821380ca" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_8.json b/core/testdata/acl_block_8.json deleted file mode 100644 index 9437772de135..000000000000 --- a/core/testdata/acl_block_8.json +++ /dev/null @@ -1,618 +0,0 @@ -{ - "rlp": "f91cadf901f6a0fa221b6492050cfc24b906b20ce208b3dc4ba841e564395f2900c4a175158a1ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a0b38b2ff96bb62a36840bd31e6b02a1ded156d8f571b35eef02d08f311fe03f65a08876562acbd95cb180c7599816bd6c954f8feadf02891b7c41b6369fb31c2e1ea0b78dc917392b3a6757a3545c29f0300f401c1d07303215ad0d4023a170a1c99fb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000098347e7c4830984145a80a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f91ab0b9034601f9034286796f6c6f7632240a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0d9c848f01ea535491946502971d8abd4640243394078a51efa4577c690910027a046c1247d86cb8b09209974eb3e667c82b81307c622124099c93a46811509dca6b9034601f9034286796f6c6f7632250a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000001a07595a92f015a9aeba3135f9fd3bcf743f058503f7e9dbc470d195d35bcb4eaa3a050cf2c39959208961f5bf9b890ec98473c631ba668b41455ed91c8711bc5c7b2b9034601f9034286796f6c6f7632260a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0949a0a2f11aa9958d32c9e4d734497ed74dd851d57b28981f606e5be517a2f56a05493ccac5f48b724388a824ee3df6c0c54922faea0ed911cd6e7993d72e105b0b9034601f9034286796f6c6f7632270a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a03eae4a21a7648d2b33940a601a37bc24eb1f0472611a3321867edf423970db98a02a87c17c6c8116a0df110e51da727d953569e5f48f61d80f6e7aa67ee88491d0b9034601f9034286796f6c6f7632280a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a07fcccf7db8f6f715b4467798328ecd812de95a9e00b16064108f220c131b1feba00b32d45c342f74907d7999a4bfc13b2bc0f6dee4336fdfb4847e182f80204785b9034601f9034286796f6c6f7632290a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0b25c865ca6bd22c9dc046adc53d7419d9696a13f16baf97593672f2033c200c1a061b26c60cfa8af36154a4555c20501c30af193104a779ac20266e8a09da30b6bb9034601f9034286796f6c6f76322a0a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a0f97719ddd5d72d9269b5fe95b7646cc2719d67824a7784bea322afdcd79ce119a022e4250977257258c863fcb766b88494b884750fa6023db8410fac8a0a100eadb9034601f9034286796f6c6f76322b0a8301e24194000000000000000000000000000000000000aaaa8080f902d8f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0070000000000000000000000000000000000000000000000000000000000000080a073c0c49e7f0c7c4343c80d726733c06810b8efeee8907f2fc65519258a93fa67a0140d4d304c84d40e85e98eb5f073698f9f0d44f9051c25e98aa3da1f975cb771f8662c0a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a04a8911c73aa392f7472d0f3b8de07c06df21cec19b50eb5b913f2b4d4e9b3d6aa00a9d8d20c17644f8db37b6a2f00dc330a8c3c09f5fc5aa065f2410e3a3340a9dc0", - "json": { - "header": { - "parentHash": "0xfa221b6492050cfc24b906b20ce208b3dc4ba841e564395f2900c4a175158a1e", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0xb38b2ff96bb62a36840bd31e6b02a1ded156d8f571b35eef02d08f311fe03f65", - "transactionsRoot": "0x8876562acbd95cb180c7599816bd6c954f8feadf02891b7c41b6369fb31c2e1e", - "receiptsRoot": "0xb78dc917392b3a6757a3545c29f0300f401c1d07303215ad0d4023a170a1c99f", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0x9", - "gasLimit": "0x47e7c4", - "gasUsed": "0x98414", - "timestamp": "0x5a", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0x84dda3788f42b7e41a084407d725a58c201ce7cfadd97e886cb976dda22c9921" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x24", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xd9c848f01ea535491946502971d8abd4640243394078a51efa4577c690910027", - "s": "0x46c1247d86cb8b09209974eb3e667c82b81307c622124099c93a46811509dca6", - "hash": "0xaf54d730700aef32f551db22595085bf45e85e605d75484e89a727527e96129b" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x25", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x7595a92f015a9aeba3135f9fd3bcf743f058503f7e9dbc470d195d35bcb4eaa3", - "s": "0x50cf2c39959208961f5bf9b890ec98473c631ba668b41455ed91c8711bc5c7b2", - "hash": "0xde28554defa0795db3c147bda91a23ffcb30b80cf26f28ab96d6ead60a69d2b9" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x26", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x949a0a2f11aa9958d32c9e4d734497ed74dd851d57b28981f606e5be517a2f56", - "s": "0x5493ccac5f48b724388a824ee3df6c0c54922faea0ed911cd6e7993d72e105b0", - "hash": "0x285d3401abaa281c502acc4bf59ec59a6c7bce62f9a46bfc6b3100b97152f528" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x27", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x3eae4a21a7648d2b33940a601a37bc24eb1f0472611a3321867edf423970db98", - "s": "0x2a87c17c6c8116a0df110e51da727d953569e5f48f61d80f6e7aa67ee88491d0", - "hash": "0x85c6d289b56245b7b6e4ccdd514e2b6792c9f3e956ea4968d69593a3030f4499" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x28", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x7fcccf7db8f6f715b4467798328ecd812de95a9e00b16064108f220c131b1feb", - "s": "0xb32d45c342f74907d7999a4bfc13b2bc0f6dee4336fdfb4847e182f80204785", - "hash": "0x846c5fce7829817683d7be03b6f08f39ef79dbeed0ec64e1901962f8d83ddedd" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x29", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xb25c865ca6bd22c9dc046adc53d7419d9696a13f16baf97593672f2033c200c1", - "s": "0x61b26c60cfa8af36154a4555c20501c30af193104a779ac20266e8a09da30b6b", - "hash": "0xeddbe8867f8555f92fdd42d03872467509551a645f7bd92a050fbabaf506865c" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x2a", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xf97719ddd5d72d9269b5fe95b7646cc2719d67824a7784bea322afdcd79ce119", - "s": "0x22e4250977257258c863fcb766b88494b884750fa6023db8410fac8a0a100ead", - "hash": "0x026824663c75c144366419e4448cb29453f70d891245e0264bf94c9478bc28ae" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x2b", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x73c0c49e7f0c7c4343c80d726733c06810b8efeee8907f2fc65519258a93fa67", - "s": "0x140d4d304c84d40e85e98eb5f073698f9f0d44f9051c25e98aa3da1f975cb771", - "hash": "0x877c3067e2ead44ec4be1d4dcda3571213325d93291f32c3f674cff01947cf0a" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x2c", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec87", - "r": "0x4a8911c73aa392f7472d0f3b8de07c06df21cec19b50eb5b913f2b4d4e9b3d6a", - "s": "0xa9d8d20c17644f8db37b6a2f00dc330a8c3c09f5fc5aa065f2410e3a3340a9d", - "hash": "0xca741c6398b7e3bfdafc46c3c97ac22a8c1002744231e1702c0bbc2245d2ba34" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_block_9.json b/core/testdata/acl_block_9.json deleted file mode 100644 index 8b6059a6fe45..000000000000 --- a/core/testdata/acl_block_9.json +++ /dev/null @@ -1,753 +0,0 @@ -{ - "rlp": "f92329f901f6a084dda3788f42b7e41a084407d725a58c201ce7cfadd97e886cb976dda22c9921a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940100000000000000000000000000000000000000a091503e4466860227794cecc7e441abc9bad4ef57114c08af408cb6bf58980235a0de7408c49f9332211cbf0ea0d6d6697ee9ebef4b9cb53869168834956153d45ca0c18851ede636a1298652a8dd6bffb065e7c198417660bf20f97731be93d46cefb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200000a8347e7c4830b82406480a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f9212cb903a101f9039d86796f6c6f76322d0a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a0cc5c7d6d2250816d5cebafe393914fd6ff39702ef9647d907c196c4240858446a068082151d6d9fbe47e3fed849328dce66ab6b0976a106d0a5423b18b0be201e2b903a101f9039d86796f6c6f76322e0a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a005620469222dcdb8378eecec565b89c69d653397b14160ff49052ac67699150ea06f343d9c86ee05ff23f562d5b21f763a34ecf00cda60b267f9dc124661dd69c7b903a101f9039d86796f6c6f76322f0a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000080a072b8ee28e31595dc01388151d9a293a832dfca58c22d48d8c24681e5e52b95f0a0156cd769bbcafaca1ce2691542aafc05ec3156dee26988d780e2915f67415437b903a101f9039d86796f6c6f7632300a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a022ffc9f0594be343e16e448e15aa2298f097c88c8e951020e9055f70537e6cbba022d8161cd97590d9fdfe61bc0ce34face1a221f6d9a50c96ffc185c7b6eb1a33b903a101f9039d86796f6c6f7632310a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000080a0e9834fd907d82587ac1c3d1f4998fbe914142834ec86e34293e11d22279eb6f4a0594a4a7b79798e466e41125fcfa9c08e548a4f6bba7bab3a17769d6cd15d4926b903a101f9039d86796f6c6f7632320a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a0cad758b73761dc79fbe62ea6ecae306c2f8a9a614bddd2ee379f9924ecf26d9ba006d5955b0769de282012278bf43d83bbee144dc61893d2d0f1daad9463af9677b903a101f9039d86796f6c6f7632330a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a01bd327017a42d3bdce1b192716c730eda6b990d9f12ee14286872daa5a36ecf8a0407ec3dd532be0377aa774e6352fa12e15f1ce8e09a39a520449b2a6bbf2d0aab903a101f9039d86796f6c6f7632340a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000080a001a2f42cdd339b157cd736cade0641489bf345f6bc0a657075d329797a9ef331a0696ca3e566854a52d4b6514fcfddf796dfa18762ce350d86d14612b0e177ccc2b903a101f9039d86796f6c6f7632350a8301e24194000000000000000000000000000000000000aaaa8080f90333f859940000000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000f859940100000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000000f859940200000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940300000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00300000000000000000000000000000000000000000000000000000000000000f859940400000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00400000000000000000000000000000000000000000000000000000000000000f859940500000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00500000000000000000000000000000000000000000000000000000000000000f859940600000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00600000000000000000000000000000000000000000000000000000000000000f859940700000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a00700000000000000000000000000000000000000000000000000000000000000f859940800000000000000000000000000000000000000f842a00000000000000000000000000000000000000000000000000000000000000000a0080000000000000000000000000000000000000000000000000000000000000001a02f63a43500e78623d38149a0bd2a331c616202312aff7d4047ee080c02139e7aa021d1a2144e9fea759d3e650a91f576b9a502c4a84cab745f8c9b8e15618c33cdf866360a8301e24194000000000000000000000000000000000000aaaa808086f2ded8deec87a0ed4c15a3ff67c17eef207d8e7beef31af80a63ab8e03738c10f1483f7e8f6203a0495d2bea850f073e20c79fbef96ccab6ca3367059e3fa4704f8f22f48dc318cac0", - "json": { - "header": { - "parentHash": "0x84dda3788f42b7e41a084407d725a58c201ce7cfadd97e886cb976dda22c9921", - "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "miner": "0x0100000000000000000000000000000000000000", - "stateRoot": "0x91503e4466860227794cecc7e441abc9bad4ef57114c08af408cb6bf58980235", - "transactionsRoot": "0xde7408c49f9332211cbf0ea0d6d6697ee9ebef4b9cb53869168834956153d45c", - "receiptsRoot": "0xc18851ede636a1298652a8dd6bffb065e7c198417660bf20f97731be93d46cef", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "difficulty": "0x20000", - "number": "0xa", - "gasLimit": "0x47e7c4", - "gasUsed": "0xb8240", - "timestamp": "0x64", - "extraData": "0x", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x0000000000000000", - "hash": "0xd8e7665bdcb0b053e18bc9dc565765b3c93aaf3938d03a6b24df816dbc44f5df" - }, - "transactions": [ - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x2d", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0xcc5c7d6d2250816d5cebafe393914fd6ff39702ef9647d907c196c4240858446", - "s": "0x68082151d6d9fbe47e3fed849328dce66ab6b0976a106d0a5423b18b0be201e2", - "hash": "0xf59de76965a4c6ab43ba656320bcc151c1c5b2dd3e9c61077bfada88c60f9d91" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x2e", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x5620469222dcdb8378eecec565b89c69d653397b14160ff49052ac67699150e", - "s": "0x6f343d9c86ee05ff23f562d5b21f763a34ecf00cda60b267f9dc124661dd69c7", - "hash": "0xf9800f0463832ba38394196d74415d925b0fe48a6accc44fce76294cef1c6542" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x2f", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x72b8ee28e31595dc01388151d9a293a832dfca58c22d48d8c24681e5e52b95f0", - "s": "0x156cd769bbcafaca1ce2691542aafc05ec3156dee26988d780e2915f67415437", - "hash": "0x8d7f71e167aed00e7f98a3d6efef0455a915affcff0b6d96ac26e65bb65a6ce9" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x30", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x22ffc9f0594be343e16e448e15aa2298f097c88c8e951020e9055f70537e6cbb", - "s": "0x22d8161cd97590d9fdfe61bc0ce34face1a221f6d9a50c96ffc185c7b6eb1a33", - "hash": "0x478e063e01971fa8990da37b2709d4b7f53c3724df94d9bdf685cc1c3eafb459" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x31", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0xe9834fd907d82587ac1c3d1f4998fbe914142834ec86e34293e11d22279eb6f4", - "s": "0x594a4a7b79798e466e41125fcfa9c08e548a4f6bba7bab3a17769d6cd15d4926", - "hash": "0x6e6eb6cfc365c3ee3e4b575d92844c7742505b62aa3d5765a41bcf7f61d787b1" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x32", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0xcad758b73761dc79fbe62ea6ecae306c2f8a9a614bddd2ee379f9924ecf26d9b", - "s": "0x6d5955b0769de282012278bf43d83bbee144dc61893d2d0f1daad9463af9677", - "hash": "0x79de88fa2ac7f1ef13e596f9c4732fd06eaa968b5afd9fd6efa9564ddedd04e4" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x33", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x1bd327017a42d3bdce1b192716c730eda6b990d9f12ee14286872daa5a36ecf8", - "s": "0x407ec3dd532be0377aa774e6352fa12e15f1ce8e09a39a520449b2a6bbf2d0aa", - "hash": "0x849ad53627a411a79641b82d23f40f76544ef7cc185518560810c02cd163dddf" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x34", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x0", - "r": "0x1a2f42cdd339b157cd736cade0641489bf345f6bc0a657075d329797a9ef331", - "s": "0x696ca3e566854a52d4b6514fcfddf796dfa18762ce350d86d14612b0e177ccc2", - "hash": "0xbae361665e925aa04f59f41a7f23bac56bd69ca40262cb55afc6a9446aa12f77" - }, - { - "type": "0x1", - "chainId": "0x796f6c6f7632", - "nonce": "0x35", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": [ - { - "address": "0x0000000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0100000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0100000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0200000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0200000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0300000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0300000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0400000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0400000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0500000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0500000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0600000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0600000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0700000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0700000000000000000000000000000000000000000000000000000000000000" - ] - }, - { - "address": "0x0800000000000000000000000000000000000000", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0800000000000000000000000000000000000000000000000000000000000000" - ] - } - ], - "v": "0x1", - "r": "0x2f63a43500e78623d38149a0bd2a331c616202312aff7d4047ee080c02139e7a", - "s": "0x21d1a2144e9fea759d3e650a91f576b9a502c4a84cab745f8c9b8e15618c33cd", - "hash": "0x8d7a600d5de038029800c6d10b5dbd5ace67324fd75dfe3e31f5b48ce6a19b9c" - }, - { - "type": "0x0", - "chainId": null, - "nonce": "0x36", - "gasPrice": "0xa", - "gas": "0x1e241", - "to": "0x000000000000000000000000000000000000aaaa", - "value": "0x0", - "input": "0x", - "accessList": null, - "v": "0xf2ded8deec87", - "r": "0xed4c15a3ff67c17eef207d8e7beef31af80a63ab8e03738c10f1483f7e8f6203", - "s": "0x495d2bea850f073e20c79fbef96ccab6ca3367059e3fa4704f8f22f48dc318ca", - "hash": "0xefe1036e9043183eb61a8042ca97c8260da7eb2ef1d6969d9404e1e6ec48f490" - } - ], - "uncles": null, - "receipts": null - } -} \ No newline at end of file diff --git a/core/testdata/acl_genesis.json b/core/testdata/acl_genesis.json deleted file mode 100644 index 3fc5f4948bea..000000000000 --- a/core/testdata/acl_genesis.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "config": { - "chainId": 133519467574834, - "homesteadBlock": 0, - "daoForkSupport": true, - "eip150Block": 0, - "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "yoloV2Block": 0, - "clique": { - "period": 15, - "epoch": 30000 - } - }, - "nonce": "0x0", - "timestamp": "0x0", - "extraData": "0x", - "gasLimit": "0x0", - "difficulty": null, - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "alloc": { - "000000000000000000000000000000000000aaaa": { - "code": "0x58585454", - "balance": "0x0" - }, - "71562b71999873db5b286df957af199ec94617f7": { - "balance": "0x3b9aca00" - } - }, - "number": "0x0", - "gasUsed": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" -} \ No newline at end of file diff --git a/core/types/block_test.go b/core/types/block_test.go index 1e19102e689c..ed6c81672248 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -18,14 +18,9 @@ package types import ( "bytes" - "encoding/json" - "fmt" "hash" - "io/ioutil" "math/big" - "os" "reflect" - "strings" "testing" "github.com/ethereum/go-ethereum/common" From 9a0b788c46fda4a512cc806ba1e29e33411ed4b6 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 1 Feb 2021 11:01:06 +0100 Subject: [PATCH 13/83] internal/t8ntool: output block body as hex-encoded string, same output logic as other fields --- cmd/evm/internal/t8ntool/transition.go | 29 +++++++++++--------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index f69365002db1..fedcd1243569 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -26,6 +26,7 @@ import ( "path" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" @@ -134,10 +135,9 @@ func Main(ctx *cli.Context) error { txs types.Transactions // txs to apply allocStr = ctx.String(InputAllocFlag.Name) - envStr = ctx.String(InputEnvFlag.Name) - txStr = ctx.String(InputTxsFlag.Name) - bodyOutStr = ctx.String(OutputBodyFlag.Name) - inputData = &input{} + envStr = ctx.String(InputEnvFlag.Name) + txStr = ctx.String(InputTxsFlag.Name) + inputData = &input{} ) // Figure out the prestate alloc if allocStr == stdinSelector || envStr == stdinSelector || txStr == stdinSelector { @@ -216,21 +216,11 @@ func Main(ctx *cli.Context) error { if err != nil { return err } - if len(bodyOutStr) != 0 { - // Dump out the "block body" : the transactions in RLP-form - txFile, err := os.Create(bodyOutStr) - if err != nil { - return NewError(ErrorIO, fmt.Errorf("failed writing body file (txs rlp): %v", err)) - } - rlp.Encode(txFile, txs) - txFile.Close() - log.Info("Wrote body file", "file", bodyOutStr, "txs", len(txs)) - } - + body, _ := rlp.EncodeToBytes(txs) // Dump the excution result collector := make(Alloc) state.DumpToCollector(collector, false, false, false, nil, -1) - return dispatchOutput(ctx, baseDir, result, collector) + return dispatchOutput(ctx, baseDir, result, collector, body) } @@ -337,7 +327,7 @@ func saveFile(baseDir, filename string, data interface{}) error { // dispatchOutput writes the output data to either stderr or stdout, or to the specified // files -func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, alloc Alloc) error { +func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, alloc Alloc, body hexutil.Bytes) error { stdOutObject := make(map[string]interface{}) stdErrObject := make(map[string]interface{}) dispatch := func(baseDir, fName, name string, obj interface{}) error { @@ -346,6 +336,8 @@ func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, a stdOutObject[name] = obj case "stderr": stdErrObject[name] = obj + case "": + // don't save default: // save to file if err := saveFile(baseDir, fName, obj); err != nil { return err @@ -359,6 +351,9 @@ func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, a if err := dispatch(baseDir, ctx.String(OutputResultFlag.Name), "result", result); err != nil { return err } + if err := dispatch(baseDir, ctx.String(OutputBodyFlag.Name), "body", body); err != nil { + return err + } if len(stdOutObject) > 0 { b, err := json.MarshalIndent(stdOutObject, "", " ") if err != nil { From 6efe70d4469fdef56bc82bb486eea31127595fbd Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 3 Feb 2021 14:43:31 +0100 Subject: [PATCH 14/83] all: refactor access list handling + fix flaw in t8n --- cmd/evm/internal/t8ntool/execution.go | 32 ++++++++------------------- core/state/statedb.go | 28 +++++++++++++++++++++++ core/state_processor.go | 17 +------------- core/vm/runtime/runtime.go | 18 ++++----------- eth/tracers/api.go | 17 +------------- internal/ethapi/api.go | 20 ++--------------- tests/state_test_util.go | 9 +------- 7 files changed, 46 insertions(+), 95 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index a45cf1a6190d..e89bfcf2e353 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -144,32 +144,18 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, statedb.Prepare(tx.Hash(), blockHash, txIndex) txContext := core.NewEVMTxContext(msg) + if !chainConfig.IsYoloV3(vmContext.BlockNumber) && tx.Type() != types.LegacyTxId { + log.Info("rejected tx", "index", i, "hash", tx.Hash(), "error", core.ErrTxTypeNotSupported) + rejectedTxs = append(rejectedTxs, i) + continue + } + snapshot := statedb.Snapshot() + evm := vm.NewEVM(vmContext, txContext, statedb, chainConfig, vmConfig) if chainConfig.IsYoloV3(vmContext.BlockNumber) { - statedb.AddAddressToAccessList(msg.From()) - if dst := msg.To(); dst != nil { - statedb.AddAddressToAccessList(*dst) - // If it's a create-tx, the destination will be added inside evm.create - } - for _, addr := range evm.ActivePrecompiles() { - statedb.AddAddressToAccessList(addr) - } - if al := msg.AccessList(); al != nil { - for _, el := range *al { - statedb.AddAddressToAccessList(*el.Address) - for _, key := range el.StorageKeys { - statedb.AddSlotToAccessList(*el.Address, *key) - } - } - } - } else { - if tx.Type() != types.LegacyTxId { - log.Info("rejected tx", "index", i, "hash", tx.Hash(), "error", core.ErrTxTypeNotSupported) - rejectedTxs = append(rejectedTxs, i) - continue - } + statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) } - snapshot := statedb.Snapshot() + // (ret []byte, usedGas uint64, failed bool, err error) msgResult, err := core.ApplyMessage(evm, msg, gaspool) if err != nil { diff --git a/core/state/statedb.go b/core/state/statedb.go index 8fd066e24fec..c9b10750fe87 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -983,6 +983,34 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { return root, err } +// PrepareAccessList handles the preparatory steps for executing a state transition with +// regards to both EIP-2929 and EIP-2930: +// - Add sender to access list (2929) +// - Add destination to access list (2929) +// - Add precompiles to access list (2929) +// - Add the contents of the optional tx access list (2930) +// This method should only be called if Yolov3/Berlin/2929+2930 is applicable at +// the current number +func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, + precompiles []common.Address, accessList *types.AccessList) { + s.AddAddressToAccessList(sender) + if dst != nil { + s.AddAddressToAccessList(*dst) + // If it's a create-tx, the destination will be added inside evm.create + } + for _, addr := range precompiles { + s.AddAddressToAccessList(addr) + } + if accessList != nil { + for _, el := range *accessList { + s.AddAddressToAccessList(*el.Address) + for _, key := range el.StorageKeys { + s.AddSlotToAccessList(*el.Address, *key) + } + } + } +} + // AddAddressToAccessList adds the given address to the access list func (s *StateDB) AddAddressToAccessList(addr common.Address) { if s.accessList.AddAddress(addr) { diff --git a/core/state_processor.go b/core/state_processor.go index 6dc8ceff7b8c..d21f62303e8b 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -97,22 +97,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon txContext := NewEVMTxContext(msg) // Add addresses to access list if applicable if config.IsYoloV3(header.Number) { - statedb.AddAddressToAccessList(msg.From()) - if dst := msg.To(); dst != nil { - statedb.AddAddressToAccessList(*dst) - // If it's a create-tx, the destination will be added inside evm.create - } - for _, addr := range evm.ActivePrecompiles() { - statedb.AddAddressToAccessList(addr) - } - if al := msg.AccessList(); al != nil { - for _, el := range *al { - statedb.AddAddressToAccessList(*el.Address) - for _, key := range el.StorageKeys { - statedb.AddSlotToAccessList(*el.Address, *key) - } - } - } + statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) } // Update the evm with the new transaction context. diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 7cdb4ebd2284..c97bdc420c43 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -114,11 +114,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) { sender = vm.AccountRef(cfg.Origin) ) if cfg.ChainConfig.IsYoloV3(vmenv.Context.BlockNumber) { - cfg.State.AddAddressToAccessList(cfg.Origin) - cfg.State.AddAddressToAccessList(address) - for _, addr := range vmenv.ActivePrecompiles() { - cfg.State.AddAddressToAccessList(addr) - } + cfg.State.PrepareAccessList(cfg.Origin, &address, vmenv.ActivePrecompiles(), nil) } cfg.State.CreateAccount(address) // set the receiver's (the executing contract) code for execution. @@ -150,10 +146,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) { sender = vm.AccountRef(cfg.Origin) ) if cfg.ChainConfig.IsYoloV3(vmenv.Context.BlockNumber) { - cfg.State.AddAddressToAccessList(cfg.Origin) - for _, addr := range vmenv.ActivePrecompiles() { - cfg.State.AddAddressToAccessList(addr) - } + cfg.State.PrepareAccessList(cfg.Origin, nil, vmenv.ActivePrecompiles(), nil) } // Call the code with the given configuration. @@ -177,12 +170,9 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er vmenv := NewEnv(cfg) sender := cfg.State.GetOrNewStateObject(cfg.Origin) + statedb := cfg.State if cfg.ChainConfig.IsYoloV3(vmenv.Context.BlockNumber) { - cfg.State.AddAddressToAccessList(cfg.Origin) - cfg.State.AddAddressToAccessList(address) - for _, addr := range vmenv.ActivePrecompiles() { - cfg.State.AddAddressToAccessList(addr) - } + statedb.PrepareAccessList(cfg.Origin, &address, vmenv.ActivePrecompiles(), nil) } // Call the code with the given configuration. diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 128397eadf9f..b8d789ad46f1 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -757,22 +757,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, vmctx vm.Bloc vmenv := vm.NewEVM(vmctx, txContext, statedb, api.backend.ChainConfig(), vm.Config{Debug: true, Tracer: tracer}) if api.backend.ChainConfig().IsYoloV3(vmctx.BlockNumber) { - statedb.AddAddressToAccessList(message.From()) - if dst := message.To(); dst != nil { - statedb.AddAddressToAccessList(*dst) - // If it's a create-tx, the destination will be added inside evm.create - } - for _, addr := range vmenv.ActivePrecompiles() { - statedb.AddAddressToAccessList(addr) - } - if al := message.AccessList(); al != nil { - for _, el := range *al { - statedb.AddAddressToAccessList(*el.Address) - for _, key := range el.StorageKeys { - statedb.AddSlotToAccessList(*el.Address, *key) - } - } - } + statedb.PrepareAccessList(message.From(), message.To(), vmenv.ActivePrecompiles(), message.AccessList()) } result, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 67ff64479038..13f2a8b4f12a 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -872,25 +872,9 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo // Setup the gas pool (also for unmetered requests) // and apply the message. gp := new(core.GasPool).AddGas(math.MaxUint64) - // TODO! Refactor this check to some better place -- right now it's copy-pasted - // all over the place + // Apply access list if evm.ChainConfig().IsYoloV3(header.Number) { - state.AddAddressToAccessList(msg.From()) - if dst := msg.To(); dst != nil { - state.AddAddressToAccessList(*dst) - // If it's a create-tx, the destination will be added inside evm.create - } - for _, addr := range evm.ActivePrecompiles() { - state.AddAddressToAccessList(addr) - } - if al := msg.AccessList(); al != nil { - for _, el := range *al { - state.AddAddressToAccessList(*el.Address) - for _, key := range el.StorageKeys { - state.AddSlotToAccessList(*el.Address, *key) - } - } - } + state.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) } result, err := core.ApplyMessage(evm, msg, gp) diff --git a/tests/state_test_util.go b/tests/state_test_util.go index bbb3c4573942..aaae03e2ba45 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -188,14 +188,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh evm := vm.NewEVM(context, txContext, statedb, config, vmconfig) if config.IsYoloV3(context.BlockNumber) { - statedb.AddAddressToAccessList(msg.From()) - if dst := msg.To(); dst != nil { - statedb.AddAddressToAccessList(*dst) - // If it's a create-tx, the destination will be added inside evm.create - } - for _, addr := range evm.ActivePrecompiles() { - statedb.AddAddressToAccessList(addr) - } + statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) } gaspool := new(core.GasPool) gaspool.AddGas(block.GasLimit()) From 68bfe72b50069d339891576b0d19af05112895ae Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 4 Feb 2021 09:32:01 +0100 Subject: [PATCH 15/83] cmd/geth: correct log output on yolov3 --- cmd/geth/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 5b27a20d9cd6..95613a258dc1 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -283,6 +283,9 @@ func prepare(ctx *cli.Context) { case ctx.GlobalIsSet(utils.GoerliFlag.Name): log.Info("Starting Geth on Görli testnet...") + case ctx.GlobalIsSet(utils.YoloV3Flag.Name): + log.Info("Starting Geth on YOLOv3 testnet...") + case ctx.GlobalIsSet(utils.DeveloperFlag.Name): log.Info("Starting Geth in ephemeral dev mode...") From ba9db2163de03f92a380ff14e19da044d362e092 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 9 Feb 2021 08:34:39 +0100 Subject: [PATCH 16/83] core/types: update tx signing hash according to https://github.com/ethereum/EIPs/pull/3253 --- core/types/block.go | 12 ++++++++++++ core/types/transaction_signing.go | 23 ++++++++++++----------- core/types/transaction_test.go | 28 ++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/core/types/block.go b/core/types/block.go index 8096ebb75516..9eff9c21c533 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -147,6 +147,18 @@ func rlpHash(x interface{}) (h common.Hash) { return h } +// prefixedRlpHash writes the prefix into the hasher before rlp-encoding the +// given interface. It's used for typed transactions. +func prefixedRlpHash(prefix []byte, x interface{}) (h common.Hash) { + sha := hasherPool.Get().(crypto.KeccakState) + defer hasherPool.Put(sha) + sha.Reset() + sha.Write(prefix) + rlp.Encode(sha, x) + sha.Read(h[:]) + return h +} + // EmptyBody returns true if there is no additional 'body' to complete the header // that is: no transactions and no uncles. func (h *Header) EmptyBody() bool { diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 660d0c159da8..b14dd612ec62 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -164,17 +164,18 @@ func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { s.chainId, uint(0), uint(0), }) case AccessListTxId: - return rlpHash([]interface{}{ - tx.Type(), - tx.ChainId(), - tx.Nonce(), - tx.GasPrice(), - tx.Gas(), - tx.To(), - tx.Value(), - tx.Data(), - tx.AccessList(), - }) + return prefixedRlpHash( + []byte{tx.Type()}, + []interface{}{ + tx.ChainId(), + tx.Nonce(), + tx.GasPrice(), + tx.Gas(), + tx.To(), + tx.Value(), + tx.Data(), + tx.AccessList(), + }) default: // This _should_ not happen, but in case someone sends in a bad // json struct via RPC, it's probably more prudent to return an diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 9fe37349d36f..ae8979d9131f 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -102,14 +102,38 @@ func TestTransactionEncode(t *testing.T) { func TestEIP2718TransactionSigHash(t *testing.T) { s := NewEIP2718Signer(big.NewInt(1)) - if s.Hash(emptyEip2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { + if s.Hash(emptyEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") { t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", s.Hash(emptyEip2718Tx)) } - if s.Hash(signedEip2718Tx) != common.HexToHash("c44faa8f50803df8edd97e72c4dbae32343b2986c91e382fc3e329e6c9a36f31") { + if s.Hash(signedEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") { t.Errorf("signed EIP-2718 transaction hash mismatch, got %x", s.Hash(signedEip2718Tx)) } } +func TestEIP2718SigHashes(t *testing.T) { + // the signer chainid doesn't matter for the sighash + signer := NewEIP2718Signer(big.NewInt(0)) + for i, tc := range []struct { + rlpData string + sigHash common.Hash + fullHash common.Hash + }{ + { + rlpData: "0xb8a701f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9", + sigHash: common.HexToHash("0xf8eb2089f9add782b02e4c0ce41540817688bf579c14736576cb1d6d562c2f6b"), + fullHash: common.HexToHash("0x212a85be428a85d00fb5335b013bc8d3cf7511ffdd8938de768f4ca8bf1caf50"), + }, + } { + var tx Transaction + rlp.DecodeBytes(common.FromHex(tc.rlpData), &tx) + hash := tx.Hash() + sigHash := signer.Hash(&tx) + if sigHash != tc.sigHash || hash != tc.fullHash { + t.Fatalf("test %d: got\nsighash %x want %x\nhash: %x want %x\n", i, sigHash, tc.sigHash, hash, tc.fullHash) + } + } +} + func TestEIP2718TransactionEncode(t *testing.T) { txb, err := rlp.EncodeToBytes(signedEip2718Tx) if err != nil { From 852ffce8db59fef75cb77ca73185e11f13dab5f2 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 10 Feb 2021 08:35:00 +0100 Subject: [PATCH 17/83] core/types: add test for input to derivesha --- core/types/transaction_test.go | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index ae8979d9131f..c81111b54c3b 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -134,6 +134,46 @@ func TestEIP2718SigHashes(t *testing.T) { } } +type hashToHumanReadable struct { + data []byte +} + +func (d *hashToHumanReadable) Reset() { + d.data = make([]byte, 0) +} + +func (d *hashToHumanReadable) Update(i []byte, i2 []byte) { + l := fmt.Sprintf("%x %x\n", i, i2) + d.data = append(d.data, []byte(l)...) +} + +func (d *hashToHumanReadable) Hash() common.Hash { + return common.Hash{} +} + +// TestEIP2718DeriveSha tests that the input to the DeriveSha function is correct +func TestEIP2718DeriveSha(t *testing.T) { + for _, tc := range []struct { + rlpData string + exp string + }{ + { + rlpData: "0xb8a701f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9", + exp: "01 01f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9\n80 01f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9\n", + }, + } { + d := &hashToHumanReadable{} + var t1, t2 Transaction + rlp.DecodeBytes(common.FromHex(tc.rlpData), &t1) + rlp.DecodeBytes(common.FromHex(tc.rlpData), &t2) + var txs Transactions = Transactions{&t1, &t2} + DeriveSha(txs, d) + if tc.exp != string(d.data) { + t.Fatalf("Want\n%v\nhave:\n%v", tc.exp, string(d.data)) + } + } +} + func TestEIP2718TransactionEncode(t *testing.T) { txb, err := rlp.EncodeToBytes(signedEip2718Tx) if err != nil { From 4d236b17e99e33dbf25a60c28f50fbae6a622355 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 11 Feb 2021 15:51:26 +0100 Subject: [PATCH 18/83] core/types: use switch --- core/types/transaction.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index cc754c536d1d..b7eeaadc5f66 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -106,26 +106,26 @@ func (tx *Transaction) EncodeRLP(w io.Writer) error { // DecodeRLP implements rlp.Decoder func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { - var size uint64 - // If the tx isn't an RLP list, it's likely typed so pop off the first byte. kind, size, err := s.Kind() - if err != nil { + switch { + case err != nil: return err - } else if kind == rlp.List { + case kind == rlp.List: + // It's a legacy transaction. tx.typ = LegacyTxId var i *LegacyTransaction err = s.Decode(&i) tx.inner = i - } else if kind == rlp.String { + size = rlp.ListSize(size) + case kind == rlp.String: + // It's an EIP-2718 typed TX envelope. var b []byte - b, err = s.Bytes() + b, err := s.Bytes() if err != nil { return err } - - tx.typ = b[0] size = uint64(len(b)) - + tx.typ = b[0] if tx.typ == AccessListTxId { var i *AccessListTransaction err = rlp.DecodeBytes(b[1:], &i) @@ -133,15 +133,14 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { } else { return ErrTxTypeNotSupported } - } else { + default: return rlp.ErrExpectedList } if err == nil { - tx.size.Store(common.StorageSize(rlp.ListSize(size))) + tx.size.Store(common.StorageSize(size)) tx.time = time.Now() } - return err } From ee783aae6796b417206d64c48c49acfbd7c6aa01 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 11 Feb 2021 15:52:56 +0100 Subject: [PATCH 19/83] core/types: clean up encoder --- core/types/transaction.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index b7eeaadc5f66..7d71346dcfea 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -94,11 +94,9 @@ func (tx *Transaction) EncodeRLP(w io.Writer) error { if tx.typ == LegacyTxId { return rlp.Encode(w, tx.inner) } - buf := new(bytes.Buffer) - if _, err := buf.Write([]byte{tx.typ}); err != nil { - return err - } - if err := rlp.Encode(buf, tx.inner); err != nil { + var buf bytes.Buffer + buf.WriteByte(tx.typ) + if err := rlp.Encode(&buf, tx.inner); err != nil { return err } return rlp.Encode(w, buf.Bytes()) From 11468edad5d5ce1991cb17008c6df149060c371c Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 11 Feb 2021 15:58:20 +0100 Subject: [PATCH 20/83] core/types: clean up WithSignature --- core/types/transaction.go | 53 ++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 7d71346dcfea..dbaa1f95fcf7 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -212,32 +212,25 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e if err != nil { return nil, err } - - var ret *Transaction - if tx.typ == LegacyTxId { + // Copy inner transaction. + var cpy inner + switch tx.typ { + case LegacyTxId: inner := tx.inner.(*LegacyTransaction) - cpy := &LegacyTransaction{ + cpy = &LegacyTransaction{ AccountNonce: inner.AccountNonce, Price: inner.Price, GasLimit: inner.GasLimit, Recipient: inner.Recipient, Amount: inner.Amount, Payload: inner.Payload, - - V: inner.V, - R: inner.R, - S: inner.S, - } - cpy.R, cpy.S, cpy.V = r, s, v - - ret = &Transaction{ - typ: LegacyTxId, - inner: cpy, - time: tx.time, + V: v, + R: r, + S: s, } - } else if tx.typ == AccessListTxId { + case AccessListTxId: inner := tx.inner.(*AccessListTransaction) - cpy := &AccessListTransaction{ + cpy = &AccessListTransaction{ Chain: inner.Chain, AccountNonce: inner.AccountNonce, Price: inner.Price, @@ -246,31 +239,27 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e Amount: inner.Amount, Payload: inner.Payload, Accesses: inner.Accesses, - - V: inner.V, - R: inner.R, - S: inner.S, - } - cpy.R, cpy.S, cpy.V = r, s, v - - ret = &Transaction{ - typ: AccessListTxId, - inner: cpy, - time: tx.time, + V: v, + R: r, + S: s, } - - } else { + default: return nil, ErrInvalidTxType } - + // Copy outer transaction. + ret := &Transaction{typ: tx.typ, inner: cpy, time: tx.time} return ret, nil } + func (tx *Transaction) Cost() *big.Int { total := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())) total.Add(total, tx.Value()) return total } -func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { return tx.inner.RawSignatureValues() } + +func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { + return tx.inner.RawSignatureValues() +} // Raw transactions are used for internal processes which need the raw // consensus representation of typed transactions, not the RLP string From c6d18811942e67be049b7c34cf0ee82ffa27fbbf Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 11 Feb 2021 19:08:44 +0100 Subject: [PATCH 21/83] core/types: implement DeriveSha in a diffent way --- core/types/block.go | 33 +-------- core/types/derive_sha.go | 58 ---------------- core/types/hashing.go | 112 ++++++++++++++++++++++++++++++ core/types/receipt.go | 12 ++-- core/types/transaction.go | 64 ++++++++--------- core/types/transaction_signing.go | 2 +- 6 files changed, 147 insertions(+), 134 deletions(-) delete mode 100644 core/types/derive_sha.go create mode 100644 core/types/hashing.go diff --git a/core/types/block.go b/core/types/block.go index 9eff9c21c533..553db003bbbf 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -23,15 +23,12 @@ import ( "io" "math/big" "reflect" - "sync" "sync/atomic" "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" - "golang.org/x/crypto/sha3" ) var ( @@ -131,34 +128,6 @@ func (h *Header) SanityCheck() error { return nil } -// hasherPool holds LegacyKeccak hashers. -var hasherPool = sync.Pool{ - New: func() interface{} { - return sha3.NewLegacyKeccak256() - }, -} - -func rlpHash(x interface{}) (h common.Hash) { - sha := hasherPool.Get().(crypto.KeccakState) - defer hasherPool.Put(sha) - sha.Reset() - rlp.Encode(sha, x) - sha.Read(h[:]) - return h -} - -// prefixedRlpHash writes the prefix into the hasher before rlp-encoding the -// given interface. It's used for typed transactions. -func prefixedRlpHash(prefix []byte, x interface{}) (h common.Hash) { - sha := hasherPool.Get().(crypto.KeccakState) - defer hasherPool.Put(sha) - sha.Reset() - sha.Write(prefix) - rlp.Encode(sha, x) - sha.Read(h[:]) - return h -} - // EmptyBody returns true if there is no additional 'body' to complete the header // that is: no transactions and no uncles. func (h *Header) EmptyBody() bool { @@ -233,7 +202,7 @@ type storageblock struct { // The values of TxHash, UncleHash, ReceiptHash and Bloom in header // are ignored and set to values derived from the given txs, uncles // and receipts. -func NewBlock(header *Header, txs []*Transaction, uncles []*Header, receipts []*Receipt, hasher Hasher) *Block { +func NewBlock(header *Header, txs []*Transaction, uncles []*Header, receipts []*Receipt, hasher TrieHasher) *Block { b := &Block{header: CopyHeader(header), td: new(big.Int)} // TODO: panic if len(txs) != len(receipts) diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go deleted file mode 100644 index 51a10f3f3da7..000000000000 --- a/core/types/derive_sha.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2014 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 ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/rlp" -) - -type DerivableList interface { - Len() int - GetRlp(i int) []byte -} - -// Hasher is the tool used to calculate the hash of derivable list. -type Hasher interface { - Reset() - Update([]byte, []byte) - Hash() common.Hash -} - -func DeriveSha(list DerivableList, hasher Hasher) common.Hash { - hasher.Reset() - - // StackTrie requires values to be inserted in increasing - // hash order, which is not the order that `list` provides - // hashes in. This insertion sequence ensures that the - // order is correct. - - var buf []byte - for i := 1; i < list.Len() && i <= 0x7f; i++ { - buf = rlp.AppendUint64(buf[:0], uint64(i)) - hasher.Update(buf, list.GetRlp(i)) - } - if list.Len() > 0 { - buf = rlp.AppendUint64(buf[:0], 0) - hasher.Update(buf, list.GetRlp(0)) - } - for i := 0x80; i < list.Len(); i++ { - buf = rlp.AppendUint64(buf[:0], uint64(i)) - hasher.Update(buf, list.GetRlp(i)) - } - return hasher.Hash() -} diff --git a/core/types/hashing.go b/core/types/hashing.go new file mode 100644 index 000000000000..d786ec9a67b9 --- /dev/null +++ b/core/types/hashing.go @@ -0,0 +1,112 @@ +// Copyright 2014 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" + "sync" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/rlp" + "golang.org/x/crypto/sha3" +) + +// hasherPool holds LegacyKeccak256 hashers for rlpHash. +var hasherPool = sync.Pool{ + New: func() interface{} { return sha3.NewLegacyKeccak256() }, +} + +// deriveBufferPool holds temporary encoder buffers for DeriveSha and TX encoding. +var encodeBufferPool = sync.Pool{ + New: func() interface{} { return new(bytes.Buffer) }, +} + +func rlpHash(x interface{}) (h common.Hash) { + sha := hasherPool.Get().(crypto.KeccakState) + defer hasherPool.Put(sha) + sha.Reset() + rlp.Encode(sha, x) + sha.Read(h[:]) + return h +} + +// prefixedRlpHash writes the prefix into the hasher before rlp-encoding the +// given interface. It's used for typed transactions. +func prefixedRlpHash(prefix byte, x interface{}) (h common.Hash) { + sha := hasherPool.Get().(crypto.KeccakState) + defer hasherPool.Put(sha) + sha.Reset() + sha.Write([]byte{prefix}) + rlp.Encode(sha, x) + sha.Read(h[:]) + return h +} + +// TrieHasher is the tool used to calculate the hash of derivable list. +// This is internal, do not use. +type TrieHasher interface { + Reset() + Update([]byte, []byte) + Hash() common.Hash +} + +// DerivableList is the input to DeriveSha. +// It is implemented by the 'Transactions' and 'Receipts' types. +type DerivableList interface { + Len() int + encode(int, *bytes.Buffer) +} + +func encodeForDerive(list DerivableList, i int, buf *bytes.Buffer) []byte { + buf.Reset() + list.encode(i, buf) + // It's really unfortunate that we need to do perform this copy. + // StackTrie holds onto the values until Hash is called, so the values + // written to it must not alias. + return common.CopyBytes(buf.Bytes()) +} + +// DeriveSha creates the tree hashes of transactions and receipts in a block header. +func DeriveSha(list DerivableList, hasher TrieHasher) common.Hash { + hasher.Reset() + + valueBuf := encodeBufferPool.Get().(*bytes.Buffer) + defer encodeBufferPool.Put(valueBuf) + + // StackTrie requires values to be inserted in increasing hash order, which is not the + // order that `list` provides hashes in. This insertion sequence ensures that the + // order is correct. + var indexBuf []byte + for i := 1; i < list.Len() && i <= 0x7f; i++ { + indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(i)) + value := encodeForDerive(list, i, valueBuf) + hasher.Update(indexBuf, value) + } + if list.Len() > 0 { + indexBuf = rlp.AppendUint64(indexBuf[:0], 0) + value := encodeForDerive(list, 0, valueBuf) + hasher.Update(indexBuf, value) + } + for i := 0x80; i < list.Len(); i++ { + indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(i)) + value := encodeForDerive(list, i, valueBuf) + hasher.Update(indexBuf, value) + } + return hasher.Hash() +} + diff --git a/core/types/receipt.go b/core/types/receipt.go index 5068a753732d..825dd5f35b4e 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -299,19 +299,15 @@ func decodeV3StoredReceiptRLP(r *ReceiptForStorage, blob []byte) error { return nil } -// Receipts is a wrapper around a Receipt array to implement DerivableList. +// Receipts implements DerivableList for receipts. type Receipts []*Receipt // Len returns the number of receipts in this list. func (r Receipts) Len() int { return len(r) } -// GetRlp returns the RLP encoding of one receipt from the list. -func (r Receipts) GetRlp(i int) []byte { - bytes, err := rlp.EncodeToBytes(r[i]) - if err != nil { - panic(err) - } - return bytes +// encode encodes the i'th receipt to w. +func (r Receipts) encode(i int, w *bytes.Buffer) { + rlp.Encode(w, r[i]) } // DeriveFields fills the receipts with their computed fields based on consensus diff --git a/core/types/transaction.go b/core/types/transaction.go index dbaa1f95fcf7..90898bc6849f 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -88,12 +88,11 @@ func isProtectedV(V *big.Int) bool { } // EncodeRLP implements rlp.Encoder -// For legacy transactions, it outputs rlp(tx.inner). For typed transactions -// it outputs rlp(tx.type || tx.inner). func (tx *Transaction) EncodeRLP(w io.Writer) error { if tx.typ == LegacyTxId { return rlp.Encode(w, tx.inner) } + // It's an EIP-2718 typed TX envelope. var buf bytes.Buffer buf.WriteByte(tx.typ) if err := rlp.Encode(&buf, tx.inner); err != nil { @@ -114,7 +113,6 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { var i *LegacyTransaction err = s.Decode(&i) tx.inner = i - size = rlp.ListSize(size) case kind == rlp.String: // It's an EIP-2718 typed TX envelope. var b []byte @@ -122,7 +120,6 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { if err != nil { return err } - size = uint64(len(b)) tx.typ = b[0] if tx.typ == AccessListTxId { var i *AccessListTransaction @@ -136,6 +133,7 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { } if err == nil { + size = rlp.ListSize(size) tx.size.Store(common.StorageSize(size)) tx.time = time.Now() } @@ -172,24 +170,31 @@ func (tx *Transaction) Data() []byte { return tx.inner.Data() } func (tx *Transaction) AccessList() *AccessList { return tx.inner.AccessList() } func (tx *Transaction) Gas() uint64 { return tx.inner.Gas() } func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.inner.GasPrice()) } +func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.Value()) } +func (tx *Transaction) Nonce() uint64 { return tx.inner.Nonce() } +func (tx *Transaction) CheckNonce() bool { return true } +func (tx *Transaction) To() *common.Address { return tx.inner.To() } + func (tx *Transaction) GasPriceCmp(other *Transaction) int { return tx.inner.GasPrice().Cmp(other.GasPrice()) } + func (tx *Transaction) GasPriceIntCmp(other *big.Int) int { return tx.inner.GasPrice().Cmp(other) } -func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.Value()) } -func (tx *Transaction) Nonce() uint64 { return tx.inner.Nonce() } -func (tx *Transaction) CheckNonce() bool { return true } -func (tx *Transaction) To() *common.Address { return tx.inner.To() } + func (tx *Transaction) Hash() common.Hash { if hash := tx.hash.Load(); hash != nil { return hash.(common.Hash) } - n := rawtx(*tx) - h := rlpHash(&n) - tx.hash.Store(h) + var h common.Hash + if tx.typ == LegacyTxId { + h = rlpHash(tx.inner) + } else { + h = prefixedRlpHash(tx.typ, tx.inner) + } + tx.hash.Store(h) return h } @@ -261,35 +266,24 @@ func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { return tx.inner.RawSignatureValues() } -// Raw transactions are used for internal processes which need the raw -// consensus representation of typed transactions, not the RLP string -// wrapped version (e.g. type || payload vs. rlp(type || payload)). -type rawtx Transaction - -func (tx *rawtx) EncodeRLP(w io.Writer) error { - if tx.typ != LegacyTxId { - if _, err := w.Write([]byte{tx.typ}); err != nil { - return err - } - } - - return rlp.Encode(w, tx.inner) -} - -// Transactions is a Transaction slice type for basic sorting. +// Transactions implements DerivableList for transactions. type Transactions []*Transaction // Len returns the length of s. func (s Transactions) Len() int { return len(s) } -// Swap swaps the i'th and the j'th element in s. -func (s Transactions) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// GetRlp implements Rlpable and returns the i'th element of s in rlp. -func (s Transactions) GetRlp(i int) []byte { - raw := rawtx(*s[i]) - enc, _ := rlp.EncodeToBytes(&raw) - return enc +// encode encodes the i'th transaction to w. Note that this does not check for errors +// because we assume that *Transaction will only ever contain valid txs that were either +// constructed by decoding or via public API in this package. +func (s Transactions) encode(i int, w *bytes.Buffer) { + tx := s[i] + if tx.typ == LegacyTxId { + rlp.Encode(w, tx.inner) + } else { + // It's an EIP-2718 typed TX envelope. + w.WriteByte(tx.typ) + rlp.Encode(w, tx.inner) + } } // TxDifference returns a new set which is the difference between a and b. diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index b14dd612ec62..fb658e010ea9 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -165,7 +165,7 @@ func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { }) case AccessListTxId: return prefixedRlpHash( - []byte{tx.Type()}, + tx.Type(), []interface{}{ tx.ChainId(), tx.Nonce(), From 27b8e16fcd1d949a00c092f1fb7d6d878c6ee3cb Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 11 Feb 2021 19:10:06 +0100 Subject: [PATCH 22/83] core/types: rename inner -> innerTx and remove docs --- core/types/transaction.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 90898bc6849f..64e3f8f7c846 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -44,7 +44,7 @@ const ( type Transaction struct { typ uint8 // EIP-2718 transaction type identifier - inner inner // Consensus contents of a transaction + inner innerTx // Consensus contents of a transaction time time.Time // Time first seen locally (spam avoidance) // caches @@ -53,12 +53,10 @@ type Transaction struct { from atomic.Value } -type inner interface { - // ChainId returns which chain id this transaction was signed for (if at all) +// innerTx is the underlying data of a transaction. +type innerTx interface { ChainId() *big.Int - // Protected returns whether the transaction is protected from replay protection. Protected() bool - // AccessList returns the transactions optional EIP-2930 access list. AccessList() *AccessList Data() []byte Gas() uint64 @@ -66,11 +64,7 @@ type inner interface { Value() *big.Int Nonce() uint64 CheckNonce() bool - // To returns the recipient address of the transaction. - // It returns nil if the transaction is a contract creation. To() *common.Address - // RawSignatureValues returns the V, R, S signature values of the transaction. - // The return values should not be modified by the caller. RawSignatureValues() (v, r, s *big.Int) } @@ -218,7 +212,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e return nil, err } // Copy inner transaction. - var cpy inner + var cpy innerTx switch tx.typ { case LegacyTxId: inner := tx.inner.(*LegacyTransaction) From e3afa3429f17db93d479fdd72858032881edda6f Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 11 Feb 2021 19:11:09 +0100 Subject: [PATCH 23/83] core/types: use encoder buffer pool in EncodeRLP --- core/types/transaction.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 64e3f8f7c846..cc6fd33f20a7 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -87,9 +87,11 @@ func (tx *Transaction) EncodeRLP(w io.Writer) error { return rlp.Encode(w, tx.inner) } // It's an EIP-2718 typed TX envelope. - var buf bytes.Buffer + buf := encodeBufferPool.Get().(*bytes.Buffer) + defer encodeBufferPool.Put(buf) + buf.Reset() buf.WriteByte(tx.typ) - if err := rlp.Encode(&buf, tx.inner); err != nil { + if err := rlp.Encode(buf, tx.inner); err != nil { return err } return rlp.Encode(w, buf.Bytes()) From 00bd0f1afe542fb5ecb3ca4b018d038f714f6482 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 08:00:10 +0100 Subject: [PATCH 24/83] core/types: add DeriveSha tests from StackTrie --- core/types/hashing.go | 6 +- core/types/receipt.go | 4 +- core/types/transaction.go | 2 +- core/types/transaction_test.go | 40 -------- trie/stacktrie_test.go | 170 --------------------------------- 5 files changed, 6 insertions(+), 216 deletions(-) diff --git a/core/types/hashing.go b/core/types/hashing.go index d786ec9a67b9..71efb25a9aa9 100644 --- a/core/types/hashing.go +++ b/core/types/hashing.go @@ -67,14 +67,15 @@ type TrieHasher interface { // DerivableList is the input to DeriveSha. // It is implemented by the 'Transactions' and 'Receipts' types. +// This is internal, do not use these methods. type DerivableList interface { Len() int - encode(int, *bytes.Buffer) + EncodeIndex(int, *bytes.Buffer) } func encodeForDerive(list DerivableList, i int, buf *bytes.Buffer) []byte { buf.Reset() - list.encode(i, buf) + list.EncodeIndex(i, buf) // It's really unfortunate that we need to do perform this copy. // StackTrie holds onto the values until Hash is called, so the values // written to it must not alias. @@ -109,4 +110,3 @@ func DeriveSha(list DerivableList, hasher TrieHasher) common.Hash { } return hasher.Hash() } - diff --git a/core/types/receipt.go b/core/types/receipt.go index 825dd5f35b4e..6836fee5ae99 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -305,8 +305,8 @@ type Receipts []*Receipt // Len returns the number of receipts in this list. func (r Receipts) Len() int { return len(r) } -// encode encodes the i'th receipt to w. -func (r Receipts) encode(i int, w *bytes.Buffer) { +// EncodeIndex encodes the i'th receipt to w. +func (r Receipts) EncodeIndex(i int, w *bytes.Buffer) { rlp.Encode(w, r[i]) } diff --git a/core/types/transaction.go b/core/types/transaction.go index cc6fd33f20a7..6cd98c87850a 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -271,7 +271,7 @@ func (s Transactions) Len() int { return len(s) } // encode encodes the i'th transaction to w. Note that this does not check for errors // because we assume that *Transaction will only ever contain valid txs that were either // constructed by decoding or via public API in this package. -func (s Transactions) encode(i int, w *bytes.Buffer) { +func (s Transactions) EncodeIndex(i int, w *bytes.Buffer) { tx := s[i] if tx.typ == LegacyTxId { rlp.Encode(w, tx.inner) diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index c81111b54c3b..ae8979d9131f 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -134,46 +134,6 @@ func TestEIP2718SigHashes(t *testing.T) { } } -type hashToHumanReadable struct { - data []byte -} - -func (d *hashToHumanReadable) Reset() { - d.data = make([]byte, 0) -} - -func (d *hashToHumanReadable) Update(i []byte, i2 []byte) { - l := fmt.Sprintf("%x %x\n", i, i2) - d.data = append(d.data, []byte(l)...) -} - -func (d *hashToHumanReadable) Hash() common.Hash { - return common.Hash{} -} - -// TestEIP2718DeriveSha tests that the input to the DeriveSha function is correct -func TestEIP2718DeriveSha(t *testing.T) { - for _, tc := range []struct { - rlpData string - exp string - }{ - { - rlpData: "0xb8a701f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9", - exp: "01 01f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9\n80 01f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9\n", - }, - } { - d := &hashToHumanReadable{} - var t1, t2 Transaction - rlp.DecodeBytes(common.FromHex(tc.rlpData), &t1) - rlp.DecodeBytes(common.FromHex(tc.rlpData), &t2) - var txs Transactions = Transactions{&t1, &t2} - DeriveSha(txs, d) - if tc.exp != string(d.data) { - t.Fatalf("Want\n%v\nhave:\n%v", tc.exp, string(d.data)) - } - } -} - func TestEIP2718TransactionEncode(t *testing.T) { txb, err := rlp.EncodeToBytes(signedEip2718Tx) if err != nil { diff --git a/trie/stacktrie_test.go b/trie/stacktrie_test.go index d4488b4029c4..29706f2e9dd0 100644 --- a/trie/stacktrie_test.go +++ b/trie/stacktrie_test.go @@ -1,16 +1,9 @@ package trie import ( - "bytes" - "fmt" - "math/big" - mrand "math/rand" "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb/memorydb" ) @@ -78,169 +71,6 @@ func TestValLength56(t *testing.T) { } } -func genTxs(num uint64) (types.Transactions, error) { - key, err := crypto.HexToECDSA("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef") - if err != nil { - return nil, err - } - var addr = crypto.PubkeyToAddress(key.PublicKey) - newTx := func(i uint64) (*types.Transaction, error) { - signer := types.NewEIP155Signer(big.NewInt(18)) - tx, err := types.SignTx(types.NewTransaction(i, addr, new(big.Int), 0, new(big.Int).SetUint64(10000000), nil), signer, key) - return tx, err - } - var txs types.Transactions - for i := uint64(0); i < num; i++ { - tx, err := newTx(i) - if err != nil { - return nil, err - } - txs = append(txs, tx) - } - return txs, nil -} - -func TestDeriveSha(t *testing.T) { - txs, err := genTxs(0) - if err != nil { - t.Fatal(err) - } - for len(txs) < 1000 { - exp := types.DeriveSha(txs, newEmpty()) - got := types.DeriveSha(txs, NewStackTrie(nil)) - if !bytes.Equal(got[:], exp[:]) { - t.Fatalf("%d txs: got %x exp %x", len(txs), got, exp) - } - newTxs, err := genTxs(uint64(len(txs) + 1)) - if err != nil { - t.Fatal(err) - } - txs = append(txs, newTxs...) - } -} - -func BenchmarkDeriveSha200(b *testing.B) { - txs, err := genTxs(200) - if err != nil { - b.Fatal(err) - } - var exp common.Hash - var got common.Hash - b.Run("std_trie", func(b *testing.B) { - b.ResetTimer() - b.ReportAllocs() - for i := 0; i < b.N; i++ { - exp = types.DeriveSha(txs, newEmpty()) - } - }) - - b.Run("stack_trie", func(b *testing.B) { - b.ResetTimer() - b.ReportAllocs() - for i := 0; i < b.N; i++ { - got = types.DeriveSha(txs, NewStackTrie(nil)) - } - }) - if got != exp { - b.Errorf("got %x exp %x", got, exp) - } -} - -type dummyDerivableList struct { - len int - seed int -} - -func newDummy(seed int) *dummyDerivableList { - d := &dummyDerivableList{} - src := mrand.NewSource(int64(seed)) - // don't use lists longer than 4K items - d.len = int(src.Int63() & 0x0FFF) - d.seed = seed - return d -} - -func (d *dummyDerivableList) Len() int { - return d.len -} - -func (d *dummyDerivableList) GetRlp(i int) []byte { - src := mrand.NewSource(int64(d.seed + i)) - // max item size 256, at least 1 byte per item - size := 1 + src.Int63()&0x00FF - data := make([]byte, size) - _, err := mrand.New(src).Read(data) - if err != nil { - panic(err) - } - return data -} - -func printList(l types.DerivableList) { - fmt.Printf("list length: %d\n", l.Len()) - fmt.Printf("{\n") - for i := 0; i < l.Len(); i++ { - v := l.GetRlp(i) - fmt.Printf("\"0x%x\",\n", v) - } - fmt.Printf("},\n") -} - -func TestFuzzDeriveSha(t *testing.T) { - // increase this for longer runs -- it's set to quite low for travis - rndSeed := mrand.Int() - for i := 0; i < 10; i++ { - seed := rndSeed + i - exp := types.DeriveSha(newDummy(i), newEmpty()) - got := types.DeriveSha(newDummy(i), NewStackTrie(nil)) - if !bytes.Equal(got[:], exp[:]) { - printList(newDummy(seed)) - t.Fatalf("seed %d: got %x exp %x", seed, got, exp) - } - } -} - -type flatList struct { - rlpvals []string -} - -func newFlatList(rlpvals []string) *flatList { - return &flatList{rlpvals} -} -func (f *flatList) Len() int { - return len(f.rlpvals) -} -func (f *flatList) GetRlp(i int) []byte { - return hexutil.MustDecode(f.rlpvals[i]) -} - -// TestDerivableList contains testcases found via fuzzing -func TestDerivableList(t *testing.T) { - type tcase []string - tcs := []tcase{ - { - "0xc041", - }, - { - "0xf04cf757812428b0763112efb33b6f4fad7deb445e", - "0xf04cf757812428b0763112efb33b6f4fad7deb445e", - }, - { - "0xca410605310cdc3bb8d4977ae4f0143df54a724ed873457e2272f39d66e0460e971d9d", - "0x6cd850eca0a7ac46bb1748d7b9cb88aa3bd21c57d852c28198ad8fa422c4595032e88a4494b4778b36b944fe47a52b8c5cd312910139dfcb4147ab8e972cc456bcb063f25dd78f54c4d34679e03142c42c662af52947d45bdb6e555751334ace76a5080ab5a0256a1d259855dfc5c0b8023b25befbb13fd3684f9f755cbd3d63544c78ee2001452dd54633a7593ade0b183891a0a4e9c7844e1254005fbe592b1b89149a502c24b6e1dca44c158aebedf01beae9c30cabe16a", - "0x14abd5c47c0be87b0454596baad2", - "0xca410605310cdc3bb8d4977ae4f0143df54a724ed873457e2272f39d66e0460e971d9d", - }, - } - for i, tc := range tcs[1:] { - exp := types.DeriveSha(newFlatList(tc), newEmpty()) - got := types.DeriveSha(newFlatList(tc), NewStackTrie(nil)) - if !bytes.Equal(got[:], exp[:]) { - t.Fatalf("case %d: got %x exp %x", i, got, exp) - } - } -} - // TestUpdateSmallNodes tests a case where the leaves are small (both key and value), // which causes a lot of node-within-node. This case was found via fuzzing. func TestUpdateSmallNodes(t *testing.T) { From c98086626249b9498973a084baf0bd4ebf9c55be Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 08:23:11 +0100 Subject: [PATCH 25/83] core/types: fix ineffectual assignment --- core/types/transaction.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 6cd98c87850a..e1e2f7e368f6 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -112,8 +112,7 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { case kind == rlp.String: // It's an EIP-2718 typed TX envelope. var b []byte - b, err := s.Bytes() - if err != nil { + if b, err = s.Bytes(); err != nil { return err } tx.typ = b[0] From a25bc3809e97030c0e8d25491ea5ac51527d1975 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 08:49:44 +0100 Subject: [PATCH 26/83] core/types: update receipt RLP handling --- core/types/receipt.go | 88 +++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/core/types/receipt.go b/core/types/receipt.go index 6836fee5ae99..462fde87e106 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -133,37 +133,64 @@ func NewEIP2718Receipt(typ uint8, root []byte, failed bool, cumulativeGasUsed ui // EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt // into an RLP stream. If no post state is present, byzantium fork is assumed. func (r *Receipt) EncodeRLP(w io.Writer) error { - if r.Type != LegacyTxId { - if _, err := w.Write([]byte{r.Type}); err != nil { - return err - } + data := &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs} + if r.Type == LegacyTxId { + return rlp.Encode(w, data) + } + // It's an EIP-2718 typed TX receipt. + if r.Type != AccessListTxId { + return ErrTxTypeNotSupported } - return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs}) + buf := encodeBufferPool.Get().(*bytes.Buffer) + defer encodeBufferPool.Put(buf) + buf.Reset() + buf.WriteByte(r.Type) + if err := rlp.Encode(buf, data); err != nil { + return err + } + return rlp.Encode(w, buf.Bytes()) } // DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt // from an RLP stream. func (r *Receipt) DecodeRLP(s *rlp.Stream) error { - typ := uint64(LegacyTxId) - k, _, err := s.Kind() - if err != nil { + kind, _, err := s.Kind() + switch { + case err != nil: return err - } - // If the receipt isn't a list, it's likely typed - so pop off the first byte. - if k != rlp.List { - if typ, err = s.Uint(); err != nil { + case kind == rlp.List: + // It's a legacy receipt. + var dec receiptRLP + if err := s.Decode(&dec); err != nil { return err } + var r Receipt + r.Type = LegacyTxId + return r.setFromRLP(dec) + case kind == rlp.String: + // It's an EIP-2718 typed tx receipt. + b, err := s.Bytes() + if err != nil { + return err + } + var r Receipt + r.Type = b[0] + if r.Type == AccessListTxId { + var dec receiptRLP + if err := rlp.DecodeBytes(b[1:], &dec); err != nil { + return err + } + return r.setFromRLP(dec) + } + return ErrTxTypeNotSupported + default: + return rlp.ErrExpectedList } - var dec receiptRLP - if err := s.Decode(&dec); err != nil { - return err - } - if err := r.setStatus(dec.PostStateOrStatus); err != nil { - return err - } - r.Type, r.CumulativeGasUsed, r.Bloom, r.Logs = uint8(typ), dec.CumulativeGasUsed, dec.Bloom, dec.Logs - return nil +} + +func (r *Receipt) setFromRLP(data receiptRLP) error { + r.CumulativeGasUsed, r.Bloom, r.Logs = data.CumulativeGasUsed, data.Bloom, data.Logs + return r.setStatus(data.PostStateOrStatus) } func (r *Receipt) setStatus(postStateOrStatus []byte) error { @@ -194,7 +221,6 @@ func (r *Receipt) statusEncoding() []byte { // to approximate and limit the memory consumption of various caches. func (r *Receipt) Size() common.StorageSize { size := common.StorageSize(unsafe.Sizeof(*r)) + common.StorageSize(len(r.PostState)) - size += common.StorageSize(len(r.Logs)) * common.StorageSize(unsafe.Sizeof(Log{})) for _, log := range r.Logs { size += common.StorageSize(len(log.Topics)*common.HashLength + len(log.Data)) @@ -303,11 +329,23 @@ func decodeV3StoredReceiptRLP(r *ReceiptForStorage, blob []byte) error { type Receipts []*Receipt // Len returns the number of receipts in this list. -func (r Receipts) Len() int { return len(r) } +func (rs Receipts) Len() int { return len(rs) } // EncodeIndex encodes the i'th receipt to w. -func (r Receipts) EncodeIndex(i int, w *bytes.Buffer) { - rlp.Encode(w, r[i]) +func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) { + r := rs[i] + data := &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs} + switch r.Type { + case LegacyTxId: + rlp.Encode(w, data) + case AccessListTxId: + w.WriteByte(AccessListTxId) + rlp.Encode(w, data) + default: + // For unsupported types, write nothing. Since this is for + // DeriveSha, the error will be caught matching the derived hash + // to the block. + } } // DeriveFields fills the receipts with their computed fields based on consensus From 27f966fcda8eaeeb2074dc7888fbb895618ca68f Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 08:54:40 +0100 Subject: [PATCH 27/83] core/types: fix crash when decoding empty typed tx / receipt --- core/types/receipt.go | 5 +++++ core/types/receipt_test.go | 9 +++++++++ core/types/transaction.go | 4 ++++ core/types/transaction_test.go | 9 +++++++++ 4 files changed, 27 insertions(+) diff --git a/core/types/receipt.go b/core/types/receipt.go index 462fde87e106..cb44409804ae 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -38,6 +38,8 @@ var ( receiptStatusSuccessfulRLP = []byte{0x01} ) +var errEmptyTypedReceipt = errors.New("empty typed receipt bytes") + const ( // ReceiptStatusFailed is the status code of a transaction if execution failed. ReceiptStatusFailed = uint64(0) @@ -173,6 +175,9 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error { if err != nil { return err } + if len(b) == 0 { + return errEmptyTypedReceipt + } var r Receipt r.Type = b[0] if r.Type == AccessListTxId { diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index e4d407fe24a7..e35c8d3e6370 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -29,6 +29,15 @@ import ( "github.com/ethereum/go-ethereum/rlp" ) +func TestDecodeEmptyTypedReceipt(t *testing.T) { + input := []byte{0x80} + var r Receipt + err := rlp.DecodeBytes(input, &r) + if err != errEmptyTypedReceipt { + t.Fatal("wrong error:", err) + } +} + func TestLegacyReceiptDecoding(t *testing.T) { tests := []struct { name string diff --git a/core/types/transaction.go b/core/types/transaction.go index e1e2f7e368f6..5e2edc6440a3 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -35,6 +35,7 @@ var ( ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures") ErrInvalidTxType = errors.New("transaction type not valid in this context") ErrTxTypeNotSupported = errors.New("transaction type not supported") + errEmptyTypedTx = errors.New("empty typed transaction bytes") ) const ( @@ -115,6 +116,9 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { if b, err = s.Bytes(); err != nil { return err } + if len(b) == 0 { + return errEmptyTypedTx + } tx.typ = b[0] if tx.typ == AccessListTxId { var i *AccessListTransaction diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index ae8979d9131f..23ea40bbb62e 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -79,6 +79,15 @@ var ( ) ) +func TestDecodeEmptyTypedTx(t *testing.T) { + input := []byte{0x80} + var tx Transaction + err := rlp.DecodeBytes(input, &tx) + if err != errEmptyTypedTx { + t.Fatal("wrong error:", err) + } +} + func TestTransactionSigHash(t *testing.T) { var homestead HomesteadSigner if homestead.Hash(emptyTx) != common.HexToHash("c775b99e7ad12f50d819fcd602390467e28141316969f4b57f0626f74fe3b386") { From 94feb0fc7de96109f40cd81c6a03ee415172c433 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 11:51:06 +0100 Subject: [PATCH 28/83] core/types: add missing tests --- core/types/hashing_test.go | 212 +++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 core/types/hashing_test.go diff --git a/core/types/hashing_test.go b/core/types/hashing_test.go new file mode 100644 index 000000000000..a948b10ef66e --- /dev/null +++ b/core/types/hashing_test.go @@ -0,0 +1,212 @@ +package types_test + +import ( + "bytes" + "fmt" + "io" + "math/big" + mrand "math/rand" + "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" +) + +func TestDeriveSha(t *testing.T) { + txs, err := genTxs(0) + if err != nil { + t.Fatal(err) + } + for len(txs) < 1000 { + exp := types.DeriveSha(txs, new(trie.Trie)) + got := types.DeriveSha(txs, trie.NewStackTrie(nil)) + if !bytes.Equal(got[:], exp[:]) { + t.Fatalf("%d txs: got %x exp %x", len(txs), got, exp) + } + newTxs, err := genTxs(uint64(len(txs) + 1)) + if err != nil { + t.Fatal(err) + } + txs = append(txs, newTxs...) + } +} + +// TestEIP2718DeriveSha tests that the input to the DeriveSha function is correct. +func TestEIP2718DeriveSha(t *testing.T) { + for _, tc := range []struct { + rlpData string + exp string + }{ + { + rlpData: "0xb8a701f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9", + exp: "01 01f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9\n80 01f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9\n", + }, + } { + d := &hashToHumanReadable{} + var t1, t2 types.Transaction + rlp.DecodeBytes(common.FromHex(tc.rlpData), &t1) + rlp.DecodeBytes(common.FromHex(tc.rlpData), &t2) + txs := types.Transactions{&t1, &t2} + types.DeriveSha(txs, d) + if tc.exp != string(d.data) { + t.Fatalf("Want\n%v\nhave:\n%v", tc.exp, string(d.data)) + } + } +} + +func BenchmarkDeriveSha200(b *testing.B) { + txs, err := genTxs(200) + if err != nil { + b.Fatal(err) + } + var exp common.Hash + var got common.Hash + b.Run("std_trie", func(b *testing.B) { + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + exp = types.DeriveSha(txs, new(trie.Trie)) + } + }) + + b.Run("stack_trie", func(b *testing.B) { + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + got = types.DeriveSha(txs, trie.NewStackTrie(nil)) + } + }) + if got != exp { + b.Errorf("got %x exp %x", got, exp) + } +} + +func TestFuzzDeriveSha(t *testing.T) { + // increase this for longer runs -- it's set to quite low for travis + rndSeed := mrand.Int() + for i := 0; i < 10; i++ { + seed := rndSeed + i + exp := types.DeriveSha(newDummy(i), new(trie.Trie)) + got := types.DeriveSha(newDummy(i), trie.NewStackTrie(nil)) + if !bytes.Equal(got[:], exp[:]) { + printList(newDummy(seed)) + t.Fatalf("seed %d: got %x exp %x", seed, got, exp) + } + } +} + +// TestDerivableList contains testcases found via fuzzing +func TestDerivableList(t *testing.T) { + type tcase []string + tcs := []tcase{ + { + "0xc041", + }, + { + "0xf04cf757812428b0763112efb33b6f4fad7deb445e", + "0xf04cf757812428b0763112efb33b6f4fad7deb445e", + }, + { + "0xca410605310cdc3bb8d4977ae4f0143df54a724ed873457e2272f39d66e0460e971d9d", + "0x6cd850eca0a7ac46bb1748d7b9cb88aa3bd21c57d852c28198ad8fa422c4595032e88a4494b4778b36b944fe47a52b8c5cd312910139dfcb4147ab8e972cc456bcb063f25dd78f54c4d34679e03142c42c662af52947d45bdb6e555751334ace76a5080ab5a0256a1d259855dfc5c0b8023b25befbb13fd3684f9f755cbd3d63544c78ee2001452dd54633a7593ade0b183891a0a4e9c7844e1254005fbe592b1b89149a502c24b6e1dca44c158aebedf01beae9c30cabe16a", + "0x14abd5c47c0be87b0454596baad2", + "0xca410605310cdc3bb8d4977ae4f0143df54a724ed873457e2272f39d66e0460e971d9d", + }, + } + for i, tc := range tcs[1:] { + exp := types.DeriveSha(flatList(tc), new(trie.Trie)) + got := types.DeriveSha(flatList(tc), trie.NewStackTrie(nil)) + if !bytes.Equal(got[:], exp[:]) { + t.Fatalf("case %d: got %x exp %x", i, got, exp) + } + } +} + +func genTxs(num uint64) (types.Transactions, error) { + key, err := crypto.HexToECDSA("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef") + if err != nil { + return nil, err + } + var addr = crypto.PubkeyToAddress(key.PublicKey) + newTx := func(i uint64) (*types.Transaction, error) { + signer := types.NewEIP155Signer(big.NewInt(18)) + utx := types.NewTransaction(i, addr, new(big.Int), 0, new(big.Int).SetUint64(10000000), nil) + tx, err := types.SignTx(utx, signer, key) + return tx, err + } + var txs types.Transactions + for i := uint64(0); i < num; i++ { + tx, err := newTx(i) + if err != nil { + return nil, err + } + txs = append(txs, tx) + } + return txs, nil +} + +type dummyDerivableList struct { + len int + seed int +} + +func newDummy(seed int) *dummyDerivableList { + d := &dummyDerivableList{} + src := mrand.NewSource(int64(seed)) + // don't use lists longer than 4K items + d.len = int(src.Int63() & 0x0FFF) + d.seed = seed + return d +} + +func (d *dummyDerivableList) Len() int { + return d.len +} + +func (d *dummyDerivableList) EncodeIndex(i int, w *bytes.Buffer) { + src := mrand.NewSource(int64(d.seed + i)) + // max item size 256, at least 1 byte per item + size := 1 + src.Int63()&0x00FF + io.CopyN(w, mrand.New(src), size) +} + +func printList(l types.DerivableList) { + fmt.Printf("list length: %d\n", l.Len()) + fmt.Printf("{\n") + for i := 0; i < l.Len(); i++ { + var buf bytes.Buffer + l.EncodeIndex(i, &buf) + fmt.Printf("\"0x%x\",\n", buf.Bytes()) + } + fmt.Printf("},\n") +} + +type flatList []string + +func (f flatList) Len() int { + return len(f) +} +func (f flatList) EncodeIndex(i int, w *bytes.Buffer) { + w.Write(hexutil.MustDecode(f[i])) +} + +type hashToHumanReadable struct { + data []byte +} + +func (d *hashToHumanReadable) Reset() { + d.data = make([]byte, 0) +} + +func (d *hashToHumanReadable) Update(i []byte, i2 []byte) { + l := fmt.Sprintf("%x %x\n", i, i2) + d.data = append(d.data, []byte(l)...) +} + +func (d *hashToHumanReadable) Hash() common.Hash { + return common.Hash{} +} From c0b5059f2a1f5dc0e05bc4282ae709ce674f4fc9 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 20:39:18 +0100 Subject: [PATCH 29/83] core/types: add methods for EIP2718 canon encoding --- core/types/access_list_tx.go | 1 + core/types/legacy_tx.go | 1 + core/types/transaction.go | 100 +++++++++++++++++++++++++++-------- 3 files changed, 80 insertions(+), 22 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index af5377735943..9abb20a8e6d0 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -99,6 +99,7 @@ func newAccessListTransaction(chainId *big.Int, nonce uint64, to *common.Address } } +func (tx *AccessListTransaction) Type() byte { return AccessListTxId } func (tx *AccessListTransaction) ChainId() *big.Int { return tx.Chain } func (tx *AccessListTransaction) Protected() bool { return true } func (tx *AccessListTransaction) AccessList() *AccessList { return tx.Accesses } diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 5ff7c437e66e..7e53e7cf0f02 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -73,6 +73,7 @@ func newLegacyTransaction(nonce uint64, to *common.Address, amount *big.Int, gas } } +func (tx *LegacyTransaction) Type() byte { return LegacyTxId } func (tx *LegacyTransaction) ChainId() *big.Int { return deriveChainId(tx.V) } func (tx *LegacyTransaction) Protected() bool { return isProtectedV(tx.V) } func (tx *LegacyTransaction) AccessList() *AccessList { return nil } diff --git a/core/types/transaction.go b/core/types/transaction.go index 5e2edc6440a3..db96625c8ccc 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -56,6 +56,8 @@ type Transaction struct { // innerTx is the underlying data of a transaction. type innerTx interface { + Type() byte + ChainId() *big.Int Protected() bool AccessList() *AccessList @@ -91,13 +93,30 @@ func (tx *Transaction) EncodeRLP(w io.Writer) error { buf := encodeBufferPool.Get().(*bytes.Buffer) defer encodeBufferPool.Put(buf) buf.Reset() - buf.WriteByte(tx.typ) - if err := rlp.Encode(buf, tx.inner); err != nil { + if err := tx.encodeTyped(buf); err != nil { return err } return rlp.Encode(w, buf.Bytes()) } +// encodeTyped writes the canonical encoding of a typed transaction to w. +func (tx *Transaction) encodeTyped(w *bytes.Buffer) error { + w.WriteByte(tx.typ) + return rlp.Encode(w, tx.inner) +} + +// MarshalBinary returns the canonical encoding of the transaction. +// For legacy transactions, it returns the RLP encoding. For EIP-2718 typed +// transactions, it returns the type and payload. +func (tx *Transaction) MarshalBinary() ([]byte, error) { + if tx.typ == LegacyTxId { + return rlp.EncodeToBytes(tx.inner) + } + var buf bytes.Buffer + err := tx.encodeTyped(&buf) + return buf.Bytes(), err +} + // DecodeRLP implements rlp.Decoder func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { kind, size, err := s.Kind() @@ -106,37 +125,71 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { return err case kind == rlp.List: // It's a legacy transaction. - tx.typ = LegacyTxId - var i *LegacyTransaction - err = s.Decode(&i) - tx.inner = i + var inner LegacyTransaction + err := s.Decode(&inner) + if err == nil { + tx.setDecoded(&inner, int(rlp.ListSize(size))) + } + return err case kind == rlp.String: // It's an EIP-2718 typed TX envelope. var b []byte if b, err = s.Bytes(); err != nil { return err } - if len(b) == 0 { - return errEmptyTypedTx - } - tx.typ = b[0] - if tx.typ == AccessListTxId { - var i *AccessListTransaction - err = rlp.DecodeBytes(b[1:], &i) - tx.inner = i - } else { - return ErrTxTypeNotSupported + inner, err := tx.decodeTyped(b) + if err == nil { + tx.setDecoded(inner, len(b)) } + return err default: return rlp.ErrExpectedList } +} + +// UnmarshalBinary decodes the canonical encoding of transactions. +// It supports legacy RLP transactions and EIP2718 typed transactions. +func (tx *Transaction) UnmarshalBinary(b []byte) error { + if len(b) > 0 && b[0] >= 0x7f { + // It's a legacy transaction. + var data LegacyTransaction + err := rlp.DecodeBytes(b, &data) + if err != nil { + return err + } + tx.setDecoded(&data, len(b)) + return nil + } + // It's an EIP2718 typed transaction envelope. + inner, err := tx.decodeTyped(b) + if err != nil { + return err + } + tx.setDecoded(inner, len(b)) + return nil +} - if err == nil { - size = rlp.ListSize(size) - tx.size.Store(common.StorageSize(size)) - tx.time = time.Now() +// decodeTyped decodes a typed transaction from the canonical format. +func (tx *Transaction) decodeTyped(b []byte) (innerTx, error) { + if len(b) == 0 { + return nil, errEmptyTypedTx + } + switch b[0] { + case AccessListTxId: + var inner AccessListTransaction + err := rlp.DecodeBytes(b[1:], &inner) + return &inner, err + default: + return nil, ErrTxTypeNotSupported } - return err +} + +// setDecoded sets the inner transaction and size after decoding. +func (tx *Transaction) setDecoded(inner innerTx, size int) { + tx.typ = inner.Type() + tx.inner = inner + tx.time = time.Now() + tx.size.Store(common.StorageSize(size)) } func sanityCheckSignature(v *big.Int, r *big.Int, s *big.Int, maybeProtected bool) error { @@ -171,9 +224,12 @@ func (tx *Transaction) Gas() uint64 { return tx.inner.Gas() } func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.inner.GasPrice()) } func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.Value()) } func (tx *Transaction) Nonce() uint64 { return tx.inner.Nonce() } -func (tx *Transaction) CheckNonce() bool { return true } func (tx *Transaction) To() *common.Address { return tx.inner.To() } +// TODO: remove CheckNonce method. + +func (tx *Transaction) CheckNonce() bool { return true } + func (tx *Transaction) GasPriceCmp(other *Transaction) int { return tx.inner.GasPrice().Cmp(other.GasPrice()) } From 90eccc70262bb1c9116fc66a264fa059765ea085 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 20:43:31 +0100 Subject: [PATCH 30/83] core/types: use encodeTyped in one more place --- core/types/transaction.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index db96625c8ccc..4fec34bf517b 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -335,9 +335,7 @@ func (s Transactions) EncodeIndex(i int, w *bytes.Buffer) { if tx.typ == LegacyTxId { rlp.Encode(w, tx.inner) } else { - // It's an EIP-2718 typed TX envelope. - w.WriteByte(tx.typ) - rlp.Encode(w, tx.inner) + tx.encodeTyped(w) } } From 0a59de29d990d81460a9269361e173e9eeb2c702 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 20:43:44 +0100 Subject: [PATCH 31/83] internal/ethapi: canon format in fillTransaction and sendRawTransaction --- internal/ethapi/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 13f2a8b4f12a..8038fb56c951 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1652,7 +1652,7 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen } // Assemble the transaction and obtain rlp tx := args.toTransaction() - data, err := rlp.EncodeToBytes(tx) + data, err := tx.MarshalBinary() if err != nil { return nil, err } @@ -1663,7 +1663,7 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen // The sender is responsible for signing the transaction and using the correct nonce. func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) { tx := new(types.Transaction) - if err := rlp.DecodeBytes(encodedTx, tx); err != nil { + if err := tx.UnmarshalBinary(encodedTx, tx); err != nil { return common.Hash{}, err } return SubmitTransaction(ctx, s.b, tx) From 6e942737591a100cec2afe9812af216526e58643 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 20:46:44 +0100 Subject: [PATCH 32/83] internal/ethapi: fixup --- internal/ethapi/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 8038fb56c951..c3e9f7ee05a1 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1661,9 +1661,9 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen // SendRawTransaction will add the signed transaction to the transaction pool. // The sender is responsible for signing the transaction and using the correct nonce. -func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) { +func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) { tx := new(types.Transaction) - if err := tx.UnmarshalBinary(encodedTx, tx); err != nil { + if err := tx.UnmarshalBinary(input); err != nil { return common.Hash{}, err } return SubmitTransaction(ctx, s.b, tx) From a3e4006af82faa3e6aa8d820e9d75ef008cea307 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 21:00:41 +0100 Subject: [PATCH 33/83] core/types: group simple tx accessors --- core/types/transaction.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 4fec34bf517b..51d89dde4879 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -71,10 +71,6 @@ type innerTx interface { RawSignatureValues() (v, r, s *big.Int) } -func (tx *Transaction) Type() uint8 { return tx.typ } -func (tx *Transaction) ChainId() *big.Int { return tx.inner.ChainId() } -func (tx *Transaction) Protected() bool { return tx.inner.Protected() } - func isProtectedV(V *big.Int) bool { if V.BitLen() <= 8 { v := V.Uint64() @@ -218,6 +214,9 @@ func sanityCheckSignature(v *big.Int, r *big.Int, s *big.Int, maybeProtected boo return nil } +func (tx *Transaction) Type() uint8 { return tx.typ } +func (tx *Transaction) ChainId() *big.Int { return tx.inner.ChainId() } +func (tx *Transaction) Protected() bool { return tx.inner.Protected() } func (tx *Transaction) Data() []byte { return tx.inner.Data() } func (tx *Transaction) AccessList() *AccessList { return tx.inner.AccessList() } func (tx *Transaction) Gas() uint64 { return tx.inner.Gas() } @@ -226,6 +225,16 @@ func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inn func (tx *Transaction) Nonce() uint64 { return tx.inner.Nonce() } func (tx *Transaction) To() *common.Address { return tx.inner.To() } +func (tx *Transaction) Cost() *big.Int { + total := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())) + total.Add(total, tx.Value()) + return total +} + +func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { + return tx.inner.RawSignatureValues() +} + // TODO: remove CheckNonce method. func (tx *Transaction) CheckNonce() bool { return true } @@ -311,16 +320,6 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e return ret, nil } -func (tx *Transaction) Cost() *big.Int { - total := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())) - total.Add(total, tx.Value()) - return total -} - -func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { - return tx.inner.RawSignatureValues() -} - // Transactions implements DerivableList for transactions. type Transactions []*Transaction From 7d85a1dfc75545912b23d49f38826afefb92b9bd Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 21:02:47 +0100 Subject: [PATCH 34/83] core/types: rename tx type enum values --- cmd/evm/internal/t8ntool/execution.go | 2 +- core/state_processor.go | 2 +- core/tx_pool.go | 4 ++-- core/types/access_list_tx.go | 4 ++-- core/types/block_test.go | 2 +- core/types/legacy_tx.go | 4 ++-- core/types/receipt.go | 16 ++++++++-------- core/types/receipt_test.go | 2 +- core/types/transaction.go | 19 ++++++++++--------- core/types/transaction_marshalling.go | 8 ++++---- core/types/transaction_signing.go | 12 ++++++------ internal/ethapi/api.go | 4 ++-- 12 files changed, 40 insertions(+), 39 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index e89bfcf2e353..270e7499e16e 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -144,7 +144,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, statedb.Prepare(tx.Hash(), blockHash, txIndex) txContext := core.NewEVMTxContext(msg) - if !chainConfig.IsYoloV3(vmContext.BlockNumber) && tx.Type() != types.LegacyTxId { + if !chainConfig.IsYoloV3(vmContext.BlockNumber) && tx.Type() != types.LegacyTxType { log.Info("rejected tx", "index", i, "hash", tx.Hash(), "error", core.ErrTxTypeNotSupported) rejectedTxs = append(rejectedTxs, i) continue diff --git a/core/state_processor.go b/core/state_processor.go index d21f62303e8b..075748756eb5 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -90,7 +90,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { - if !config.IsYoloV3(header.Number) && tx.Type() != types.LegacyTxId { + if !config.IsYoloV3(header.Number) && tx.Type() != types.LegacyTxType { return nil, ErrTxTypeNotSupported } // Create a new context to be used in the EVM environment diff --git a/core/tx_pool.go b/core/tx_pool.go index e3f20f0fdfba..97bf128b6779 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -537,11 +537,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrGasLimit } // Accept only legacy transactions if before 2718/2930. - if tx.Type() != types.LegacyTxId && !pool.eip2718 { + if tx.Type() != types.LegacyTxType && !pool.eip2718 { return ErrTxTypeNotSupported } // After 2718/2930, accept both legacy transactions and access list transactions. - if pool.eip2718 && (tx.Type() != types.LegacyTxId && tx.Type() != types.AccessListTxId) { + if pool.eip2718 && (tx.Type() != types.LegacyTxType && tx.Type() != types.AccessListTxType) { return ErrTxTypeNotSupported } // Make sure the transaction is signed properly diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 9abb20a8e6d0..845ab635359e 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -93,13 +93,13 @@ func newAccessListTransaction(chainId *big.Int, nonce uint64, to *common.Address i.Accesses = accesses } return &Transaction{ - typ: AccessListTxId, + typ: AccessListTxType, inner: &i, time: time.Now(), } } -func (tx *AccessListTransaction) Type() byte { return AccessListTxId } +func (tx *AccessListTransaction) Type() byte { return AccessListTxType } func (tx *AccessListTransaction) ChainId() *big.Int { return tx.Chain } func (tx *AccessListTransaction) Protected() bool { return true } func (tx *AccessListTransaction) AccessList() *AccessList { return tx.Accesses } diff --git a/core/types/block_test.go b/core/types/block_test.go index ed6c81672248..43291c5c96ce 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -105,7 +105,7 @@ func TestEIP2718BlockEncoding(t *testing.T) { check("len(Transactions)", len(block.Transactions()), 2) check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash()) check("Transactions[1].Hash", block.Transactions()[1].Hash(), tx2.Hash()) - check("Transactions[1].Type()", block.Transactions()[1].Type(), uint8(AccessListTxId)) + check("Transactions[1].Type()", block.Transactions()[1].Type(), uint8(AccessListTxType)) ourBlockEnc, err := rlp.EncodeToBytes(&block) if err != nil { diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 7e53e7cf0f02..9b7b371ff467 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -67,13 +67,13 @@ func newLegacyTransaction(nonce uint64, to *common.Address, amount *big.Int, gas i.Price.Set(gasPrice) } return &Transaction{ - typ: LegacyTxId, + typ: LegacyTxType, inner: &i, time: time.Now(), } } -func (tx *LegacyTransaction) Type() byte { return LegacyTxId } +func (tx *LegacyTransaction) Type() byte { return LegacyTxType } func (tx *LegacyTransaction) ChainId() *big.Int { return deriveChainId(tx.V) } func (tx *LegacyTransaction) Protected() bool { return isProtectedV(tx.V) } func (tx *LegacyTransaction) AccessList() *AccessList { return nil } diff --git a/core/types/receipt.go b/core/types/receipt.go index cb44409804ae..1b224b0659d3 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -118,7 +118,7 @@ type v3StoredReceiptRLP struct { // NewReceipt creates a barebone transaction receipt, copying the init fields. func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt { - return NewEIP2718Receipt(LegacyTxId, root, failed, cumulativeGasUsed) + return NewEIP2718Receipt(LegacyTxType, root, failed, cumulativeGasUsed) } // NewEIP2718Receipt creates a barebone transaction receipt for typed transactions, copying the init fields. @@ -136,11 +136,11 @@ func NewEIP2718Receipt(typ uint8, root []byte, failed bool, cumulativeGasUsed ui // into an RLP stream. If no post state is present, byzantium fork is assumed. func (r *Receipt) EncodeRLP(w io.Writer) error { data := &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs} - if r.Type == LegacyTxId { + if r.Type == LegacyTxType { return rlp.Encode(w, data) } // It's an EIP-2718 typed TX receipt. - if r.Type != AccessListTxId { + if r.Type != AccessListTxType { return ErrTxTypeNotSupported } buf := encodeBufferPool.Get().(*bytes.Buffer) @@ -167,7 +167,7 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error { return err } var r Receipt - r.Type = LegacyTxId + r.Type = LegacyTxType return r.setFromRLP(dec) case kind == rlp.String: // It's an EIP-2718 typed tx receipt. @@ -180,7 +180,7 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error { } var r Receipt r.Type = b[0] - if r.Type == AccessListTxId { + if r.Type == AccessListTxType { var dec receiptRLP if err := rlp.DecodeBytes(b[1:], &dec); err != nil { return err @@ -341,10 +341,10 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) { r := rs[i] data := &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs} switch r.Type { - case LegacyTxId: + case LegacyTxType: rlp.Encode(w, data) - case AccessListTxId: - w.WriteByte(AccessListTxId) + case AccessListTxType: + w.WriteByte(AccessListTxType) rlp.Encode(w, data) default: // For unsupported types, write nothing. Since this is for diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index e35c8d3e6370..3179179ac608 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -193,7 +193,7 @@ func TestDeriveFields(t *testing.T) { GasUsed: 2, }, &Receipt{ - Type: AccessListTxId, + Type: AccessListTxType, PostState: common.Hash{3}.Bytes(), CumulativeGasUsed: 6, Logs: []*Log{ diff --git a/core/types/transaction.go b/core/types/transaction.go index 51d89dde4879..97cbf868a396 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -38,9 +38,10 @@ var ( errEmptyTypedTx = errors.New("empty typed transaction bytes") ) +// Transaction types. const ( - LegacyTxId = iota - AccessListTxId + LegacyTxType = iota + AccessListTxType ) type Transaction struct { @@ -82,7 +83,7 @@ func isProtectedV(V *big.Int) bool { // EncodeRLP implements rlp.Encoder func (tx *Transaction) EncodeRLP(w io.Writer) error { - if tx.typ == LegacyTxId { + if tx.typ == LegacyTxType { return rlp.Encode(w, tx.inner) } // It's an EIP-2718 typed TX envelope. @@ -105,7 +106,7 @@ func (tx *Transaction) encodeTyped(w *bytes.Buffer) error { // For legacy transactions, it returns the RLP encoding. For EIP-2718 typed // transactions, it returns the type and payload. func (tx *Transaction) MarshalBinary() ([]byte, error) { - if tx.typ == LegacyTxId { + if tx.typ == LegacyTxType { return rlp.EncodeToBytes(tx.inner) } var buf bytes.Buffer @@ -171,7 +172,7 @@ func (tx *Transaction) decodeTyped(b []byte) (innerTx, error) { return nil, errEmptyTypedTx } switch b[0] { - case AccessListTxId: + case AccessListTxType: var inner AccessListTransaction err := rlp.DecodeBytes(b[1:], &inner) return &inner, err @@ -253,7 +254,7 @@ func (tx *Transaction) Hash() common.Hash { } var h common.Hash - if tx.typ == LegacyTxId { + if tx.typ == LegacyTxType { h = rlpHash(tx.inner) } else { h = prefixedRlpHash(tx.typ, tx.inner) @@ -284,7 +285,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e // Copy inner transaction. var cpy innerTx switch tx.typ { - case LegacyTxId: + case LegacyTxType: inner := tx.inner.(*LegacyTransaction) cpy = &LegacyTransaction{ AccountNonce: inner.AccountNonce, @@ -297,7 +298,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e R: r, S: s, } - case AccessListTxId: + case AccessListTxType: inner := tx.inner.(*AccessListTransaction) cpy = &AccessListTransaction{ Chain: inner.Chain, @@ -331,7 +332,7 @@ func (s Transactions) Len() int { return len(s) } // constructed by decoding or via public API in this package. func (s Transactions) EncodeIndex(i int, w *bytes.Buffer) { tx := s[i] - if tx.typ == LegacyTxId { + if tx.typ == LegacyTxType { rlp.Encode(w, tx.inner) } else { tx.encodeTyped(w) diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index bdc4a157ab5c..6a10fbd49860 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -39,7 +39,7 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { enc.S = (*hexutil.Big)(s) hash := t.Hash() enc.Hash = &hash - if t.Type() == AccessListTxId { + if t.Type() == AccessListTxType { enc.Type = hexutil.Uint64(t.Type()) enc.Chain = (*hexutil.Big)(t.ChainId()) enc.AccessList = t.AccessList() @@ -73,7 +73,7 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'nonce' for txdata") } - if dec.Type == nil || *dec.Type == hexutil.Uint64(LegacyTxId) { + if dec.Type == nil || *dec.Type == hexutil.Uint64(LegacyTxType) { var i LegacyTransaction if dec.AccountNonce == nil { return errors.New("missing required field 'nonce' for txdata") @@ -120,8 +120,8 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { } } t.inner = &i - } else if *dec.Type == hexutil.Uint64(AccessListTxId) { - t.typ = AccessListTxId + } else if *dec.Type == hexutil.Uint64(AccessListTxType) { + t.typ = AccessListTxType var i AccessListTransaction if dec.Chain == nil { return errors.New("missing required field 'chainId' for txdata") diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index fb658e010ea9..537c2cca6b71 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -115,14 +115,14 @@ func NewEIP2718Signer(chainId *big.Int) EIP2718Signer { // Sender returns the recovered addressed from a transaction's signature. func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { V, R, S := tx.RawSignatureValues() - if tx.Type() == LegacyTxId { + if tx.Type() == LegacyTxType { if !tx.Protected() { return HomesteadSigner{}.Sender(tx) } V = new(big.Int).Sub(V, s.chainIdMul) V.Sub(V, big8) } - if tx.Type() == AccessListTxId { + if tx.Type() == AccessListTxType { // ACL txs are defined to use 0 and 1 as their recovery id, add // 27 to become equivalent to unprotected Homestead signatures. V = new(big.Int).Add(V, big.NewInt(27)) @@ -139,11 +139,11 @@ func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *bi if err != nil { return nil, nil, nil, err } - if tx.Type() == LegacyTxId && s.chainId.Sign() != 0 { + if tx.Type() == LegacyTxType && s.chainId.Sign() != 0 { V = big.NewInt(int64(sig[64] + 35)) V.Add(V, s.chainIdMul) } - if tx.Type() == AccessListTxId { + if tx.Type() == AccessListTxType { V = big.NewInt(int64(sig[64])) } return R, S, V, nil @@ -153,7 +153,7 @@ func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *bi // It does not uniquely identify the transaction. func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { switch tx.typ { - case LegacyTxId: + case LegacyTxType: return rlpHash([]interface{}{ tx.Nonce(), tx.GasPrice(), @@ -163,7 +163,7 @@ func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { tx.Data(), s.chainId, uint(0), uint(0), }) - case AccessListTxId: + case AccessListTxType: return prefixedRlpHash( tx.Type(), []interface{}{ diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index c3e9f7ee05a1..fc0fb1ae29b9 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1228,7 +1228,7 @@ type RPCTransaction struct { // representation, with the given location metadata set (if available). func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { var signer types.Signer = types.FrontierSigner{} - if tx.Type() == types.AccessListTxId { + if tx.Type() == types.AccessListTxType { signer = types.NewEIP2718Signer(tx.ChainId()) } else if tx.Protected() { signer = types.NewEIP155Signer(tx.ChainId()) @@ -1254,7 +1254,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) result.TransactionIndex = (*hexutil.Uint64)(&index) } - if tx.Type() == types.AccessListTxId { + if tx.Type() == types.AccessListTxType { result.Type = hexutil.Uint64(tx.Type()) result.Accesses = tx.AccessList() result.ChainID = (*hexutil.Big)(tx.ChainId()) From c97925e4dd4cf0c16092636a78bb712381bc099b Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 21:04:50 +0100 Subject: [PATCH 35/83] core/types: rename transaction types --- core/types/access_list_tx.go | 34 +++++++++++++-------------- core/types/legacy_tx.go | 34 +++++++++++++-------------- core/types/transaction.go | 14 +++++------ core/types/transaction_marshalling.go | 4 ++-- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 845ab635359e..8d45afddb504 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -39,7 +39,7 @@ func (al *AccessList) StorageKeys() int { return sum } -type AccessListTransaction struct { +type AccessListTx struct { Chain *big.Int `json:"chainId" gencodec:"required"` AccountNonce uint64 `json:"nonce" gencodec:"required"` Price *big.Int `json:"gasPrice" gencodec:"required"` @@ -56,18 +56,18 @@ type AccessListTransaction struct { } func NewAccessListTransaction(chainId *big.Int, nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { - return newAccessListTransaction(chainId, nonce, &to, amount, gasLimit, gasPrice, data, accesses) + return newAccessListTx(chainId, nonce, &to, amount, gasLimit, gasPrice, data, accesses) } func NewAccessListContractCreation(chainId *big.Int, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { - return newAccessListTransaction(chainId, nonce, nil, amount, gasLimit, gasPrice, data, accesses) + return newAccessListTx(chainId, nonce, nil, amount, gasLimit, gasPrice, data, accesses) } -func newAccessListTransaction(chainId *big.Int, nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { +func newAccessListTx(chainId *big.Int, nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { if len(data) > 0 { data = common.CopyBytes(data) } - i := AccessListTransaction{ + i := AccessListTx{ Chain: new(big.Int), AccountNonce: nonce, Recipient: to, @@ -99,20 +99,20 @@ func newAccessListTransaction(chainId *big.Int, nonce uint64, to *common.Address } } -func (tx *AccessListTransaction) Type() byte { return AccessListTxType } -func (tx *AccessListTransaction) ChainId() *big.Int { return tx.Chain } -func (tx *AccessListTransaction) Protected() bool { return true } -func (tx *AccessListTransaction) AccessList() *AccessList { return tx.Accesses } -func (tx *AccessListTransaction) Data() []byte { return common.CopyBytes(tx.Payload) } -func (tx *AccessListTransaction) Gas() uint64 { return tx.GasLimit } -func (tx *AccessListTransaction) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } -func (tx *AccessListTransaction) Value() *big.Int { return new(big.Int).Set(tx.Amount) } -func (tx *AccessListTransaction) Nonce() uint64 { return tx.AccountNonce } -func (tx *AccessListTransaction) CheckNonce() bool { return true } +func (tx *AccessListTx) Type() byte { return AccessListTxType } +func (tx *AccessListTx) ChainId() *big.Int { return tx.Chain } +func (tx *AccessListTx) Protected() bool { return true } +func (tx *AccessListTx) AccessList() *AccessList { return tx.Accesses } +func (tx *AccessListTx) Data() []byte { return common.CopyBytes(tx.Payload) } +func (tx *AccessListTx) Gas() uint64 { return tx.GasLimit } +func (tx *AccessListTx) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } +func (tx *AccessListTx) Value() *big.Int { return new(big.Int).Set(tx.Amount) } +func (tx *AccessListTx) Nonce() uint64 { return tx.AccountNonce } +func (tx *AccessListTx) CheckNonce() bool { return true } // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. -func (tx *AccessListTransaction) To() *common.Address { +func (tx *AccessListTx) To() *common.Address { if tx.Recipient == nil { return nil } @@ -122,6 +122,6 @@ func (tx *AccessListTransaction) To() *common.Address { // RawSignatureValues returns the V, R, S signature values of the transaction. // The return values should not be modified by the caller. -func (tx *AccessListTransaction) RawSignatureValues() (v, r, s *big.Int) { +func (tx *AccessListTx) RawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 9b7b371ff467..ac9c06e09c32 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -23,7 +23,7 @@ import ( "github.com/ethereum/go-ethereum/common" ) -type LegacyTransaction struct { +type LegacyTx struct { AccountNonce uint64 `json:"nonce" gencodec:"required"` Price *big.Int `json:"gasPrice" gencodec:"required"` GasLimit uint64 `json:"gas" gencodec:"required"` @@ -38,18 +38,18 @@ type LegacyTransaction struct { } func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - return newLegacyTransaction(nonce, &to, amount, gasLimit, gasPrice, data) + return newLegacyTx(nonce, &to, amount, gasLimit, gasPrice, data) } func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - return newLegacyTransaction(nonce, nil, amount, gasLimit, gasPrice, data) + return newLegacyTx(nonce, nil, amount, gasLimit, gasPrice, data) } -func newLegacyTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { +func newLegacyTx(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { if len(data) > 0 { data = common.CopyBytes(data) } - i := LegacyTransaction{ + i := LegacyTx{ AccountNonce: nonce, Recipient: to, Payload: data, @@ -73,20 +73,20 @@ func newLegacyTransaction(nonce uint64, to *common.Address, amount *big.Int, gas } } -func (tx *LegacyTransaction) Type() byte { return LegacyTxType } -func (tx *LegacyTransaction) ChainId() *big.Int { return deriveChainId(tx.V) } -func (tx *LegacyTransaction) Protected() bool { return isProtectedV(tx.V) } -func (tx *LegacyTransaction) AccessList() *AccessList { return nil } -func (tx *LegacyTransaction) Data() []byte { return common.CopyBytes(tx.Payload) } -func (tx *LegacyTransaction) Gas() uint64 { return tx.GasLimit } -func (tx *LegacyTransaction) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } -func (tx *LegacyTransaction) Value() *big.Int { return new(big.Int).Set(tx.Amount) } -func (tx *LegacyTransaction) Nonce() uint64 { return tx.AccountNonce } -func (tx *LegacyTransaction) CheckNonce() bool { return true } +func (tx *LegacyTx) Type() byte { return LegacyTxType } +func (tx *LegacyTx) ChainId() *big.Int { return deriveChainId(tx.V) } +func (tx *LegacyTx) Protected() bool { return isProtectedV(tx.V) } +func (tx *LegacyTx) AccessList() *AccessList { return nil } +func (tx *LegacyTx) Data() []byte { return common.CopyBytes(tx.Payload) } +func (tx *LegacyTx) Gas() uint64 { return tx.GasLimit } +func (tx *LegacyTx) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } +func (tx *LegacyTx) Value() *big.Int { return new(big.Int).Set(tx.Amount) } +func (tx *LegacyTx) Nonce() uint64 { return tx.AccountNonce } +func (tx *LegacyTx) CheckNonce() bool { return true } // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. -func (tx *LegacyTransaction) To() *common.Address { +func (tx *LegacyTx) To() *common.Address { if tx.Recipient == nil { return nil } @@ -96,6 +96,6 @@ func (tx *LegacyTransaction) To() *common.Address { // RawSignatureValues returns the V, R, S signature values of the transaction. // The return values should not be modified by the caller. -func (tx *LegacyTransaction) RawSignatureValues() (v, r, s *big.Int) { +func (tx *LegacyTx) RawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } diff --git a/core/types/transaction.go b/core/types/transaction.go index 97cbf868a396..f3c9c27f192c 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -122,7 +122,7 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { return err case kind == rlp.List: // It's a legacy transaction. - var inner LegacyTransaction + var inner LegacyTx err := s.Decode(&inner) if err == nil { tx.setDecoded(&inner, int(rlp.ListSize(size))) @@ -149,7 +149,7 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { func (tx *Transaction) UnmarshalBinary(b []byte) error { if len(b) > 0 && b[0] >= 0x7f { // It's a legacy transaction. - var data LegacyTransaction + var data LegacyTx err := rlp.DecodeBytes(b, &data) if err != nil { return err @@ -173,7 +173,7 @@ func (tx *Transaction) decodeTyped(b []byte) (innerTx, error) { } switch b[0] { case AccessListTxType: - var inner AccessListTransaction + var inner AccessListTx err := rlp.DecodeBytes(b[1:], &inner) return &inner, err default: @@ -286,8 +286,8 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e var cpy innerTx switch tx.typ { case LegacyTxType: - inner := tx.inner.(*LegacyTransaction) - cpy = &LegacyTransaction{ + inner := tx.inner.(*LegacyTx) + cpy = &LegacyTx{ AccountNonce: inner.AccountNonce, Price: inner.Price, GasLimit: inner.GasLimit, @@ -299,8 +299,8 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e S: s, } case AccessListTxType: - inner := tx.inner.(*AccessListTransaction) - cpy = &AccessListTransaction{ + inner := tx.inner.(*AccessListTx) + cpy = &AccessListTx{ Chain: inner.Chain, AccountNonce: inner.AccountNonce, Price: inner.Price, diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 6a10fbd49860..0b025bc2979f 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -74,7 +74,7 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { } if dec.Type == nil || *dec.Type == hexutil.Uint64(LegacyTxType) { - var i LegacyTransaction + var i LegacyTx if dec.AccountNonce == nil { return errors.New("missing required field 'nonce' for txdata") } @@ -122,7 +122,7 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { t.inner = &i } else if *dec.Type == hexutil.Uint64(AccessListTxType) { t.typ = AccessListTxType - var i AccessListTransaction + var i AccessListTx if dec.Chain == nil { return errors.New("missing required field 'chainId' for txdata") } From e8d48ea7ded3535a8ea0c673f81fc8db82ead4e4 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 21:08:07 +0100 Subject: [PATCH 36/83] core/types: remove CheckNonce of Transaction CheckNonce is for Message, and all messages created by Transaction have their nonce checked. --- core/types/transaction.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index f3c9c27f192c..1a0ccb0c6a07 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -236,10 +236,6 @@ func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { return tx.inner.RawSignatureValues() } -// TODO: remove CheckNonce method. - -func (tx *Transaction) CheckNonce() bool { return true } - func (tx *Transaction) GasPriceCmp(other *Transaction) int { return tx.inner.GasPrice().Cmp(other.GasPrice()) } From 29cd03e24303d11aa573fa8a94816eba8673a975 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 12 Feb 2021 21:09:50 +0100 Subject: [PATCH 37/83] core/types: remove CheckNonce from innerTx --- core/types/access_list_tx.go | 1 - core/types/legacy_tx.go | 1 - core/types/transaction.go | 1 - 3 files changed, 3 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 8d45afddb504..68ba04a547cf 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -108,7 +108,6 @@ func (tx *AccessListTx) Gas() uint64 { return tx.GasLimit } func (tx *AccessListTx) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } func (tx *AccessListTx) Value() *big.Int { return new(big.Int).Set(tx.Amount) } func (tx *AccessListTx) Nonce() uint64 { return tx.AccountNonce } -func (tx *AccessListTx) CheckNonce() bool { return true } // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index ac9c06e09c32..696d887176bb 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -82,7 +82,6 @@ func (tx *LegacyTx) Gas() uint64 { return tx.GasLimit } func (tx *LegacyTx) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } func (tx *LegacyTx) Value() *big.Int { return new(big.Int).Set(tx.Amount) } func (tx *LegacyTx) Nonce() uint64 { return tx.AccountNonce } -func (tx *LegacyTx) CheckNonce() bool { return true } // To returns the recipient address of the transaction. // It returns nil if the transaction is a contract creation. diff --git a/core/types/transaction.go b/core/types/transaction.go index 1a0ccb0c6a07..2fb5b93af68e 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -67,7 +67,6 @@ type innerTx interface { GasPrice() *big.Int Value() *big.Int Nonce() uint64 - CheckNonce() bool To() *common.Address RawSignatureValues() (v, r, s *big.Int) } From 4df70a56ee41f0d23dea48617e5bb9255bae80a5 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 12 Feb 2021 22:19:00 +0100 Subject: [PATCH 38/83] internal/ethapi: use MarshallBinary in a few more places --- internal/ethapi/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index fc0fb1ae29b9..8217b81ddb56 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -410,7 +410,7 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs log.Warn("Failed transaction sign attempt", "from", args.From, "to", args.To, "value", args.Value.ToInt(), "err", err) return nil, err } - data, err := rlp.EncodeToBytes(signed) + data, err := signed.MarshalBinary() if err != nil { return nil, err } @@ -1724,7 +1724,7 @@ func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args Sen if err != nil { return nil, err } - data, err := rlp.EncodeToBytes(tx) + data, err := tx.MarshalBinary() if err != nil { return nil, err } From fb9517abeb1dd31cf60858545d76be2f165d96a1 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 12 Feb 2021 22:47:21 +0100 Subject: [PATCH 39/83] all: use Marshall/UnmarshallBinary over rlp for transactions --- cmd/clef/main.go | 2 +- core/types/transaction_test.go | 35 ++++++++++++++++++++++++---------- ethclient/ethclient.go | 3 +-- graphql/graphql.go | 3 +-- internal/ethapi/api.go | 4 ++-- light/txpool.go | 4 +--- signer/core/api.go | 5 ++--- 7 files changed, 33 insertions(+), 23 deletions(-) diff --git a/cmd/clef/main.go b/cmd/clef/main.go index dbbb410fb6a3..8befce88dc93 100644 --- a/cmd/clef/main.go +++ b/cmd/clef/main.go @@ -1106,7 +1106,7 @@ func GenDoc(ctx *cli.Context) { rlpdata := common.FromHex("0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed") var tx types.Transaction - rlp.DecodeBytes(rlpdata, &tx) + tx.UnmarshalBinary(rlpdata) add("OnApproved - SignTransactionResult", desc, ðapi.SignTransactionResult{Raw: rlpdata, Tx: &tx}) } diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 23ea40bbb62e..9b94572fa4ae 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -144,13 +144,27 @@ func TestEIP2718SigHashes(t *testing.T) { } func TestEIP2718TransactionEncode(t *testing.T) { - txb, err := rlp.EncodeToBytes(signedEip2718Tx) - if err != nil { - t.Fatalf("encode error: %v", err) + // RLP representation + { + have, err := rlp.EncodeToBytes(signedEip2718Tx) + if err != nil { + t.Fatalf("encode error: %v", err) + } + want := common.FromHex("b86601f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b2660a032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d37521") + if !bytes.Equal(have, want) { + t.Errorf("encoded RLP mismatch, got %x", have) + } } - should := common.FromHex("b86601f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b2660a032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d37521") - if !bytes.Equal(txb, should) { - t.Errorf("encoded RLP mismatch, got %x", txb) + // Binary representation + { + have, err := signedEip2718Tx.MarshalBinary() + if err != nil { + t.Fatalf("encode error: %v", err) + } + want := common.FromHex("01f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b2660a032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d37521") + if !bytes.Equal(have, want) { + t.Errorf("encoded RLP mismatch, got %x", have) + } } } @@ -312,13 +326,14 @@ func encodeDecodeJSON(tx *Transaction) (*Transaction, error) { return parsedTx, nil } -func encodeDecodeRLP(tx *Transaction) (*Transaction, error) { - data, err := rlp.EncodeToBytes(tx) +func encodeDecodeBinary(tx *Transaction) (*Transaction, error) { + // TOOD @holiman + data, err := tx.MarshalBinary() if err != nil { return nil, fmt.Errorf("rlp encoding failed: %v", err) } var parsedTx = &Transaction{} - if err := rlp.DecodeBytes(data, parsedTx); err != nil { + if err := parsedTx.UnmarshalBinary(data); err != nil { return nil, fmt.Errorf("rlp decoding failed: %v", err) } return parsedTx, nil @@ -375,7 +390,7 @@ func TestTransactionCoding(t *testing.T) { t.Fatalf("could not sign transaction: %v", err) } // RLP - parsedTx, err := encodeDecodeRLP(tx) + parsedTx, err := encodeDecodeBinary(tx) if err != nil { t.Fatal(err) } diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 8dc34a835e39..a17696356c7c 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -28,7 +28,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" ) @@ -521,7 +520,7 @@ func (ec *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64 // If the transaction was a contract creation use the TransactionReceipt method to get the // contract address after the transaction has been mined. func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error { - data, err := rlp.EncodeToBytes(tx) + data, err := tx.MarshalBinary() if err != nil { return err } diff --git a/graphql/graphql.go b/graphql/graphql.go index 5dc0f723d327..70205fcd8147 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -33,7 +33,6 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/internal/ethapi" - "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" ) @@ -1022,7 +1021,7 @@ func (r *Resolver) Transaction(ctx context.Context, args struct{ Hash common.Has func (r *Resolver) SendRawTransaction(ctx context.Context, args struct{ Data hexutil.Bytes }) (common.Hash, error) { tx := new(types.Transaction) - if err := rlp.DecodeBytes(args.Data, tx); err != nil { + if err := tx.UnmarshalBinary(args.Data); err != nil { return common.Hash{}, err } hash, err := ethapi.SubmitTransaction(ctx, r.backend, tx) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 8217b81ddb56..b09f200f2dea 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1282,7 +1282,7 @@ func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.By if index >= uint64(len(txs)) { return nil } - blob, _ := rlp.EncodeToBytes(txs[index]) + blob, _ := txs[index].MarshalBinary() return blob } @@ -1409,7 +1409,7 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, } } // Serialize to RLP and return - return rlp.EncodeToBytes(tx) + return tx.MarshalBinary() } // GetTransactionReceipt returns the transaction receipt for the given transaction hash. diff --git a/light/txpool.go b/light/txpool.go index 5ec2fca1f38b..0c904000e6aa 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -32,7 +32,6 @@ import ( "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rlp" ) const ( @@ -432,8 +431,7 @@ func (pool *TxPool) add(ctx context.Context, tx *types.Transaction) error { func (pool *TxPool) Add(ctx context.Context, tx *types.Transaction) error { pool.mu.Lock() defer pool.mu.Unlock() - - data, err := rlp.EncodeToBytes(tx) + data, err := tx.MarshalBinary() if err != nil { return err } diff --git a/signer/core/api.go b/signer/core/api.go index 07e206a74c87..968dcfb2edaa 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -33,7 +33,6 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/signer/storage" ) @@ -574,11 +573,11 @@ func (api *SignerAPI) SignTransaction(ctx context.Context, args SendTxArgs, meth return nil, err } - rlpdata, err := rlp.EncodeToBytes(signedTx) + data, err := signedTx.MarshalBinary() if err != nil { return nil, err } - response := ethapi.SignTransactionResult{Raw: rlpdata, Tx: signedTx} + response := ethapi.SignTransactionResult{Raw: data, Tx: signedTx} // Finally, send the signed tx to the UI api.UI.OnApprovedTx(response) From 05097918479d49f279f10e0bcbaf6d4f4aae5947 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Sat, 13 Feb 2021 15:32:51 +0100 Subject: [PATCH 40/83] core, params, cmd/utils: redefine yolov3 as yolov3x --- cmd/utils/flags.go | 2 +- core/genesis.go | 6 +++--- core/genesis_alloc.go | 3 +-- params/config.go | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index aad1d697998e..840eb177e176 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1602,7 +1602,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { SetDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash) case ctx.GlobalBool(YoloV3Flag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { - cfg.NetworkId = new(big.Int).SetBytes([]byte("yolov3")).Uint64() // "yolov3" + cfg.NetworkId = new(big.Int).SetBytes([]byte("yolov3x")).Uint64() // "yolov3x" } cfg.Genesis = core.DefaultYoloV3GenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): diff --git a/core/genesis.go b/core/genesis.go index 462aec45bddf..6bcc50b050ab 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -377,11 +377,11 @@ func DefaultGoerliGenesisBlock() *Genesis { } func DefaultYoloV3GenesisBlock() *Genesis { - // Full genesis: https://gist.github.com/holiman/b2c32a05ff2e2712e11c0787d987d46f + // Full genesis: https://gist.github.com/holiman/c6ed9269dce28304ad176314caa75e97 return &Genesis{ Config: params.YoloV3ChainConfig, - Timestamp: 0x60117f8b, - ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000008a37866fd3627c9205a37c8685666f32ec07bb1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), + Timestamp: 0x6027dd2e, + ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000001041afbcb359d5a8dc58c15b2ff51354ff8a217d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), GasLimit: 0x47b760, Difficulty: big.NewInt(1), Alloc: decodePrealloc(yoloV3AllocData), diff --git a/core/genesis_alloc.go b/core/genesis_alloc.go index 6eecbbf0e828..5b0e933d7a3d 100644 --- a/core/genesis_alloc.go +++ b/core/genesis_alloc.go @@ -25,5 +25,4 @@ const mainnetAllocData = "\xfa\x04]X\u0793\r\x83b\x011\x8e\u0189\x9agT\x06\x908' const ropstenAllocData = "\xf9\x03\xa4\u0080\x01\xc2\x01\x01\xc2\x02\x01\xc2\x03\x01\xc2\x04\x01\xc2\x05\x01\xc2\x06\x01\xc2\a\x01\xc2\b\x01\xc2\t\x01\xc2\n\x80\xc2\v\x80\xc2\f\x80\xc2\r\x80\xc2\x0e\x80\xc2\x0f\x80\xc2\x10\x80\xc2\x11\x80\xc2\x12\x80\xc2\x13\x80\xc2\x14\x80\xc2\x15\x80\xc2\x16\x80\xc2\x17\x80\xc2\x18\x80\xc2\x19\x80\xc2\x1a\x80\xc2\x1b\x80\xc2\x1c\x80\xc2\x1d\x80\xc2\x1e\x80\xc2\x1f\x80\xc2 \x80\xc2!\x80\xc2\"\x80\xc2#\x80\xc2$\x80\xc2%\x80\xc2&\x80\xc2'\x80\xc2(\x80\xc2)\x80\xc2*\x80\xc2+\x80\xc2,\x80\xc2-\x80\xc2.\x80\xc2/\x80\xc20\x80\xc21\x80\xc22\x80\xc23\x80\xc24\x80\xc25\x80\xc26\x80\xc27\x80\xc28\x80\xc29\x80\xc2:\x80\xc2;\x80\xc2<\x80\xc2=\x80\xc2>\x80\xc2?\x80\xc2@\x80\xc2A\x80\xc2B\x80\xc2C\x80\xc2D\x80\xc2E\x80\xc2F\x80\xc2G\x80\xc2H\x80\xc2I\x80\xc2J\x80\xc2K\x80\xc2L\x80\xc2M\x80\xc2N\x80\xc2O\x80\xc2P\x80\xc2Q\x80\xc2R\x80\xc2S\x80\xc2T\x80\xc2U\x80\xc2V\x80\xc2W\x80\xc2X\x80\xc2Y\x80\xc2Z\x80\xc2[\x80\xc2\\\x80\xc2]\x80\xc2^\x80\xc2_\x80\xc2`\x80\xc2a\x80\xc2b\x80\xc2c\x80\xc2d\x80\xc2e\x80\xc2f\x80\xc2g\x80\xc2h\x80\xc2i\x80\xc2j\x80\xc2k\x80\xc2l\x80\xc2m\x80\xc2n\x80\xc2o\x80\xc2p\x80\xc2q\x80\xc2r\x80\xc2s\x80\xc2t\x80\xc2u\x80\xc2v\x80\xc2w\x80\xc2x\x80\xc2y\x80\xc2z\x80\xc2{\x80\xc2|\x80\xc2}\x80\xc2~\x80\xc2\u007f\x80\u00c1\x80\x80\u00c1\x81\x80\u00c1\x82\x80\u00c1\x83\x80\u00c1\x84\x80\u00c1\x85\x80\u00c1\x86\x80\u00c1\x87\x80\u00c1\x88\x80\u00c1\x89\x80\u00c1\x8a\x80\u00c1\x8b\x80\u00c1\x8c\x80\u00c1\x8d\x80\u00c1\x8e\x80\u00c1\x8f\x80\u00c1\x90\x80\u00c1\x91\x80\u00c1\x92\x80\u00c1\x93\x80\u00c1\x94\x80\u00c1\x95\x80\u00c1\x96\x80\u00c1\x97\x80\u00c1\x98\x80\u00c1\x99\x80\u00c1\x9a\x80\u00c1\x9b\x80\u00c1\x9c\x80\u00c1\x9d\x80\u00c1\x9e\x80\u00c1\x9f\x80\u00c1\xa0\x80\u00c1\xa1\x80\u00c1\xa2\x80\u00c1\xa3\x80\u00c1\xa4\x80\u00c1\xa5\x80\u00c1\xa6\x80\u00c1\xa7\x80\u00c1\xa8\x80\u00c1\xa9\x80\u00c1\xaa\x80\u00c1\xab\x80\u00c1\xac\x80\u00c1\xad\x80\u00c1\xae\x80\u00c1\xaf\x80\u00c1\xb0\x80\u00c1\xb1\x80\u00c1\xb2\x80\u00c1\xb3\x80\u00c1\xb4\x80\u00c1\xb5\x80\u00c1\xb6\x80\u00c1\xb7\x80\u00c1\xb8\x80\u00c1\xb9\x80\u00c1\xba\x80\u00c1\xbb\x80\u00c1\xbc\x80\u00c1\xbd\x80\u00c1\xbe\x80\u00c1\xbf\x80\u00c1\xc0\x80\u00c1\xc1\x80\u00c1\u0080\u00c1\u00c0\u00c1\u0100\u00c1\u0140\u00c1\u0180\u00c1\u01c0\u00c1\u0200\u00c1\u0240\u00c1\u0280\u00c1\u02c0\u00c1\u0300\u00c1\u0340\u00c1\u0380\u00c1\u03c0\u00c1\u0400\u00c1\u0440\u00c1\u0480\u00c1\u04c0\u00c1\u0500\u00c1\u0540\u00c1\u0580\u00c1\u05c0\u00c1\u0600\u00c1\u0640\u00c1\u0680\u00c1\u06c0\u00c1\u0700\u00c1\u0740\u00c1\u0780\u00c1\u07c0\u00c1\xe0\x80\u00c1\xe1\x80\u00c1\xe2\x80\u00c1\xe3\x80\u00c1\xe4\x80\u00c1\xe5\x80\u00c1\xe6\x80\u00c1\xe7\x80\u00c1\xe8\x80\u00c1\xe9\x80\u00c1\xea\x80\u00c1\xeb\x80\u00c1\xec\x80\u00c1\xed\x80\u00c1\xee\x80\u00c1\xef\x80\u00c1\xf0\x80\u00c1\xf1\x80\u00c1\xf2\x80\u00c1\xf3\x80\u00c1\xf4\x80\u00c1\xf5\x80\u00c1\xf6\x80\u00c1\xf7\x80\u00c1\xf8\x80\u00c1\xf9\x80\u00c1\xfa\x80\u00c1\xfb\x80\u00c1\xfc\x80\u00c1\xfd\x80\u00c1\xfe\x80\u00c1\xff\x80\u3507KT\xa8\xbd\x15)f\xd6?pk\xae\x1f\xfe\xb0A\x19!\xe5\x8d\f\x9f,\x9c\xd0Ft\xed\xea@\x00\x00\x00" const rinkebyAllocData = "\xf9\x03\xb7\u0080\x01\xc2\x01\x01\xc2\x02\x01\xc2\x03\x01\xc2\x04\x01\xc2\x05\x01\xc2\x06\x01\xc2\a\x01\xc2\b\x01\xc2\t\x01\xc2\n\x01\xc2\v\x01\xc2\f\x01\xc2\r\x01\xc2\x0e\x01\xc2\x0f\x01\xc2\x10\x01\xc2\x11\x01\xc2\x12\x01\xc2\x13\x01\xc2\x14\x01\xc2\x15\x01\xc2\x16\x01\xc2\x17\x01\xc2\x18\x01\xc2\x19\x01\xc2\x1a\x01\xc2\x1b\x01\xc2\x1c\x01\xc2\x1d\x01\xc2\x1e\x01\xc2\x1f\x01\xc2 \x01\xc2!\x01\xc2\"\x01\xc2#\x01\xc2$\x01\xc2%\x01\xc2&\x01\xc2'\x01\xc2(\x01\xc2)\x01\xc2*\x01\xc2+\x01\xc2,\x01\xc2-\x01\xc2.\x01\xc2/\x01\xc20\x01\xc21\x01\xc22\x01\xc23\x01\xc24\x01\xc25\x01\xc26\x01\xc27\x01\xc28\x01\xc29\x01\xc2:\x01\xc2;\x01\xc2<\x01\xc2=\x01\xc2>\x01\xc2?\x01\xc2@\x01\xc2A\x01\xc2B\x01\xc2C\x01\xc2D\x01\xc2E\x01\xc2F\x01\xc2G\x01\xc2H\x01\xc2I\x01\xc2J\x01\xc2K\x01\xc2L\x01\xc2M\x01\xc2N\x01\xc2O\x01\xc2P\x01\xc2Q\x01\xc2R\x01\xc2S\x01\xc2T\x01\xc2U\x01\xc2V\x01\xc2W\x01\xc2X\x01\xc2Y\x01\xc2Z\x01\xc2[\x01\xc2\\\x01\xc2]\x01\xc2^\x01\xc2_\x01\xc2`\x01\xc2a\x01\xc2b\x01\xc2c\x01\xc2d\x01\xc2e\x01\xc2f\x01\xc2g\x01\xc2h\x01\xc2i\x01\xc2j\x01\xc2k\x01\xc2l\x01\xc2m\x01\xc2n\x01\xc2o\x01\xc2p\x01\xc2q\x01\xc2r\x01\xc2s\x01\xc2t\x01\xc2u\x01\xc2v\x01\xc2w\x01\xc2x\x01\xc2y\x01\xc2z\x01\xc2{\x01\xc2|\x01\xc2}\x01\xc2~\x01\xc2\u007f\x01\u00c1\x80\x01\u00c1\x81\x01\u00c1\x82\x01\u00c1\x83\x01\u00c1\x84\x01\u00c1\x85\x01\u00c1\x86\x01\u00c1\x87\x01\u00c1\x88\x01\u00c1\x89\x01\u00c1\x8a\x01\u00c1\x8b\x01\u00c1\x8c\x01\u00c1\x8d\x01\u00c1\x8e\x01\u00c1\x8f\x01\u00c1\x90\x01\u00c1\x91\x01\u00c1\x92\x01\u00c1\x93\x01\u00c1\x94\x01\u00c1\x95\x01\u00c1\x96\x01\u00c1\x97\x01\u00c1\x98\x01\u00c1\x99\x01\u00c1\x9a\x01\u00c1\x9b\x01\u00c1\x9c\x01\u00c1\x9d\x01\u00c1\x9e\x01\u00c1\x9f\x01\u00c1\xa0\x01\u00c1\xa1\x01\u00c1\xa2\x01\u00c1\xa3\x01\u00c1\xa4\x01\u00c1\xa5\x01\u00c1\xa6\x01\u00c1\xa7\x01\u00c1\xa8\x01\u00c1\xa9\x01\u00c1\xaa\x01\u00c1\xab\x01\u00c1\xac\x01\u00c1\xad\x01\u00c1\xae\x01\u00c1\xaf\x01\u00c1\xb0\x01\u00c1\xb1\x01\u00c1\xb2\x01\u00c1\xb3\x01\u00c1\xb4\x01\u00c1\xb5\x01\u00c1\xb6\x01\u00c1\xb7\x01\u00c1\xb8\x01\u00c1\xb9\x01\u00c1\xba\x01\u00c1\xbb\x01\u00c1\xbc\x01\u00c1\xbd\x01\u00c1\xbe\x01\u00c1\xbf\x01\u00c1\xc0\x01\u00c1\xc1\x01\u00c1\xc2\x01\u00c1\xc3\x01\u00c1\xc4\x01\u00c1\xc5\x01\u00c1\xc6\x01\u00c1\xc7\x01\u00c1\xc8\x01\u00c1\xc9\x01\u00c1\xca\x01\u00c1\xcb\x01\u00c1\xcc\x01\u00c1\xcd\x01\u00c1\xce\x01\u00c1\xcf\x01\u00c1\xd0\x01\u00c1\xd1\x01\u00c1\xd2\x01\u00c1\xd3\x01\u00c1\xd4\x01\u00c1\xd5\x01\u00c1\xd6\x01\u00c1\xd7\x01\u00c1\xd8\x01\u00c1\xd9\x01\u00c1\xda\x01\u00c1\xdb\x01\u00c1\xdc\x01\u00c1\xdd\x01\u00c1\xde\x01\u00c1\xdf\x01\u00c1\xe0\x01\u00c1\xe1\x01\u00c1\xe2\x01\u00c1\xe3\x01\u00c1\xe4\x01\u00c1\xe5\x01\u00c1\xe6\x01\u00c1\xe7\x01\u00c1\xe8\x01\u00c1\xe9\x01\u00c1\xea\x01\u00c1\xeb\x01\u00c1\xec\x01\u00c1\xed\x01\u00c1\xee\x01\u00c1\xef\x01\u00c1\xf0\x01\u00c1\xf1\x01\u00c1\xf2\x01\u00c1\xf3\x01\u00c1\xf4\x01\u00c1\xf5\x01\u00c1\xf6\x01\u00c1\xf7\x01\u00c1\xf8\x01\u00c1\xf9\x01\u00c1\xfa\x01\u00c1\xfb\x01\u00c1\xfc\x01\u00c1\xfd\x01\u00c1\xfe\x01\u00c1\xff\x01\xf6\x941\xb9\x8d\x14\x00{\xde\xe67)\x80\x86\x98\x8a\v\xbd1\x18E#\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" const goerliAllocData = "\xf9\x04\x06\u0080\x01\xc2\x01\x01\xc2\x02\x01\xc2\x03\x01\xc2\x04\x01\xc2\x05\x01\xc2\x06\x01\xc2\a\x01\xc2\b\x01\xc2\t\x01\xc2\n\x01\xc2\v\x01\xc2\f\x01\xc2\r\x01\xc2\x0e\x01\xc2\x0f\x01\xc2\x10\x01\xc2\x11\x01\xc2\x12\x01\xc2\x13\x01\xc2\x14\x01\xc2\x15\x01\xc2\x16\x01\xc2\x17\x01\xc2\x18\x01\xc2\x19\x01\xc2\x1a\x01\xc2\x1b\x01\xc2\x1c\x01\xc2\x1d\x01\xc2\x1e\x01\xc2\x1f\x01\xc2 \x01\xc2!\x01\xc2\"\x01\xc2#\x01\xc2$\x01\xc2%\x01\xc2&\x01\xc2'\x01\xc2(\x01\xc2)\x01\xc2*\x01\xc2+\x01\xc2,\x01\xc2-\x01\xc2.\x01\xc2/\x01\xc20\x01\xc21\x01\xc22\x01\xc23\x01\xc24\x01\xc25\x01\xc26\x01\xc27\x01\xc28\x01\xc29\x01\xc2:\x01\xc2;\x01\xc2<\x01\xc2=\x01\xc2>\x01\xc2?\x01\xc2@\x01\xc2A\x01\xc2B\x01\xc2C\x01\xc2D\x01\xc2E\x01\xc2F\x01\xc2G\x01\xc2H\x01\xc2I\x01\xc2J\x01\xc2K\x01\xc2L\x01\xc2M\x01\xc2N\x01\xc2O\x01\xc2P\x01\xc2Q\x01\xc2R\x01\xc2S\x01\xc2T\x01\xc2U\x01\xc2V\x01\xc2W\x01\xc2X\x01\xc2Y\x01\xc2Z\x01\xc2[\x01\xc2\\\x01\xc2]\x01\xc2^\x01\xc2_\x01\xc2`\x01\xc2a\x01\xc2b\x01\xc2c\x01\xc2d\x01\xc2e\x01\xc2f\x01\xc2g\x01\xc2h\x01\xc2i\x01\xc2j\x01\xc2k\x01\xc2l\x01\xc2m\x01\xc2n\x01\xc2o\x01\xc2p\x01\xc2q\x01\xc2r\x01\xc2s\x01\xc2t\x01\xc2u\x01\xc2v\x01\xc2w\x01\xc2x\x01\xc2y\x01\xc2z\x01\xc2{\x01\xc2|\x01\xc2}\x01\xc2~\x01\xc2\u007f\x01\u00c1\x80\x01\u00c1\x81\x01\u00c1\x82\x01\u00c1\x83\x01\u00c1\x84\x01\u00c1\x85\x01\u00c1\x86\x01\u00c1\x87\x01\u00c1\x88\x01\u00c1\x89\x01\u00c1\x8a\x01\u00c1\x8b\x01\u00c1\x8c\x01\u00c1\x8d\x01\u00c1\x8e\x01\u00c1\x8f\x01\u00c1\x90\x01\u00c1\x91\x01\u00c1\x92\x01\u00c1\x93\x01\u00c1\x94\x01\u00c1\x95\x01\u00c1\x96\x01\u00c1\x97\x01\u00c1\x98\x01\u00c1\x99\x01\u00c1\x9a\x01\u00c1\x9b\x01\u00c1\x9c\x01\u00c1\x9d\x01\u00c1\x9e\x01\u00c1\x9f\x01\u00c1\xa0\x01\u00c1\xa1\x01\u00c1\xa2\x01\u00c1\xa3\x01\u00c1\xa4\x01\u00c1\xa5\x01\u00c1\xa6\x01\u00c1\xa7\x01\u00c1\xa8\x01\u00c1\xa9\x01\u00c1\xaa\x01\u00c1\xab\x01\u00c1\xac\x01\u00c1\xad\x01\u00c1\xae\x01\u00c1\xaf\x01\u00c1\xb0\x01\u00c1\xb1\x01\u00c1\xb2\x01\u00c1\xb3\x01\u00c1\xb4\x01\u00c1\xb5\x01\u00c1\xb6\x01\u00c1\xb7\x01\u00c1\xb8\x01\u00c1\xb9\x01\u00c1\xba\x01\u00c1\xbb\x01\u00c1\xbc\x01\u00c1\xbd\x01\u00c1\xbe\x01\u00c1\xbf\x01\u00c1\xc0\x01\u00c1\xc1\x01\u00c1\xc2\x01\u00c1\xc3\x01\u00c1\xc4\x01\u00c1\xc5\x01\u00c1\xc6\x01\u00c1\xc7\x01\u00c1\xc8\x01\u00c1\xc9\x01\u00c1\xca\x01\u00c1\xcb\x01\u00c1\xcc\x01\u00c1\xcd\x01\u00c1\xce\x01\u00c1\xcf\x01\u00c1\xd0\x01\u00c1\xd1\x01\u00c1\xd2\x01\u00c1\xd3\x01\u00c1\xd4\x01\u00c1\xd5\x01\u00c1\xd6\x01\u00c1\xd7\x01\u00c1\xd8\x01\u00c1\xd9\x01\u00c1\xda\x01\u00c1\xdb\x01\u00c1\xdc\x01\u00c1\xdd\x01\u00c1\xde\x01\u00c1\xdf\x01\u00c1\xe0\x01\u00c1\xe1\x01\u00c1\xe2\x01\u00c1\xe3\x01\u00c1\xe4\x01\u00c1\xe5\x01\u00c1\xe6\x01\u00c1\xe7\x01\u00c1\xe8\x01\u00c1\xe9\x01\u00c1\xea\x01\u00c1\xeb\x01\u00c1\xec\x01\u00c1\xed\x01\u00c1\xee\x01\u00c1\xef\x01\u00c1\xf0\x01\u00c1\xf1\x01\u00c1\xf2\x01\u00c1\xf3\x01\u00c1\xf4\x01\u00c1\xf5\x01\u00c1\xf6\x01\u00c1\xf7\x01\u00c1\xf8\x01\u00c1\xf9\x01\u00c1\xfa\x01\u00c1\xfb\x01\u00c1\xfc\x01\u00c1\xfd\x01\u00c1\xfe\x01\u00c1\xff\x01\xe0\x94L*\xe4\x82Y5\x05\xf0\x16<\xde\xfc\a>\x81\xc6<\xdaA\a\x8a\x15-\x02\xc7\xe1J\xf6\x80\x00\x00\xe0\x94\xa8\xe8\xf1G2e\x8eKQ\xe8q\x191\x05:\x8ai\xba\xf2\xb1\x8a\x15-\x02\xc7\xe1J\xf6\x80\x00\x00\xe1\x94\u0665\x17\x9f\t\x1d\x85\x05\x1d<\x98'\x85\xef\xd1E\\\uc199\x8b\bE\x95\x16\x14\x01HJ\x00\x00\x00\xe1\x94\u08bdBX\xd2v\x887\xba\xa2j(\xfeq\xdc\a\x9f\x84\u01cbJG\xe3\xc1$H\xf4\xad\x00\x00\x00" -const yoloV3AllocData = "\xf9\x05\x01\u0080\x01\xc2\x01\x01\xc2\x02\x01\xc2\x03\x01\xc2\x04\x01\xc2\x05\x01\xc2\x06\x01\xc2\a\x01\xc2\b\x01\xc2\t\x01\xc2\n\x01\xc2\v\x01\xc2\f\x01\xc2\r\x01\xc2\x0e\x01\xc2\x0f\x01\xc2\x10\x01\xc2\x11\x01\xc2\x12\x01\xc2\x13\x01\xc2\x14\x01\xc2\x15\x01\xc2\x16\x01\xc2\x17\x01\xc2\x18\x01\xc2\x19\x01\xc2\x1a\x01\xc2\x1b\x01\xc2\x1c\x01\xc2\x1d\x01\xc2\x1e\x01\xc2\x1f\x01\xc2 \x01\xc2!\x01\xc2\"\x01\xc2#\x01\xc2$\x01\xc2%\x01\xc2&\x01\xc2'\x01\xc2(\x01\xc2)\x01\xc2*\x01\xc2+\x01\xc2,\x01\xc2-\x01\xc2.\x01\xc2/\x01\xc20\x01\xc21\x01\xc22\x01\xc23\x01\xc24\x01\xc25\x01\xc26\x01\xc27\x01\xc28\x01\xc29\x01\xc2:\x01\xc2;\x01\xc2<\x01\xc2=\x01\xc2>\x01\xc2?\x01\xc2@\x01\xc2A\x01\xc2B\x01\xc2C\x01\xc2D\x01\xc2E\x01\xc2F\x01\xc2G\x01\xc2H\x01\xc2I\x01\xc2J\x01\xc2K\x01\xc2L\x01\xc2M\x01\xc2N\x01\xc2O\x01\xc2P\x01\xc2Q\x01\xc2R\x01\xc2S\x01\xc2T\x01\xc2U\x01\xc2V\x01\xc2W\x01\xc2X\x01\xc2Y\x01\xc2Z\x01\xc2[\x01\xc2\\\x01\xc2]\x01\xc2^\x01\xc2_\x01\xc2`\x01\xc2a\x01\xc2b\x01\xc2c\x01\xc2d\x01\xc2e\x01\xc2f\x01\xc2g\x01\xc2h\x01\xc2i\x01\xc2j\x01\xc2k\x01\xc2l\x01\xc2m\x01\xc2n\x01\xc2o\x01\xc2p\x01\xc2q\x01\xc2r\x01\xc2s\x01\xc2t\x01\xc2u\x01\xc2v\x01\xc2w\x01\xc2x\x01\xc2y\x01\xc2z\x01\xc2{\x01\xc2|\x01\xc2}\x01\xc2~\x01\xc2\u007f\x01\u00c1\x80\x01\u00c1\x81\x01\u00c1\x82\x01\u00c1\x83\x01\u00c1\x84\x01\u00c1\x85\x01\u00c1\x86\x01\u00c1\x87\x01\u00c1\x88\x01\u00c1\x89\x01\u00c1\x8a\x01\u00c1\x8b\x01\u00c1\x8c\x01\u00c1\x8d\x01\u00c1\x8e\x01\u00c1\x8f\x01\u00c1\x90\x01\u00c1\x91\x01\u00c1\x92\x01\u00c1\x93\x01\u00c1\x94\x01\u00c1\x95\x01\u00c1\x96\x01\u00c1\x97\x01\u00c1\x98\x01\u00c1\x99\x01\u00c1\x9a\x01\u00c1\x9b\x01\u00c1\x9c\x01\u00c1\x9d\x01\u00c1\x9e\x01\u00c1\x9f\x01\u00c1\xa0\x01\u00c1\xa1\x01\u00c1\xa2\x01\u00c1\xa3\x01\u00c1\xa4\x01\u00c1\xa5\x01\u00c1\xa6\x01\u00c1\xa7\x01\u00c1\xa8\x01\u00c1\xa9\x01\u00c1\xaa\x01\u00c1\xab\x01\u00c1\xac\x01\u00c1\xad\x01\u00c1\xae\x01\u00c1\xaf\x01\u00c1\xb0\x01\u00c1\xb1\x01\u00c1\xb2\x01\u00c1\xb3\x01\u00c1\xb4\x01\u00c1\xb5\x01\u00c1\xb6\x01\u00c1\xb7\x01\u00c1\xb8\x01\u00c1\xb9\x01\u00c1\xba\x01\u00c1\xbb\x01\u00c1\xbc\x01\u00c1\xbd\x01\u00c1\xbe\x01\u00c1\xbf\x01\u00c1\xc0\x01\u00c1\xc1\x01\u00c1\xc2\x01\u00c1\xc3\x01\u00c1\xc4\x01\u00c1\xc5\x01\u00c1\xc6\x01\u00c1\xc7\x01\u00c1\xc8\x01\u00c1\xc9\x01\u00c1\xca\x01\u00c1\xcb\x01\u00c1\xcc\x01\u00c1\xcd\x01\u00c1\xce\x01\u00c1\xcf\x01\u00c1\xd0\x01\u00c1\xd1\x01\u00c1\xd2\x01\u00c1\xd3\x01\u00c1\xd4\x01\u00c1\xd5\x01\u00c1\xd6\x01\u00c1\xd7\x01\u00c1\xd8\x01\u00c1\xd9\x01\u00c1\xda\x01\u00c1\xdb\x01\u00c1\xdc\x01\u00c1\xdd\x01\u00c1\xde\x01\u00c1\xdf\x01\u00c1\xe0\x01\u00c1\xe1\x01\u00c1\xe2\x01\u00c1\xe3\x01\u00c1\xe4\x01\u00c1\xe5\x01\u00c1\xe6\x01\u00c1\xe7\x01\u00c1\xe8\x01\u00c1\xe9\x01\u00c1\xea\x01\u00c1\xeb\x01\u00c1\xec\x01\u00c1\xed\x01\u00c1\xee\x01\u00c1\xef\x01\u00c1\xf0\x01\u00c1\xf1\x01\u00c1\xf2\x01\u00c1\xf3\x01\u00c1\xf4\x01\u00c1\xf5\x01\u00c1\xf6\x01\u00c1\xf7\x01\u00c1\xf8\x01\u00c1\xf9\x01\u00c1\xfa\x01\u00c1\xfb\x01\u00c1\xfc\x01\u00c1\xfd\x01\u00c1\xfe\x01\u00c1\xff\x01\xf6\x94\x0e\x89\xe2\xae\xdb\x1c\xfc\u06d4$\xd4\x1a\x1f!\x8fA2s\x81r\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94`\xad\xc0\xf8\x9aA\xaf#|\xe75T\xed\xe1p\xd73\xec\x14\xe0\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94y\x9d2\x9e_X4\x19\x16|\xd7\"\x96$\x85\x92n3\x8fJ\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94|\xf5\xb7\x9b\xfe)\x1ag\xab\x02\xb3\x93\xe4V\xcc\xc4\xc2f\xf7S\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\x8a\x8e\xaf\xb1\xcfb\xbf\xbe\xb1t\x17i\xda\xe1\xa9\xddG\x99a\x92\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\x8b\xa1\xf1\tU\x1b\xd42\x800\x12dZ\xc16\xdd\xd6M\xbar\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\xb0*.\xda\x1b1\u007f\xbd\x16v\x01(\x83k\n\u015bV\x0e\x9d\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" - +const yoloV3AllocData = "\xf9\x05o\u0080\x01\xc2\x01\x01\xc2\x02\x01\xc2\x03\x01\xc2\x04\x01\xc2\x05\x01\xc2\x06\x01\xc2\a\x01\xc2\b\x01\xc2\t\x01\xc2\n\x01\xc2\v\x01\xc2\f\x01\xc2\r\x01\xc2\x0e\x01\xc2\x0f\x01\xc2\x10\x01\xc2\x11\x01\xc2\x12\x01\xc2\x13\x01\xc2\x14\x01\xc2\x15\x01\xc2\x16\x01\xc2\x17\x01\xc2\x18\x01\xc2\x19\x01\xc2\x1a\x01\xc2\x1b\x01\xc2\x1c\x01\xc2\x1d\x01\xc2\x1e\x01\xc2\x1f\x01\xc2 \x01\xc2!\x01\xc2\"\x01\xc2#\x01\xc2$\x01\xc2%\x01\xc2&\x01\xc2'\x01\xc2(\x01\xc2)\x01\xc2*\x01\xc2+\x01\xc2,\x01\xc2-\x01\xc2.\x01\xc2/\x01\xc20\x01\xc21\x01\xc22\x01\xc23\x01\xc24\x01\xc25\x01\xc26\x01\xc27\x01\xc28\x01\xc29\x01\xc2:\x01\xc2;\x01\xc2<\x01\xc2=\x01\xc2>\x01\xc2?\x01\xc2@\x01\xc2A\x01\xc2B\x01\xc2C\x01\xc2D\x01\xc2E\x01\xc2F\x01\xc2G\x01\xc2H\x01\xc2I\x01\xc2J\x01\xc2K\x01\xc2L\x01\xc2M\x01\xc2N\x01\xc2O\x01\xc2P\x01\xc2Q\x01\xc2R\x01\xc2S\x01\xc2T\x01\xc2U\x01\xc2V\x01\xc2W\x01\xc2X\x01\xc2Y\x01\xc2Z\x01\xc2[\x01\xc2\\\x01\xc2]\x01\xc2^\x01\xc2_\x01\xc2`\x01\xc2a\x01\xc2b\x01\xc2c\x01\xc2d\x01\xc2e\x01\xc2f\x01\xc2g\x01\xc2h\x01\xc2i\x01\xc2j\x01\xc2k\x01\xc2l\x01\xc2m\x01\xc2n\x01\xc2o\x01\xc2p\x01\xc2q\x01\xc2r\x01\xc2s\x01\xc2t\x01\xc2u\x01\xc2v\x01\xc2w\x01\xc2x\x01\xc2y\x01\xc2z\x01\xc2{\x01\xc2|\x01\xc2}\x01\xc2~\x01\xc2\u007f\x01\u00c1\x80\x01\u00c1\x81\x01\u00c1\x82\x01\u00c1\x83\x01\u00c1\x84\x01\u00c1\x85\x01\u00c1\x86\x01\u00c1\x87\x01\u00c1\x88\x01\u00c1\x89\x01\u00c1\x8a\x01\u00c1\x8b\x01\u00c1\x8c\x01\u00c1\x8d\x01\u00c1\x8e\x01\u00c1\x8f\x01\u00c1\x90\x01\u00c1\x91\x01\u00c1\x92\x01\u00c1\x93\x01\u00c1\x94\x01\u00c1\x95\x01\u00c1\x96\x01\u00c1\x97\x01\u00c1\x98\x01\u00c1\x99\x01\u00c1\x9a\x01\u00c1\x9b\x01\u00c1\x9c\x01\u00c1\x9d\x01\u00c1\x9e\x01\u00c1\x9f\x01\u00c1\xa0\x01\u00c1\xa1\x01\u00c1\xa2\x01\u00c1\xa3\x01\u00c1\xa4\x01\u00c1\xa5\x01\u00c1\xa6\x01\u00c1\xa7\x01\u00c1\xa8\x01\u00c1\xa9\x01\u00c1\xaa\x01\u00c1\xab\x01\u00c1\xac\x01\u00c1\xad\x01\u00c1\xae\x01\u00c1\xaf\x01\u00c1\xb0\x01\u00c1\xb1\x01\u00c1\xb2\x01\u00c1\xb3\x01\u00c1\xb4\x01\u00c1\xb5\x01\u00c1\xb6\x01\u00c1\xb7\x01\u00c1\xb8\x01\u00c1\xb9\x01\u00c1\xba\x01\u00c1\xbb\x01\u00c1\xbc\x01\u00c1\xbd\x01\u00c1\xbe\x01\u00c1\xbf\x01\u00c1\xc0\x01\u00c1\xc1\x01\u00c1\xc2\x01\u00c1\xc3\x01\u00c1\xc4\x01\u00c1\xc5\x01\u00c1\xc6\x01\u00c1\xc7\x01\u00c1\xc8\x01\u00c1\xc9\x01\u00c1\xca\x01\u00c1\xcb\x01\u00c1\xcc\x01\u00c1\xcd\x01\u00c1\xce\x01\u00c1\xcf\x01\u00c1\xd0\x01\u00c1\xd1\x01\u00c1\xd2\x01\u00c1\xd3\x01\u00c1\xd4\x01\u00c1\xd5\x01\u00c1\xd6\x01\u00c1\xd7\x01\u00c1\xd8\x01\u00c1\xd9\x01\u00c1\xda\x01\u00c1\xdb\x01\u00c1\xdc\x01\u00c1\xdd\x01\u00c1\xde\x01\u00c1\xdf\x01\u00c1\xe0\x01\u00c1\xe1\x01\u00c1\xe2\x01\u00c1\xe3\x01\u00c1\xe4\x01\u00c1\xe5\x01\u00c1\xe6\x01\u00c1\xe7\x01\u00c1\xe8\x01\u00c1\xe9\x01\u00c1\xea\x01\u00c1\xeb\x01\u00c1\xec\x01\u00c1\xed\x01\u00c1\xee\x01\u00c1\xef\x01\u00c1\xf0\x01\u00c1\xf1\x01\u00c1\xf2\x01\u00c1\xf3\x01\u00c1\xf4\x01\u00c1\xf5\x01\u00c1\xf6\x01\u00c1\xf7\x01\u00c1\xf8\x01\u00c1\xf9\x01\u00c1\xfa\x01\u00c1\xfb\x01\u00c1\xfc\x01\u00c1\xfd\x01\u00c1\xfe\x01\u00c1\xff\x01\xf6\x94\x0e\x89\xe2\xae\xdb\x1c\xfc\u06d4$\xd4\x1a\x1f!\x8fA2s\x81r\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\x10A\xaf\xbc\xb3Y\u0568\xdcX\xc1[/\xf5\x13T\xff\x8a!}\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94`\xad\xc0\xf8\x9aA\xaf#|\xe75T\xed\xe1p\xd73\xec\x14\xe0\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94y\x9d2\x9e_X4\x19\x16|\xd7\"\x96$\x85\x92n3\x8fJ\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94|\xf5\xb7\x9b\xfe)\x1ag\xab\x02\xb3\x93\xe4V\xcc\xc4\xc2f\xf7S\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\x8a\x8e\xaf\xb1\xcfb\xbf\xbe\xb1t\x17i\xda\xe1\xa9\xddG\x99a\x92\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\x8b\xa1\xf1\tU\x1b\xd42\x800\x12dZ\xc16\xdd\xd6M\xbar\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\xb0*.\xda\x1b1\u007f\xbd\x16v\x01(\x83k\n\u015bV\x0e\x9d\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x94\xdf\n\x88\xb2\xb6\x8cg7\x13\xa8\xec\x82`\x03go'.5s\xa0\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" diff --git a/params/config.go b/params/config.go index 5690d708b5d9..2ed96359678e 100644 --- a/params/config.go +++ b/params/config.go @@ -215,7 +215,7 @@ var ( // YoloV3ChainConfig contains the chain parameters to run a node on the YOLOv3 test network. YoloV3ChainConfig = &ChainConfig{ - ChainID: new(big.Int).SetBytes([]byte("yolov3")), + ChainID: new(big.Int).SetBytes([]byte("yolov3x")), HomesteadBlock: big.NewInt(0), DAOForkBlock: nil, DAOForkSupport: true, From 3a053a89af3cfa37331fe0aaa871fc858f4b3816 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Sun, 14 Feb 2021 14:07:25 +0100 Subject: [PATCH 41/83] core: fix panic in prefetcher, due to 2930-access list not having been properly prepared --- core/state_prefetcher.go | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 6fa52c2d9b8f..c4ee3b1f5b84 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -19,7 +19,6 @@ package core import ( "sync/atomic" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" @@ -50,8 +49,11 @@ func newStatePrefetcher(config *params.ChainConfig, bc *BlockChain, engine conse // only goal is to pre-cache transaction signatures and state trie nodes. func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *uint32) { var ( - header = block.Header() - gaspool = new(GasPool).AddGas(block.GasLimit()) + header = block.Header() + gaspool = new(GasPool).AddGas(block.GasLimit()) + blockContext = NewEVMBlockContext(header, p.bc, nil) + evm = vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg) + signer = types.MakeSigner(p.config, header.Number) ) // Iterate over and process the individual transactions byzantium := p.config.IsByzantium(block.Number()) @@ -61,8 +63,16 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c return } // Block precaching permitted to continue, execute the transaction + if !p.config.IsYoloV3(header.Number) && tx.Type() != types.LegacyTxType { + return // Invalid block, bail out + } + // Convert the transaction into an executable message and pre-cache its sender + msg, err := tx.AsMessage(signer) + if err != nil { + return // Also invalid block, bail out + } statedb.Prepare(tx.Hash(), block.Hash(), i) - if err := precacheTransaction(p.config, p.bc, nil, gaspool, statedb, header, tx, cfg); err != nil { + if err := precacheTransaction(msg, p.config, gaspool, statedb, header, evm); err != nil { return // Ugh, something went horribly wrong, bail out } // If we're pre-byzantium, pre-load trie nodes for the intermediate root @@ -79,17 +89,13 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c // precacheTransaction attempts to apply a transaction to the given state database // and uses the input parameters for its environment. The goal is not to execute // the transaction successfully, rather to warm up touched data slots. -func precacheTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gaspool *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, cfg vm.Config) error { - // Convert the transaction into an executable message and pre-cache its sender - msg, err := tx.AsMessage(types.MakeSigner(config, header.Number)) - if err != nil { - return err +func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool *GasPool, statedb *state.StateDB, header *types.Header, evm *vm.EVM) error { + // Update the evm with the new transaction context. + evm.Reset(NewEVMTxContext(msg), statedb) + // Add addresses to access list if applicable + if config.IsYoloV3(header.Number) { + statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) } - // Create the EVM and execute the transaction - context := NewEVMBlockContext(header, bc, author) - txContext := NewEVMTxContext(msg) - vm := vm.NewEVM(context, txContext, statedb, config, cfg) - - _, err = ApplyMessage(vm, msg, gaspool) + _, err := ApplyMessage(evm, msg, gaspool) return err } From c1ebe42db1b2d21f38dc7be774cd0e64ef1a5ae5 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Sun, 14 Feb 2021 23:56:24 +0100 Subject: [PATCH 42/83] core/types: fix decoding error due to shadowing --- core/types/receipt.go | 2 -- core/types/receipt_test.go | 28 ++++++++++++++++++++++++++++ core/types/transaction_test.go | 1 - eth/downloader/downloader.go | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/core/types/receipt.go b/core/types/receipt.go index 1b224b0659d3..52b92de29eb5 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -166,7 +166,6 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error { if err := s.Decode(&dec); err != nil { return err } - var r Receipt r.Type = LegacyTxType return r.setFromRLP(dec) case kind == rlp.String: @@ -178,7 +177,6 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error { if len(b) == 0 { return errEmptyTypedReceipt } - var r Receipt r.Type = b[0] if r.Type == AccessListTxType { var dec receiptRLP diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index 3179179ac608..f33bb4aa757c 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -268,6 +268,34 @@ func TestDeriveFields(t *testing.T) { } } +// TestTypedReceiptEncodingDecoding reproduces a flaw that existed in the receipt +// rlp decoder, which failed on stream decoding, due to a shadowing error. +func TestTypedReceiptEncodingDecoding(t *testing.T) { + var payload = common.FromHex("f9043eb9010c01f90108018262d4b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010c01f901080182cd14b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010d01f901090183013754b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010d01f90109018301a194b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0") + check := func(bundle []*Receipt) { + t.Helper() + for i, receipt := range bundle { + if got, want := receipt.Type, uint8(1); got != want { + t.Fatalf("bundle %d: got %x, want %x", i, got, want) + } + } + } + { // This worked + var bundle []*Receipt + rlp.DecodeBytes(payload, bundle) + check(bundle) + } + { // This failed + var bundle []*Receipt + r := bytes.NewReader(payload) + s := rlp.NewStream(r, uint64(len(payload))) + if err := s.Decode(&bundle); err != nil { + t.Fatal(err) + } + check(bundle) + } +} + func clearComputedFieldsOnReceipts(t *testing.T, receipts Receipts) { t.Helper() diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 9b94572fa4ae..beceffe72aa9 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -327,7 +327,6 @@ func encodeDecodeJSON(tx *Transaction) (*Transaction, error) { } func encodeDecodeBinary(tx *Transaction) (*Transaction, error) { - // TOOD @holiman data, err := tx.MarshalBinary() if err != nil { return nil, fmt.Errorf("rlp encoding failed: %v", err) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 416a387e3148..5ddd2f984887 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -1387,7 +1387,7 @@ func (d *Downloader) fetchParts(deliveryCh chan dataPack, deliver func(dataPack) case err == nil: peer.log.Trace("Delivered new batch of data", "type", kind, "count", packet.Stats()) default: - peer.log.Trace("Failed to deliver retrieved data", "type", kind, "err", err) + peer.log.Debug("Failed to deliver retrieved data", "type", kind, "err", err) } } // Blocks assembled, try to update the progress From 1013bb41af16fce3f06e7f3f7e50e728cdc6645b Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 15 Feb 2021 10:23:05 +0100 Subject: [PATCH 43/83] core/types: fix flaw in receipt test --- core/types/receipt_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index f33bb4aa757c..18943dba31ea 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -269,7 +269,7 @@ func TestDeriveFields(t *testing.T) { } // TestTypedReceiptEncodingDecoding reproduces a flaw that existed in the receipt -// rlp decoder, which failed on stream decoding, due to a shadowing error. +// rlp decoder, which failed due to a shadowing error. func TestTypedReceiptEncodingDecoding(t *testing.T) { var payload = common.FromHex("f9043eb9010c01f90108018262d4b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010c01f901080182cd14b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010d01f901090183013754b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010d01f90109018301a194b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0") check := func(bundle []*Receipt) { @@ -280,12 +280,12 @@ func TestTypedReceiptEncodingDecoding(t *testing.T) { } } } - { // This worked + { var bundle []*Receipt - rlp.DecodeBytes(payload, bundle) + rlp.DecodeBytes(payload, &bundle) check(bundle) } - { // This failed + { var bundle []*Receipt r := bytes.NewReader(payload) s := rlp.NewStream(r, uint64(len(payload))) From 54718c35a4f33dc5490ef5133dd7a622108cb45a Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Wed, 17 Feb 2021 14:22:10 -0800 Subject: [PATCH 44/83] internal/ethapi: Fix use correct signer in GetTransactionReceipt --- internal/ethapi/api.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index b09f200f2dea..8d6ea2175162 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1427,10 +1427,18 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha } receipt := receipts[index] + txType := tx.Type() var signer types.Signer = types.FrontierSigner{} if tx.Protected() { - signer = types.NewEIP155Signer(tx.ChainId()) + switch txType { + case types.LegacyTxType: + signer = types.NewEIP155Signer(tx.ChainId()) + case types.AccessListTxType: + // EIP-2930 + signer = types.NewEIP2718Signer(tx.ChainId()) + } } + from, _ := types.Sender(signer, tx) fields := map[string]interface{}{ @@ -1460,6 +1468,10 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha if receipt.ContractAddress != (common.Address{}) { fields["contractAddress"] = receipt.ContractAddress } + + if txType != types.LegacyTxType { + fields["type"] = hexutil.Uint(txType) + } return fields, nil } From 9bdc7ab856a9421d372d7290ab5e672a36a93312 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 17 Feb 2021 11:59:19 +0100 Subject: [PATCH 45/83] core/types: improve transaction JSON handling --- core/types/transaction.go | 4 +- core/types/transaction_marshalling.go | 238 ++++++++++++++------------ 2 files changed, 129 insertions(+), 113 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 2fb5b93af68e..83d1b2854a30 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -185,7 +185,9 @@ func (tx *Transaction) setDecoded(inner innerTx, size int) { tx.typ = inner.Type() tx.inner = inner tx.time = time.Now() - tx.size.Store(common.StorageSize(size)) + if size > 0 { + tx.size.Store(common.StorageSize(size)) + } } func sanityCheckSignature(v *big.Int, r *big.Int, s *big.Int, maybeProtected bool) error { diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 0b025bc2979f..8797040f47a7 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -9,174 +9,188 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) +// txJSON is the JSON representation of transactions. +type txJSON struct { + Type *hexutil.Uint64 `json:"type"` + + // Common transaction fields: + AccountNonce *hexutil.Uint64 `json:"nonce"` + Price *hexutil.Big `json:"gasPrice"` + GasLimit *hexutil.Uint64 `json:"gas"` + Amount *hexutil.Big `json:"value"` + Payload *hexutil.Bytes `json:"input"` + V *hexutil.Big `json:"v"` + R *hexutil.Big `json:"r"` + S *hexutil.Big `json:"s"` + Recipient *common.Address `json:"to"` + + // Access list transaction fields: + ChainID *hexutil.Big `json:"chainId,omitempty"` + AccessList *AccessList `json:"accessList,omitempty"` + + // Only used for encoding: + Hash *common.Hash `json:"hash"` +} + // MarshalJSON marshals as JSON with a hash. func (t *Transaction) MarshalJSON() ([]byte, error) { - type txdata struct { - Type hexutil.Uint64 `json:"type" rlp:"-"` - Chain *hexutil.Big `json:"chainId" rlp:"-"` - AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"` - Price *hexutil.Big `json:"gasPrice" gencodec:"required"` - GasLimit hexutil.Uint64 `json:"gas" gencodec:"required"` - Recipient *common.Address `json:"to" rlp:"nil"` - Amount *hexutil.Big `json:"value" gencodec:"required"` - Payload hexutil.Bytes `json:"input" gencodec:"required"` - AccessList *AccessList `json:"accessList" rlp:"-"` - V *hexutil.Big `json:"v" gencodec:"required"` - R *hexutil.Big `json:"r" gencodec:"required"` - S *hexutil.Big `json:"s" gencodec:"required"` - Hash *common.Hash `json:"hash" rlp:"-"` - } - var enc txdata - enc.AccountNonce = hexutil.Uint64(t.Nonce()) - enc.Price = (*hexutil.Big)(t.GasPrice()) - enc.GasLimit = hexutil.Uint64(t.Gas()) - enc.Recipient = t.To() - enc.Amount = (*hexutil.Big)(t.Value()) - enc.Payload = t.Data() - v, r, s := t.RawSignatureValues() - enc.V = (*hexutil.Big)(v) - enc.R = (*hexutil.Big)(r) - enc.S = (*hexutil.Big)(s) - hash := t.Hash() + var ( + enc txJSON + typ = hexutil.Uint64(t.Type()) + hash = t.Hash() + ) + // These are set for all tx types. enc.Hash = &hash - if t.Type() == AccessListTxType { - enc.Type = hexutil.Uint64(t.Type()) - enc.Chain = (*hexutil.Big)(t.ChainId()) - enc.AccessList = t.AccessList() + enc.Type = &typ + + // Other fields are set conditionally depending on tx type. + switch tx := t.inner.(type) { + case *LegacyTx: + enc.AccountNonce = (*hexutil.Uint64)(&tx.AccountNonce) + enc.GasLimit = (*hexutil.Uint64)(&tx.GasLimit) + enc.Price = (*hexutil.Big)(tx.Price) + enc.Amount = (*hexutil.Big)(tx.Amount) + enc.Payload = (*hexutil.Bytes)(&tx.Payload) + enc.Recipient = t.To() + enc.V = (*hexutil.Big)(tx.V) + enc.R = (*hexutil.Big)(tx.R) + enc.S = (*hexutil.Big)(tx.S) + case *AccessListTx: + enc.ChainID = (*hexutil.Big)(tx.Chain) + enc.AccessList = tx.Accesses + enc.AccountNonce = (*hexutil.Uint64)(&tx.AccountNonce) + enc.GasLimit = (*hexutil.Uint64)(&tx.GasLimit) + enc.Price = (*hexutil.Big)(tx.Price) + enc.Amount = (*hexutil.Big)(tx.Amount) + enc.Payload = (*hexutil.Bytes)(&tx.Payload) + enc.Recipient = t.To() + enc.V = (*hexutil.Big)(tx.V) + enc.R = (*hexutil.Big)(tx.R) + enc.S = (*hexutil.Big)(tx.S) } return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. func (t *Transaction) UnmarshalJSON(input []byte) error { - type txdata struct { - Type *hexutil.Uint64 `json:"type" rlp:"-"` - Chain *hexutil.Big `json:"chainId" rlp:"-"` - AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"` - Price *hexutil.Big `json:"gasPrice" gencodec:"required"` - GasLimit *hexutil.Uint64 `json:"gas" gencodec:"required"` - Recipient *common.Address `json:"to" rlp:"nil"` - Amount *hexutil.Big `json:"value" gencodec:"required"` - Payload *hexutil.Bytes `json:"input" gencodec:"required"` - AccessList *AccessList `json:"accessList" rlp:"-"` - V *hexutil.Big `json:"v" gencodec:"required"` - R *hexutil.Big `json:"r" gencodec:"required"` - S *hexutil.Big `json:"s" gencodec:"required"` - Hash *common.Hash `json:"hash" rlp:"-"` - } - var dec txdata - + var dec txJSON if err := json.Unmarshal(input, &dec); err != nil { return err } - if dec.AccountNonce == nil { - return errors.New("missing required field 'nonce' for txdata") + // Find the transaction type. + typ := hexutil.Uint64(LegacyTxType) + if dec.Type != nil { + typ = *dec.Type } - if dec.Type == nil || *dec.Type == hexutil.Uint64(LegacyTxType) { - var i LegacyTx + // Decode / verify fields according to transaction type. + var inner innerTx + switch typ { + case LegacyTxType: + var itx LegacyTx + inner = &itx + if dec.Recipient != nil { + itx.Recipient = dec.Recipient + } if dec.AccountNonce == nil { - return errors.New("missing required field 'nonce' for txdata") + return errors.New("missing required field 'nonce' in transaction") } - i.AccountNonce = uint64(*dec.AccountNonce) + itx.AccountNonce = uint64(*dec.AccountNonce) if dec.Price == nil { - return errors.New("missing required field 'gasPrice' for txdata") + return errors.New("missing required field 'gasPrice' in transaction") } - i.Price = (*big.Int)(dec.Price) + itx.Price = (*big.Int)(dec.Price) if dec.GasLimit == nil { - return errors.New("missing required field 'gas' for txdata") - } - i.GasLimit = uint64(*dec.GasLimit) - if dec.Recipient != nil { - i.Recipient = dec.Recipient + return errors.New("missing required field 'gas' in transaction") } + itx.GasLimit = uint64(*dec.GasLimit) if dec.Amount == nil { - return errors.New("missing required field 'value' for txdata") + return errors.New("missing required field 'value' in transaction") } - i.Amount = (*big.Int)(dec.Amount) + itx.Amount = (*big.Int)(dec.Amount) if dec.Payload == nil { - return errors.New("missing required field 'input' for txdata") + return errors.New("missing required field 'input' in transaction") } - i.Payload = *dec.Payload + itx.Payload = *dec.Payload if dec.V == nil { - return errors.New("missing required field 'v' for txdata") + return errors.New("missing required field 'v' in transaction") } - i.V = (*big.Int)(dec.V) + itx.V = (*big.Int)(dec.V) if dec.R == nil { - return errors.New("missing required field 'r' for txdata") + return errors.New("missing required field 'r' in transaction") } - i.R = (*big.Int)(dec.R) + itx.R = (*big.Int)(dec.R) if dec.S == nil { - return errors.New("missing required field 's' for txdata") + return errors.New("missing required field 's' in transaction") } - i.S = (*big.Int)(dec.S) - if dec.Hash != nil { - t.hash.Store(*dec.Hash) - } - withSignature := i.V.Sign() != 0 || i.R.Sign() != 0 || i.S.Sign() != 0 + itx.S = (*big.Int)(dec.S) + withSignature := itx.V.Sign() != 0 || itx.R.Sign() != 0 || itx.S.Sign() != 0 if withSignature { - if err := sanityCheckSignature(i.V, i.R, i.S, true); err != nil { + if err := sanityCheckSignature(itx.V, itx.R, itx.S, true); err != nil { return err } } - t.inner = &i - } else if *dec.Type == hexutil.Uint64(AccessListTxType) { - t.typ = AccessListTxType - var i AccessListTx - if dec.Chain == nil { - return errors.New("missing required field 'chainId' for txdata") + + case AccessListTxType: + var itx AccessListTx + inner = &itx + if dec.AccessList == nil { + return errors.New("missing required field 'accessList' in transaction") + } + itx.Accesses = dec.AccessList + if dec.ChainID == nil { + return errors.New("missing required field 'chainId' in transaction") + } + itx.Chain = (*big.Int)(dec.ChainID) + if dec.Recipient != nil { + itx.Recipient = dec.Recipient } - i.Chain = (*big.Int)(dec.Chain) if dec.AccountNonce == nil { - return errors.New("missing required field 'nonce' for txdata") + return errors.New("missing required field 'nonce' in transaction") } - i.AccountNonce = uint64(*dec.AccountNonce) + itx.AccountNonce = uint64(*dec.AccountNonce) if dec.Price == nil { - return errors.New("missing required field 'gasPrice' for txdata") + return errors.New("missing required field 'gasPrice' in transaction") } - i.Price = (*big.Int)(dec.Price) + itx.Price = (*big.Int)(dec.Price) if dec.GasLimit == nil { - return errors.New("missing required field 'gas' for txdata") - } - i.GasLimit = uint64(*dec.GasLimit) - if dec.Recipient != nil { - i.Recipient = dec.Recipient + return errors.New("missing required field 'gas' in transaction") } + itx.GasLimit = uint64(*dec.GasLimit) if dec.Amount == nil { - return errors.New("missing required field 'value' for txdata") + return errors.New("missing required field 'value' in transaction") } - i.Amount = (*big.Int)(dec.Amount) + itx.Amount = (*big.Int)(dec.Amount) if dec.Payload == nil { - return errors.New("missing required field 'input' for txdata") - } - i.Payload = *dec.Payload - if dec.AccessList == nil { - return errors.New("missing required field 'accessList' for txdata") + return errors.New("missing required field 'input' in transaction") } - i.Accesses = dec.AccessList + itx.Payload = *dec.Payload if dec.V == nil { - return errors.New("missing required field 'v' for txdata") + return errors.New("missing required field 'v' in transaction") } - i.V = (*big.Int)(dec.V) + itx.V = (*big.Int)(dec.V) if dec.R == nil { - return errors.New("missing required field 'r' for txdata") + return errors.New("missing required field 'r' in transaction") } - i.R = (*big.Int)(dec.R) + itx.R = (*big.Int)(dec.R) if dec.S == nil { - return errors.New("missing required field 's' for txdata") + return errors.New("missing required field 's' in transaction") } - i.S = (*big.Int)(dec.S) - if dec.Hash != nil { - t.hash.Store(*dec.Hash) - } - withSignature := i.V.Sign() != 0 || i.R.Sign() != 0 || i.S.Sign() != 0 + itx.S = (*big.Int)(dec.S) + withSignature := itx.V.Sign() != 0 || itx.R.Sign() != 0 || itx.S.Sign() != 0 if withSignature { - if err := sanityCheckSignature(i.V, i.R, i.S, false); err != nil { + if err := sanityCheckSignature(itx.V, itx.R, itx.S, false); err != nil { return err } } - t.inner = &i + + default: + return ErrTxTypeNotSupported } + // Now set the inner transaction. + t.setDecoded(inner, 0) + + // TODO: check hash here? return nil } From 4a28669f9692d9d8b6b27c6db2b61797b187c20c Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 18 Feb 2021 12:38:24 +0100 Subject: [PATCH 46/83] core/types: use switch in new signer --- core/types/transaction_signing.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 537c2cca6b71..c3ebb40cde6d 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -115,14 +115,14 @@ func NewEIP2718Signer(chainId *big.Int) EIP2718Signer { // Sender returns the recovered addressed from a transaction's signature. func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { V, R, S := tx.RawSignatureValues() - if tx.Type() == LegacyTxType { + switch tx.Type() { + case LegacyTxType: if !tx.Protected() { return HomesteadSigner{}.Sender(tx) } V = new(big.Int).Sub(V, s.chainIdMul) V.Sub(V, big8) - } - if tx.Type() == AccessListTxType { + case AccessListTxType: // ACL txs are defined to use 0 and 1 as their recovery id, add // 27 to become equivalent to unprotected Homestead signatures. V = new(big.Int).Add(V, big.NewInt(27)) @@ -139,11 +139,13 @@ func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *bi if err != nil { return nil, nil, nil, err } - if tx.Type() == LegacyTxType && s.chainId.Sign() != 0 { - V = big.NewInt(int64(sig[64] + 35)) - V.Add(V, s.chainIdMul) - } - if tx.Type() == AccessListTxType { + switch tx.Type() { + case LegacyTxType: + if s.chainId.Sign() != 0 { + V = big.NewInt(int64(sig[64] + 35)) + V.Add(V, s.chainIdMul) + } + case AccessListTxType: V = big.NewInt(int64(sig[64])) } return R, S, V, nil @@ -152,7 +154,7 @@ func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *bi // Hash returns the hash to be signed by the sender. // It does not uniquely identify the transaction. func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { - switch tx.typ { + switch tx.Type() { case LegacyTxType: return rlpHash([]interface{}{ tx.Nonce(), From cdabbb00e61815b1c8d960fa776909d8ef383764 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 18 Feb 2021 12:55:49 +0100 Subject: [PATCH 47/83] core/types: reject typed transactions in legacy signers --- core/types/transaction_signing.go | 63 ++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index c3ebb40cde6d..32a5c9a67296 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -104,15 +104,18 @@ type Signer interface { Equal(Signer) bool } +// EIP2718Signer implements Signer using the EIP2718 rules. type EIP2718Signer struct{ EIP155Signer } func NewEIP2718Signer(chainId *big.Int) EIP2718Signer { - return EIP2718Signer{ - NewEIP155Signer(chainId), - } + return EIP2718Signer{NewEIP155Signer(chainId)} +} + +func (s EIP2718Signer) Equal(s2 Signer) bool { + eip2718, ok := s2.(EIP2718Signer) + return ok && eip2718.chainId.Cmp(s.chainId) == 0 } -// Sender returns the recovered addressed from a transaction's signature. func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { V, R, S := tx.RawSignatureValues() switch tx.Type() { @@ -126,6 +129,8 @@ func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { // ACL txs are defined to use 0 and 1 as their recovery id, add // 27 to become equivalent to unprotected Homestead signatures. V = new(big.Int).Add(V, big.NewInt(27)) + default: + return common.Address{}, ErrTxTypeNotSupported } if tx.ChainId().Cmp(s.chainId) != 0 { return common.Address{}, ErrInvalidChainId @@ -133,20 +138,19 @@ func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { return recoverPlain(s.Hash(tx), R, S, V, true) } -// SignatureValues returns signature values. func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) { - R, S, V, err = HomesteadSigner{}.SignatureValues(tx, sig) - if err != nil { - return nil, nil, nil, err - } switch tx.Type() { case LegacyTxType: + R, S, V = decodeSignature(sig) if s.chainId.Sign() != 0 { V = big.NewInt(int64(sig[64] + 35)) V.Add(V, s.chainIdMul) } case AccessListTxType: + R, S, _ = decodeSignature(sig) V = big.NewInt(int64(sig[64])) + default: + return nil, nil, nil, ErrTxTypeNotSupported } return R, S, V, nil } @@ -187,7 +191,7 @@ func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { } } -// EIP155Transaction implements Signer using the EIP155 rules. +// EIP155Signer implements Signer using the EIP155 rules. type EIP155Signer struct { chainId, chainIdMul *big.Int } @@ -210,6 +214,9 @@ func (s EIP155Signer) Equal(s2 Signer) bool { var big8 = big.NewInt(8) func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error) { + if tx.Type() != LegacyTxType { + return common.Address{}, ErrTxTypeNotSupported + } if !tx.Protected() { return HomesteadSigner{}.Sender(tx) } @@ -225,10 +232,10 @@ func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error) { // SignatureValues returns signature values. This signature // needs to be in the [R || S || V] format where V is 0 or 1. func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) { - R, S, V, err = HomesteadSigner{}.SignatureValues(tx, sig) - if err != nil { - return nil, nil, nil, err + if tx.Type() != LegacyTxType { + return nil, nil, nil, ErrTxTypeNotSupported } + R, S, V = decodeSignature(sig) if s.chainId.Sign() != 0 { V = big.NewInt(int64(sig[64] + 35)) V.Add(V, s.chainIdMul) @@ -266,6 +273,9 @@ func (hs HomesteadSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v } func (hs HomesteadSigner) Sender(tx *Transaction) (common.Address, error) { + if tx.Type() != LegacyTxType { + return common.Address{}, ErrTxTypeNotSupported + } v, r, s := tx.RawSignatureValues() return recoverPlain(hs.Hash(tx), r, s, v, true) } @@ -277,15 +287,21 @@ func (s FrontierSigner) Equal(s2 Signer) bool { return ok } +func (fs FrontierSigner) Sender(tx *Transaction) (common.Address, error) { + if tx.Type() != LegacyTxType { + return common.Address{}, ErrTxTypeNotSupported + } + v, r, s := tx.RawSignatureValues() + return recoverPlain(fs.Hash(tx), r, s, v, false) +} + // SignatureValues returns signature values. This signature // needs to be in the [R || S || V] format where V is 0 or 1. func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) { - if len(sig) != crypto.SignatureLength { - panic(fmt.Sprintf("wrong size for signature: got %d, want %d", len(sig), crypto.SignatureLength)) + if tx.Type() != LegacyTxType { + return nil, nil, nil, ErrTxTypeNotSupported } - r = new(big.Int).SetBytes(sig[:32]) - s = new(big.Int).SetBytes(sig[32:64]) - v = new(big.Int).SetBytes([]byte{sig[64] + 27}) + r, s, v = decodeSignature(sig) return r, s, v, nil } @@ -302,9 +318,14 @@ func (fs FrontierSigner) Hash(tx *Transaction) common.Hash { }) } -func (fs FrontierSigner) Sender(tx *Transaction) (common.Address, error) { - v, r, s := tx.RawSignatureValues() - return recoverPlain(fs.Hash(tx), r, s, v, false) +func decodeSignature(sig []byte) (r, s, v *big.Int) { + if len(sig) != crypto.SignatureLength { + panic(fmt.Sprintf("wrong size for signature: got %d, want %d", len(sig), crypto.SignatureLength)) + } + r = new(big.Int).SetBytes(sig[:32]) + s = new(big.Int).SetBytes(sig[32:64]) + v = new(big.Int).SetBytes([]byte{sig[64] + 27}) + return r, s, v } func recoverPlain(sighash common.Hash, R, S, Vb *big.Int, homestead bool) (common.Address, error) { From 6eeeccd2d46661026586ec58c9549f44bbc7be00 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 18 Feb 2021 13:02:51 +0100 Subject: [PATCH 48/83] core: remove extra checks for tx type This check is now performed by the signer in AsMessage --- core/state_prefetcher.go | 4 ---- core/state_processor.go | 3 --- 2 files changed, 7 deletions(-) diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index c4ee3b1f5b84..42058c46b855 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -62,10 +62,6 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c if interrupt != nil && atomic.LoadUint32(interrupt) == 1 { return } - // Block precaching permitted to continue, execute the transaction - if !p.config.IsYoloV3(header.Number) && tx.Type() != types.LegacyTxType { - return // Invalid block, bail out - } // Convert the transaction into an executable message and pre-cache its sender msg, err := tx.AsMessage(signer) if err != nil { diff --git a/core/state_processor.go b/core/state_processor.go index 075748756eb5..7d3fd751c33c 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -90,9 +90,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { - if !config.IsYoloV3(header.Number) && tx.Type() != types.LegacyTxType { - return nil, ErrTxTypeNotSupported - } // Create a new context to be used in the EVM environment txContext := NewEVMTxContext(msg) // Add addresses to access list if applicable From 52359ac4e96b358237b6a4dc33795455c5a7e833 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 18 Feb 2021 13:03:29 +0100 Subject: [PATCH 49/83] cmd/evm/internal/t8ntool: remove check for tx type This check is now performed by the signer in AsMessage --- cmd/evm/internal/t8ntool/execution.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 270e7499e16e..2ff5815614dc 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -143,12 +143,6 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, vmConfig.Debug = (tracer != nil) statedb.Prepare(tx.Hash(), blockHash, txIndex) txContext := core.NewEVMTxContext(msg) - - if !chainConfig.IsYoloV3(vmContext.BlockNumber) && tx.Type() != types.LegacyTxType { - log.Info("rejected tx", "index", i, "hash", tx.Hash(), "error", core.ErrTxTypeNotSupported) - rejectedTxs = append(rejectedTxs, i) - continue - } snapshot := statedb.Snapshot() evm := vm.NewEVM(vmContext, txContext, statedb, chainConfig, vmConfig) From ced016eded539a211c2eedad1a15b4b0a721ac6e Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 18 Feb 2021 14:23:19 +0100 Subject: [PATCH 50/83] core: move access list setup into ApplyMessage This removes the explicit prepare call in most places where a message is applied. --- cmd/evm/internal/t8ntool/execution.go | 4 ---- core/state/statedb.go | 8 ++++---- core/state_prefetcher.go | 3 --- core/state_processor.go | 13 ++++--------- core/state_transition.go | 6 ++++++ core/vm/interface.go | 1 + eth/tracers/api.go | 9 +++------ internal/ethapi/api.go | 9 ++------- tests/state_test_util.go | 9 +++++---- 9 files changed, 25 insertions(+), 37 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 2ff5815614dc..00e1c536dce4 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -144,11 +144,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, statedb.Prepare(tx.Hash(), blockHash, txIndex) txContext := core.NewEVMTxContext(msg) snapshot := statedb.Snapshot() - evm := vm.NewEVM(vmContext, txContext, statedb, chainConfig, vmConfig) - if chainConfig.IsYoloV3(vmContext.BlockNumber) { - statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) - } // (ret []byte, usedGas uint64, failed bool, err error) msgResult, err := core.ApplyMessage(evm, msg, gaspool) diff --git a/core/state/statedb.go b/core/state/statedb.go index c9b10750fe87..5032eee88765 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -985,14 +985,14 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { // PrepareAccessList handles the preparatory steps for executing a state transition with // regards to both EIP-2929 and EIP-2930: +// // - Add sender to access list (2929) // - Add destination to access list (2929) // - Add precompiles to access list (2929) // - Add the contents of the optional tx access list (2930) -// This method should only be called if Yolov3/Berlin/2929+2930 is applicable at -// the current number -func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, - precompiles []common.Address, accessList *types.AccessList) { +// +// This method should only be called if Yolov3/Berlin/2929+2930 is applicable at the current number. +func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, accessList *types.AccessList) { s.AddAddressToAccessList(sender) if dst != nil { s.AddAddressToAccessList(*dst) diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 42058c46b855..05394321f74b 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -89,9 +89,6 @@ func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool // Update the evm with the new transaction context. evm.Reset(NewEVMTxContext(msg), statedb) // Add addresses to access list if applicable - if config.IsYoloV3(header.Number) { - statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) - } _, err := ApplyMessage(evm, msg, gaspool) return err } diff --git a/core/state_processor.go b/core/state_processor.go index 7d3fd751c33c..484ba8d30a6a 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -90,21 +90,16 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { - // Create a new context to be used in the EVM environment + // Create a new context to be used in the EVM environment. txContext := NewEVMTxContext(msg) - // Add addresses to access list if applicable - if config.IsYoloV3(header.Number) { - statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) - } - - // Update the evm with the new transaction context. evm.Reset(txContext, statedb) - // Apply the transaction to the current state (included in the env) + + // Apply the transaction to the current state (included in the env). result, err := ApplyMessage(evm, msg, gp) if err != nil { return nil, err } - // Update the state with pending changes + // Update the state with pending changes. var root []byte if config.IsByzantium(header.Number) { statedb.Finalise(true) diff --git a/core/state_transition.go b/core/state_transition.go index 1e568c07e8c2..a3260b2c2a06 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -257,6 +257,12 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { if msg.Value().Sign() > 0 && !st.evm.Context.CanTransfer(st.state, msg.From(), msg.Value()) { return nil, fmt.Errorf("%w: address %v", ErrInsufficientFundsForTransfer, msg.From().Hex()) } + + // Set up the initial access list. + if st.evm.ChainConfig().IsYoloV3(st.evm.Context.BlockNumber) { + st.state.PrepareAccessList(msg.From(), msg.To(), st.evm.ActivePrecompiles(), msg.AccessList()) + } + var ( ret []byte vmerr error // vm errors do not effect consensus and are therefore not assigned to err diff --git a/core/vm/interface.go b/core/vm/interface.go index fb5bbca48f65..f8ee4f8f6761 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -57,6 +57,7 @@ type StateDB interface { // is defined according to EIP161 (balance = nonce = code = 0). Empty(common.Address) bool + PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses *types.AccessList) AddressInAccessList(addr common.Address) bool SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool) // AddAddressToAccessList adds the given address to the access list. This operation is safe to perform diff --git a/eth/tracers/api.go b/eth/tracers/api.go index b8d789ad46f1..bd995d08a954 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -753,18 +753,15 @@ func (api *API) traceTx(ctx context.Context, message core.Message, vmctx vm.Bloc default: tracer = vm.NewStructLogger(config.LogConfig) } + // Run the transaction with tracing enabled. vmenv := vm.NewEVM(vmctx, txContext, statedb, api.backend.ChainConfig(), vm.Config{Debug: true, Tracer: tracer}) - - if api.backend.ChainConfig().IsYoloV3(vmctx.BlockNumber) { - statedb.PrepareAccessList(message.From(), message.To(), vmenv.ActivePrecompiles(), message.AccessList()) - } - result, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) if err != nil { return nil, fmt.Errorf("tracing failed: %v", err) } - // Depending on the tracer type, format and return the output + + // Depending on the tracer type, format and return the output. switch tracer := tracer.(type) { case *vm.StructLogger: // If the result contains a revert reason, return it. diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 8d6ea2175162..c4086ab7810a 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -869,18 +869,13 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo evm.Cancel() }() - // Setup the gas pool (also for unmetered requests) - // and apply the message. + // Execute the message. gp := new(core.GasPool).AddGas(math.MaxUint64) - // Apply access list - if evm.ChainConfig().IsYoloV3(header.Number) { - state.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) - } - result, err := core.ApplyMessage(evm, msg, gp) if err := vmError(); err != nil { return nil, err } + // If the timer caused an abort, return an appropriate error message if evm.Cancelled() { return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout) diff --git a/tests/state_test_util.go b/tests/state_test_util.go index aaae03e2ba45..03dc01459c09 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -182,20 +182,21 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh if err != nil { return nil, nil, common.Hash{}, err } + + // Prepare the EVM. txContext := core.NewEVMTxContext(msg) context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase) context.GetHash = vmTestBlockHash evm := vm.NewEVM(context, txContext, statedb, config, vmconfig) - if config.IsYoloV3(context.BlockNumber) { - statedb.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(), msg.AccessList()) - } + // Execute the message. + snapshot := statedb.Snapshot() gaspool := new(core.GasPool) gaspool.AddGas(block.GasLimit()) - snapshot := statedb.Snapshot() if _, err := core.ApplyMessage(evm, msg, gaspool); err != nil { statedb.RevertToSnapshot(snapshot) } + // Commit block statedb.Commit(config.IsEIP158(block.Number())) // Add 0-value mining reward. This only makes a difference in the cases From 02c1cbfc422c4fed6d7e122a10c2724281d50468 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 18 Feb 2021 14:45:28 +0100 Subject: [PATCH 51/83] core: remove extra check for tx type in txpool This is now checked by the signer. --- core/tx_pool.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 97bf128b6779..98d6f90cef73 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -537,14 +537,10 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrGasLimit } // Accept only legacy transactions if before 2718/2930. - if tx.Type() != types.LegacyTxType && !pool.eip2718 { + if !pool.eip2718 && tx.Type() != types.LegacyTxType { return ErrTxTypeNotSupported } - // After 2718/2930, accept both legacy transactions and access list transactions. - if pool.eip2718 && (tx.Type() != types.LegacyTxType && tx.Type() != types.AccessListTxType) { - return ErrTxTypeNotSupported - } - // Make sure the transaction is signed properly + // Make sure the transaction is signed properly. from, err := types.Sender(pool.signer, tx) if err != nil { return ErrInvalidSender From 5da8a0feea0466a06f95867d15365e73e14660ef Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 18 Feb 2021 16:20:26 +0100 Subject: [PATCH 52/83] core: ensure there is only one error for unsupported tx type --- core/error.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/error.go b/core/error.go index b7ed5bc6ecfc..197dd81567c1 100644 --- a/core/error.go +++ b/core/error.go @@ -16,7 +16,11 @@ package core -import "errors" +import ( + "errors" + + "github.com/ethereum/go-ethereum/core/types" +) var ( // ErrKnownBlock is returned when a block to import is already known locally. @@ -66,5 +70,5 @@ var ( // ErrTxTypeNotSupported is returned if a transaction is not supported in the // current network configuration. - ErrTxTypeNotSupported = errors.New("tx type not supported") + ErrTxTypeNotSupported = types.ErrTxTypeNotSupported ) From 389f039c89211eccfd68e6244a55a48d549789ca Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 11:51:06 +0100 Subject: [PATCH 53/83] core/types: clean up innerTx accessors This makes all accessor methods unexported and removes data copying in those accessors. The copy is still performed in the accessor on Transaction. --- core/types/access_list_tx.go | 35 +++++--------- core/types/legacy_tx.go | 32 +++++-------- core/types/transaction.go | 93 +++++++++++++++++++++++------------- 3 files changed, 82 insertions(+), 78 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 68ba04a547cf..f5461dff7f69 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -99,28 +99,17 @@ func newAccessListTx(chainId *big.Int, nonce uint64, to *common.Address, amount } } -func (tx *AccessListTx) Type() byte { return AccessListTxType } -func (tx *AccessListTx) ChainId() *big.Int { return tx.Chain } -func (tx *AccessListTx) Protected() bool { return true } -func (tx *AccessListTx) AccessList() *AccessList { return tx.Accesses } -func (tx *AccessListTx) Data() []byte { return common.CopyBytes(tx.Payload) } -func (tx *AccessListTx) Gas() uint64 { return tx.GasLimit } -func (tx *AccessListTx) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } -func (tx *AccessListTx) Value() *big.Int { return new(big.Int).Set(tx.Amount) } -func (tx *AccessListTx) Nonce() uint64 { return tx.AccountNonce } +// accessors for innerTx. -// To returns the recipient address of the transaction. -// It returns nil if the transaction is a contract creation. -func (tx *AccessListTx) To() *common.Address { - if tx.Recipient == nil { - return nil - } - to := *tx.Recipient - return &to -} +func (tx *AccessListTx) txType() byte { return AccessListTxType } +func (tx *AccessListTx) chainID() *big.Int { return tx.Chain } +func (tx *AccessListTx) protected() bool { return true } +func (tx *AccessListTx) accessList() *AccessList { return tx.Accesses } +func (tx *AccessListTx) data() []byte { return tx.Payload } +func (tx *AccessListTx) gas() uint64 { return tx.GasLimit } +func (tx *AccessListTx) gasPrice() *big.Int { return tx.Price } +func (tx *AccessListTx) value() *big.Int { return tx.Amount } +func (tx *AccessListTx) nonce() uint64 { return tx.AccountNonce } +func (tx *AccessListTx) to() *common.Address { return tx.Recipient } -// RawSignatureValues returns the V, R, S signature values of the transaction. -// The return values should not be modified by the caller. -func (tx *AccessListTx) RawSignatureValues() (v, r, s *big.Int) { - return tx.V, tx.R, tx.S -} +func (tx *AccessListTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 696d887176bb..88920494fa3c 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -73,28 +73,18 @@ func newLegacyTx(nonce uint64, to *common.Address, amount *big.Int, gasLimit uin } } -func (tx *LegacyTx) Type() byte { return LegacyTxType } -func (tx *LegacyTx) ChainId() *big.Int { return deriveChainId(tx.V) } -func (tx *LegacyTx) Protected() bool { return isProtectedV(tx.V) } -func (tx *LegacyTx) AccessList() *AccessList { return nil } -func (tx *LegacyTx) Data() []byte { return common.CopyBytes(tx.Payload) } -func (tx *LegacyTx) Gas() uint64 { return tx.GasLimit } -func (tx *LegacyTx) GasPrice() *big.Int { return new(big.Int).Set(tx.Price) } -func (tx *LegacyTx) Value() *big.Int { return new(big.Int).Set(tx.Amount) } -func (tx *LegacyTx) Nonce() uint64 { return tx.AccountNonce } +// accessors for innerTx. -// To returns the recipient address of the transaction. -// It returns nil if the transaction is a contract creation. -func (tx *LegacyTx) To() *common.Address { - if tx.Recipient == nil { - return nil - } - to := *tx.Recipient - return &to -} +func (tx *LegacyTx) txType() byte { return LegacyTxType } +func (tx *LegacyTx) chainID() *big.Int { return deriveChainId(tx.V) } +func (tx *LegacyTx) accessList() *AccessList { return nil } +func (tx *LegacyTx) data() []byte { return tx.Payload } +func (tx *LegacyTx) gas() uint64 { return tx.GasLimit } +func (tx *LegacyTx) gasPrice() *big.Int { return tx.Price } +func (tx *LegacyTx) value() *big.Int { return tx.Amount } +func (tx *LegacyTx) nonce() uint64 { return tx.AccountNonce } +func (tx *LegacyTx) to() *common.Address { return tx.Recipient } -// RawSignatureValues returns the V, R, S signature values of the transaction. -// The return values should not be modified by the caller. -func (tx *LegacyTx) RawSignatureValues() (v, r, s *big.Int) { +func (tx *LegacyTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } diff --git a/core/types/transaction.go b/core/types/transaction.go index 83d1b2854a30..b343f17f25c4 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -57,27 +57,17 @@ type Transaction struct { // innerTx is the underlying data of a transaction. type innerTx interface { - Type() byte - - ChainId() *big.Int - Protected() bool - AccessList() *AccessList - Data() []byte - Gas() uint64 - GasPrice() *big.Int - Value() *big.Int - Nonce() uint64 - To() *common.Address - RawSignatureValues() (v, r, s *big.Int) -} - -func isProtectedV(V *big.Int) bool { - if V.BitLen() <= 8 { - v := V.Uint64() - return v != 27 && v != 28 && v != 1 && v != 0 - } - // anything not 27 or 28 is considered protected - return true + txType() byte + + chainID() *big.Int + accessList() *AccessList + data() []byte + gas() uint64 + gasPrice() *big.Int + value() *big.Int + nonce() uint64 + to() *common.Address + rawSignatureValues() (v, r, s *big.Int) } // EncodeRLP implements rlp.Encoder @@ -182,7 +172,7 @@ func (tx *Transaction) decodeTyped(b []byte) (innerTx, error) { // setDecoded sets the inner transaction and size after decoding. func (tx *Transaction) setDecoded(inner innerTx, size int) { - tx.typ = inner.Type() + tx.typ = inner.txType() tx.inner = inner tx.time = time.Now() if size > 0 { @@ -216,35 +206,70 @@ func sanityCheckSignature(v *big.Int, r *big.Int, s *big.Int, maybeProtected boo return nil } +func isProtectedV(V *big.Int) bool { + if V.BitLen() <= 8 { + v := V.Uint64() + return v != 27 && v != 28 && v != 1 && v != 0 + } + // anything not 27 or 28 is considered protected + return true +} + +// Protected says whether the transaction is replay-protected. +func (tx *Transaction) Protected() bool { + switch tx := tx.inner.(type) { + case *LegacyTx: + return tx.V != nil && isProtectedV(tx.V) + default: + return true + } +} + func (tx *Transaction) Type() uint8 { return tx.typ } -func (tx *Transaction) ChainId() *big.Int { return tx.inner.ChainId() } -func (tx *Transaction) Protected() bool { return tx.inner.Protected() } -func (tx *Transaction) Data() []byte { return tx.inner.Data() } -func (tx *Transaction) AccessList() *AccessList { return tx.inner.AccessList() } -func (tx *Transaction) Gas() uint64 { return tx.inner.Gas() } -func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.inner.GasPrice()) } -func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.Value()) } -func (tx *Transaction) Nonce() uint64 { return tx.inner.Nonce() } -func (tx *Transaction) To() *common.Address { return tx.inner.To() } +func (tx *Transaction) ChainId() *big.Int { return tx.inner.chainID() } +func (tx *Transaction) Data() []byte { return tx.inner.data() } +func (tx *Transaction) AccessList() *AccessList { return tx.inner.accessList() } +func (tx *Transaction) Gas() uint64 { return tx.inner.gas() } +func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.inner.gasPrice()) } +func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.value()) } +func (tx *Transaction) Nonce() uint64 { return tx.inner.nonce() } + +// To returns the recipient address of the transaction. +// For contract-creation transactions, To returns nil. +func (tx *Transaction) To() *common.Address { + // Copy the pointed-to address. + ito := tx.inner.to() + if ito == nil { + return nil + } + cpy := *ito + return &cpy +} +// Cost returns gas * gasPrice + value. func (tx *Transaction) Cost() *big.Int { total := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())) total.Add(total, tx.Value()) return total } +// RawSignatureValues returns the V, R, S signature values of the transaction. +// The return values should not be modified by the caller. func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) { - return tx.inner.RawSignatureValues() + return tx.inner.rawSignatureValues() } +// GasPriceCmp compares the gas prices of two transactions. func (tx *Transaction) GasPriceCmp(other *Transaction) int { - return tx.inner.GasPrice().Cmp(other.GasPrice()) + return tx.inner.gasPrice().Cmp(other.GasPrice()) } +// GasPriceIntCmp compares the gas price of the transaction against the given price. func (tx *Transaction) GasPriceIntCmp(other *big.Int) int { - return tx.inner.GasPrice().Cmp(other) + return tx.inner.gasPrice().Cmp(other) } +// Hash returns the transaction hash. func (tx *Transaction) Hash() common.Hash { if hash := tx.hash.Load(); hash != nil { return hash.(common.Hash) From 68e304bbbbc48e56cb53e5b10ddfb4e1831fa1fd Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 11:54:22 +0100 Subject: [PATCH 54/83] core/types: remove tx.typ typ was redundant because tx.inner stores the type of the transaction. This shrinks Transaction by 8 bytes. --- core/types/access_list_tx.go | 1 - core/types/legacy_tx.go | 1 - core/types/transaction.go | 30 +++++++++++++++--------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index f5461dff7f69..1cda0ef31254 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -93,7 +93,6 @@ func newAccessListTx(chainId *big.Int, nonce uint64, to *common.Address, amount i.Accesses = accesses } return &Transaction{ - typ: AccessListTxType, inner: &i, time: time.Now(), } diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 88920494fa3c..9c2a45d9da35 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -67,7 +67,6 @@ func newLegacyTx(nonce uint64, to *common.Address, amount *big.Int, gasLimit uin i.Price.Set(gasPrice) } return &Transaction{ - typ: LegacyTxType, inner: &i, time: time.Now(), } diff --git a/core/types/transaction.go b/core/types/transaction.go index b343f17f25c4..95d9ee0fede1 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -45,7 +45,6 @@ const ( ) type Transaction struct { - typ uint8 // EIP-2718 transaction type identifier inner innerTx // Consensus contents of a transaction time time.Time // Time first seen locally (spam avoidance) @@ -72,7 +71,7 @@ type innerTx interface { // EncodeRLP implements rlp.Encoder func (tx *Transaction) EncodeRLP(w io.Writer) error { - if tx.typ == LegacyTxType { + if tx.Type() == LegacyTxType { return rlp.Encode(w, tx.inner) } // It's an EIP-2718 typed TX envelope. @@ -87,7 +86,7 @@ func (tx *Transaction) EncodeRLP(w io.Writer) error { // encodeTyped writes the canonical encoding of a typed transaction to w. func (tx *Transaction) encodeTyped(w *bytes.Buffer) error { - w.WriteByte(tx.typ) + w.WriteByte(tx.Type()) return rlp.Encode(w, tx.inner) } @@ -95,7 +94,7 @@ func (tx *Transaction) encodeTyped(w *bytes.Buffer) error { // For legacy transactions, it returns the RLP encoding. For EIP-2718 typed // transactions, it returns the type and payload. func (tx *Transaction) MarshalBinary() ([]byte, error) { - if tx.typ == LegacyTxType { + if tx.Type() == LegacyTxType { return rlp.EncodeToBytes(tx.inner) } var buf bytes.Buffer @@ -172,7 +171,6 @@ func (tx *Transaction) decodeTyped(b []byte) (innerTx, error) { // setDecoded sets the inner transaction and size after decoding. func (tx *Transaction) setDecoded(inner innerTx, size int) { - tx.typ = inner.txType() tx.inner = inner tx.time = time.Now() if size > 0 { @@ -225,7 +223,11 @@ func (tx *Transaction) Protected() bool { } } -func (tx *Transaction) Type() uint8 { return tx.typ } +// Type returns the transaction type. +func (tx *Transaction) Type() uint8 { + return tx.inner.txType() +} + func (tx *Transaction) ChainId() *big.Int { return tx.inner.chainID() } func (tx *Transaction) Data() []byte { return tx.inner.data() } func (tx *Transaction) AccessList() *AccessList { return tx.inner.accessList() } @@ -276,10 +278,10 @@ func (tx *Transaction) Hash() common.Hash { } var h common.Hash - if tx.typ == LegacyTxType { + if tx.Type() == LegacyTxType { h = rlpHash(tx.inner) } else { - h = prefixedRlpHash(tx.typ, tx.inner) + h = prefixedRlpHash(tx.Type(), tx.inner) } tx.hash.Store(h) return h @@ -306,9 +308,8 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e } // Copy inner transaction. var cpy innerTx - switch tx.typ { - case LegacyTxType: - inner := tx.inner.(*LegacyTx) + switch inner := tx.inner.(type) { + case *LegacyTx: cpy = &LegacyTx{ AccountNonce: inner.AccountNonce, Price: inner.Price, @@ -320,8 +321,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e R: r, S: s, } - case AccessListTxType: - inner := tx.inner.(*AccessListTx) + case *AccessListTx: cpy = &AccessListTx{ Chain: inner.Chain, AccountNonce: inner.AccountNonce, @@ -339,7 +339,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e return nil, ErrInvalidTxType } // Copy outer transaction. - ret := &Transaction{typ: tx.typ, inner: cpy, time: tx.time} + ret := &Transaction{inner: cpy, time: tx.time} return ret, nil } @@ -354,7 +354,7 @@ func (s Transactions) Len() int { return len(s) } // constructed by decoding or via public API in this package. func (s Transactions) EncodeIndex(i int, w *bytes.Buffer) { tx := s[i] - if tx.typ == LegacyTxType { + if tx.Type() == LegacyTxType { rlp.Encode(w, tx.inner) } else { tx.encodeTyped(w) From 81a5bdc019fc90084810bb13dee08e03ecb8ae57 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 12:12:06 +0100 Subject: [PATCH 55/83] core/types: document transaction accessors --- core/types/transaction.go | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 95d9ee0fede1..b631186cab32 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -228,13 +228,30 @@ func (tx *Transaction) Type() uint8 { return tx.inner.txType() } -func (tx *Transaction) ChainId() *big.Int { return tx.inner.chainID() } -func (tx *Transaction) Data() []byte { return tx.inner.data() } +// ChainId returns the EIP155 chain ID of the transaction. The return value will always be +// non-nil. For legacy transactions which are not replay-protected, the return value is +// zero. +func (tx *Transaction) ChainId() *big.Int { + return tx.inner.chainID() +} + +// Data returns the input data of the transaction. +func (tx *Transaction) Data() []byte { return tx.inner.data() } + +// AccessList returns the access list of the transaction. func (tx *Transaction) AccessList() *AccessList { return tx.inner.accessList() } -func (tx *Transaction) Gas() uint64 { return tx.inner.gas() } -func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.inner.gasPrice()) } -func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.value()) } -func (tx *Transaction) Nonce() uint64 { return tx.inner.nonce() } + +// Gas returns the gas limit of the transaction. +func (tx *Transaction) Gas() uint64 { return tx.inner.gas() } + +// GasPrice returns the gas price of the transaction. +func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.inner.gasPrice()) } + +// Value returns the ether amount of the transaction. +func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.inner.value()) } + +// Nonce returns the sender account nonce of the transaction. +func (tx *Transaction) Nonce() uint64 { return tx.inner.nonce() } // To returns the recipient address of the transaction. // For contract-creation transactions, To returns nil. @@ -349,7 +366,7 @@ type Transactions []*Transaction // Len returns the length of s. func (s Transactions) Len() int { return len(s) } -// encode encodes the i'th transaction to w. Note that this does not check for errors +// EncodeIndex encodes the i'th transaction to w. Note that this does not check for errors // because we assume that *Transaction will only ever contain valid txs that were either // constructed by decoding or via public API in this package. func (s Transactions) EncodeIndex(i int, w *bytes.Buffer) { From a05771d7a2832fc10c9d2bc42b077b4853aab7e8 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 19 Feb 2021 13:07:05 +0100 Subject: [PATCH 56/83] core/types, miner, params: fix signer-flaw/crash in miner, add yolov3 to testchainconfig --- core/types/transaction.go | 8 ++++---- miner/worker_test.go | 6 +++++- params/config.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index b631186cab32..112e5d66c7b8 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -451,13 +451,13 @@ func NewTransactionsByPriceAndNonce(signer Signer, txs map[common.Address]Transa // Initialize a price and received time based heap with the head transactions heads := make(TxByPriceAndTime, 0, len(txs)) for from, accTxs := range txs { - heads = append(heads, accTxs[0]) // Ensure the sender address is from the signer - acc, _ := Sender(signer, accTxs[0]) - txs[acc] = accTxs[1:] - if from != acc { + if acc, _ := Sender(signer, accTxs[0]); acc != from { delete(txs, from) + continue } + heads = append(heads, accTxs[0]) + txs[from] = accTxs[1:] } heap.Init(&heads) diff --git a/miner/worker_test.go b/miner/worker_test.go index a5c558ba5f4b..b53603a92650 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -77,14 +77,18 @@ func init() { testTxPoolConfig.Journal = "" ethashChainConfig = params.TestChainConfig cliqueChainConfig = params.TestChainConfig + chainId := params.TestChainConfig.ChainID cliqueChainConfig.Clique = ¶ms.CliqueConfig{ Period: 10, Epoch: 30000, } - tx1, _ := types.SignTx(types.NewTransaction(0, testUserAddress, big.NewInt(1000), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey) + tx1, _ := types.SignTx(types.NewAccessListTransaction(chainId, 0, testUserAddress, + big.NewInt(1000), params.TxGas, nil, nil, nil), types.NewEIP2718Signer(chainId), testBankKey) pendingTxs = append(pendingTxs, tx1) + tx2, _ := types.SignTx(types.NewTransaction(1, testUserAddress, big.NewInt(1000), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey) newTxs = append(newTxs, tx2) + rand.Seed(time.Now().UnixNano()) } diff --git a/params/config.go b/params/config.go index 2ed96359678e..929bdbeb94f7 100644 --- a/params/config.go +++ b/params/config.go @@ -248,7 +248,7 @@ var ( // adding flags to the config to also have to set these fields. AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} - TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, new(EthashConfig), nil} + TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, big.NewInt(0), nil, new(EthashConfig), nil} TestRules = TestChainConfig.Rules(new(big.Int)) ) From ec78fe90c1bb5ede1640b94d84ee63674a6da4ae Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 14:19:45 +0100 Subject: [PATCH 57/83] core/types: add NewTx constructor This is still WIP --- core/blockchain_test.go | 25 ++-- core/types/access_list_tx.go | 89 +++++++------ core/types/block_test.go | 38 ++++-- core/types/legacy_tx.go | 87 ++++++++----- core/types/receipt_test.go | 25 +++- core/types/transaction.go | 25 ++-- core/types/transaction_marshalling.go | 2 +- core/types/transaction_signing.go | 13 +- core/types/transaction_test.go | 173 +++++++++++++++----------- internal/ethapi/api.go | 36 ++++-- 10 files changed, 320 insertions(+), 193 deletions(-) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index b2a9bc0fc769..e399ffb29087 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -3072,18 +3072,23 @@ func TestEIP2718Transition(t *testing.T) { b.SetCoinbase(common.Address{1}) // One transaction to 0xAAAA - accesses := types.AccessList{types.AccessTuple{ - Address: &aa, - StorageKeys: []*common.Hash{ - {0}, - }, - }} - - tx := types.NewAccessListTransaction(gspec.Config.ChainID, 0, aa, big.NewInt(0), 30000, big.NewInt(1), nil, &accesses) - tx, _ = types.SignTx(tx, types.NewEIP2718Signer(gspec.Config.ChainID), key) - + signer := types.NewEIP2718Signer(gspec.Config.ChainID) + tx, _ := types.SignNewTx(key, signer, &types.AccessListTx{ + Chain: gspec.Config.ChainID, + AccountNonce: 0, + Recipient: &aa, + GasLimit: 30000, + Price: big.NewInt(1), + Accesses: &types.AccessList{types.AccessTuple{ + Address: &aa, + StorageKeys: []*common.Hash{ + {0}, + }, + }}, + }) b.AddTx(tx) }) + // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() gspec.MustCommit(diskdb) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 1cda0ef31254..6a70be3ac994 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -18,7 +18,6 @@ package types import ( "math/big" - "time" "github.com/ethereum/go-ethereum/common" ) @@ -40,62 +39,60 @@ func (al *AccessList) StorageKeys() int { } type AccessListTx struct { - Chain *big.Int `json:"chainId" gencodec:"required"` - AccountNonce uint64 `json:"nonce" gencodec:"required"` - Price *big.Int `json:"gasPrice" gencodec:"required"` - GasLimit uint64 `json:"gas" gencodec:"required"` - Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation - Amount *big.Int `json:"value" gencodec:"required"` - Payload []byte `json:"input" gencodec:"required"` - Accesses *AccessList `json:"accessList" gencodec:"required"` + Chain *big.Int + AccountNonce uint64 + Price *big.Int + GasLimit uint64 + Recipient *common.Address `rlp:"nil"` // nil means contract creation + Amount *big.Int + Payload []byte + Accesses *AccessList // Signature values - V *big.Int `json:"v" gencodec:"required"` - R *big.Int `json:"r" gencodec:"required"` - S *big.Int `json:"s" gencodec:"required"` + V *big.Int + R *big.Int + S *big.Int } -func NewAccessListTransaction(chainId *big.Int, nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { - return newAccessListTx(chainId, nonce, &to, amount, gasLimit, gasPrice, data, accesses) -} - -func NewAccessListContractCreation(chainId *big.Int, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { - return newAccessListTx(chainId, nonce, nil, amount, gasLimit, gasPrice, data, accesses) -} - -func newAccessListTx(chainId *big.Int, nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accesses *AccessList) *Transaction { - if len(data) > 0 { - data = common.CopyBytes(data) +// copy creates a deep copy of the transaction data and initializes all fields. +func (tx *AccessListTx) copy() TxData { + cpy := &AccessListTx{ + AccountNonce: tx.AccountNonce, + Recipient: tx.Recipient, // TODO: copy pointed-to address + Payload: common.CopyBytes(tx.Payload), + GasLimit: tx.GasLimit, + // These are copied below. + Accesses: new(AccessList), + Amount: new(big.Int), + Chain: new(big.Int), + Price: new(big.Int), + V: new(big.Int), + R: new(big.Int), + S: new(big.Int), + } + if tx.Accesses != nil { + // TODO: deep copy + cpy.Accesses = tx.Accesses } - i := AccessListTx{ - Chain: new(big.Int), - AccountNonce: nonce, - Recipient: to, - Payload: data, - Accesses: &AccessList{}, - Amount: new(big.Int), - GasLimit: gasLimit, - Price: new(big.Int), - V: new(big.Int), - R: new(big.Int), - S: new(big.Int), + if tx.Amount != nil { + cpy.Amount.Set(tx.Amount) } - if chainId != nil { - i.Chain.Set(chainId) + if tx.Chain != nil { + cpy.Chain.Set(tx.Chain) } - if amount != nil { - i.Amount.Set(amount) + if tx.Price != nil { + cpy.Price.Set(tx.Price) } - if gasPrice != nil { - i.Price.Set(gasPrice) + if tx.V != nil { + cpy.V.Set(tx.V) } - if accesses != nil { - i.Accesses = accesses + if tx.R != nil { + cpy.R.Set(tx.R) } - return &Transaction{ - inner: &i, - time: time.Now(), + if tx.S != nil { + cpy.S.Set(tx.S) } + return cpy } // accessors for innerTx. diff --git a/core/types/block_test.go b/core/types/block_test.go index 43291c5c96ce..7792472f7a03 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -90,17 +90,35 @@ func TestEIP2718BlockEncoding(t *testing.T) { check("Time", block.Time(), uint64(1426516743)) check("Size", block.Size(), common.StorageSize(len(blockEnc))) - tx1 := NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(10), 50000, big.NewInt(10), nil) - tx1, _ = tx1.WithSignature(HomesteadSigner{}, common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100")) + // Create legacy tx. + to := common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87") + tx1 := NewTx(&LegacyTx{ + AccountNonce: 0, + Recipient: &to, + Amount: big.NewInt(10), + GasLimit: 50000, + Price: big.NewInt(10), + }) + sig := common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100") + tx1, _ = tx1.WithSignature(HomesteadSigner{}, sig) + + // Create ACL tx. addr := common.HexToAddress("0x0000000000000000000000000000000000000001") - accesses := AccessList{AccessTuple{ - Address: &addr, - StorageKeys: []*common.Hash{ - {0}, - }, - }} - tx2 := NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) - tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401")) + tx2 := NewTx(&AccessListTx{ + Chain: big.NewInt(1), + AccountNonce: 0, + Recipient: &to, + GasLimit: 123457, + Price: big.NewInt(10), + Accesses: &AccessList{AccessTuple{ + Address: &addr, + StorageKeys: []*common.Hash{ + {0}, + }, + }}, + }) + sig2 := common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401") + tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), sig2) check("len(Transactions)", len(block.Transactions()), 2) check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash()) diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 9c2a45d9da35..f75ef7cbc770 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -18,58 +18,79 @@ package types import ( "math/big" - "time" "github.com/ethereum/go-ethereum/common" ) type LegacyTx struct { - AccountNonce uint64 `json:"nonce" gencodec:"required"` - Price *big.Int `json:"gasPrice" gencodec:"required"` - GasLimit uint64 `json:"gas" gencodec:"required"` - Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation - Amount *big.Int `json:"value" gencodec:"required"` - Payload []byte `json:"input" gencodec:"required"` + AccountNonce uint64 + Price *big.Int + GasLimit uint64 + Recipient *common.Address `rlp:"nil"` // nil means contract creation + Amount *big.Int + Payload []byte - // Signature values - V *big.Int `json:"v" gencodec:"required"` - R *big.Int `json:"r" gencodec:"required"` - S *big.Int `json:"s" gencodec:"required"` + // Signature values. + V *big.Int + R *big.Int + S *big.Int } +// NewTransaction creates an unsigned legacy transaction. +// Deprecated: use NewTx instead. func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - return newLegacyTx(nonce, &to, amount, gasLimit, gasPrice, data) + return NewTx(&LegacyTx{ + AccountNonce: nonce, + Recipient: &to, + Amount: amount, + GasLimit: gasLimit, + Price: gasPrice, + Payload: data, + }) } +// NewContractCreation creates an unsigned legacy transaction. +// Deprecated: use NewTx instead. func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - return newLegacyTx(nonce, nil, amount, gasLimit, gasPrice, data) + return NewTx(&LegacyTx{ + AccountNonce: nonce, + Amount: amount, + GasLimit: gasLimit, + Price: gasPrice, + Payload: data, + }) } -func newLegacyTx(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { - if len(data) > 0 { - data = common.CopyBytes(data) +// copy creates a deep copy of the transaction data and initializes all fields. +func (tx *LegacyTx) copy() TxData { + cpy := &LegacyTx{ + AccountNonce: tx.AccountNonce, + Recipient: tx.Recipient, // TODO: copy pointed-to address + Payload: common.CopyBytes(tx.Payload), + GasLimit: tx.GasLimit, + // These are initialized below. + Amount: new(big.Int), + Price: new(big.Int), + V: new(big.Int), + R: new(big.Int), + S: new(big.Int), } - i := LegacyTx{ - AccountNonce: nonce, - Recipient: to, - Payload: data, - Amount: new(big.Int), - GasLimit: gasLimit, - Price: new(big.Int), - V: new(big.Int), - R: new(big.Int), - S: new(big.Int), + if tx.Amount != nil { + cpy.Amount.Set(tx.Amount) + } + if tx.Price != nil { + cpy.Price.Set(tx.Price) } - if amount != nil { - i.Amount.Set(amount) + if tx.V != nil { + cpy.V.Set(tx.V) } - if gasPrice != nil { - i.Price.Set(gasPrice) + if tx.R != nil { + cpy.R.Set(tx.R) } - return &Transaction{ - inner: &i, - time: time.Now(), + if tx.S != nil { + cpy.S.Set(tx.S) } + return cpy } // accessors for innerTx. diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index 18943dba31ea..7a32120f1f81 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -163,10 +163,29 @@ func encodeAsV3StoredReceiptRLP(want *Receipt) ([]byte, error) { // Tests that receipt data can be correctly derived from the contextual infos func TestDeriveFields(t *testing.T) { // Create a few transactions to have receipts for + to2 := common.HexToAddress("0x2") + to3 := common.HexToAddress("0x3") txs := Transactions{ - NewContractCreation(1, big.NewInt(1), 1, big.NewInt(1), nil), - NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil), - NewAccessListTransaction(big.NewInt(3), 3, common.HexToAddress("0x3"), big.NewInt(3), 3, big.NewInt(3), nil, nil), + NewTx(&LegacyTx{ + AccountNonce: 1, + Amount: big.NewInt(1), + GasLimit: 1, + Price: big.NewInt(1), + }), + NewTx(&LegacyTx{ + Recipient: &to2, + AccountNonce: 2, + Amount: big.NewInt(2), + GasLimit: 2, + Price: big.NewInt(2), + }), + NewTx(&AccessListTx{ + Recipient: &to3, + AccountNonce: 3, + Amount: big.NewInt(3), + GasLimit: 3, + Price: big.NewInt(3), + }), } // Create the corresponding receipts receipts := Receipts{ diff --git a/core/types/transaction.go b/core/types/transaction.go index 112e5d66c7b8..6782630b1547 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -44,8 +44,9 @@ const ( AccessListTxType ) +// Transaction is an Ethereum transaction. type Transaction struct { - inner innerTx // Consensus contents of a transaction + inner TxData // Consensus contents of a transaction time time.Time // Time first seen locally (spam avoidance) // caches @@ -54,9 +55,19 @@ type Transaction struct { from atomic.Value } -// innerTx is the underlying data of a transaction. -type innerTx interface { - txType() byte +// NewTx creates a new transaction. +func NewTx(inner TxData) *Transaction { + tx := new(Transaction) + tx.setDecoded(inner.copy(), 0) + return tx +} + +// TxData is the underlying data of a transaction. +// +// This is implemented by LegacyTx and AccessListTx. +type TxData interface { + txType() byte // returns the type ID + copy() TxData // creates a deep copy and initializes all fields chainID() *big.Int accessList() *AccessList @@ -155,7 +166,7 @@ func (tx *Transaction) UnmarshalBinary(b []byte) error { } // decodeTyped decodes a typed transaction from the canonical format. -func (tx *Transaction) decodeTyped(b []byte) (innerTx, error) { +func (tx *Transaction) decodeTyped(b []byte) (TxData, error) { if len(b) == 0 { return nil, errEmptyTypedTx } @@ -170,7 +181,7 @@ func (tx *Transaction) decodeTyped(b []byte) (innerTx, error) { } // setDecoded sets the inner transaction and size after decoding. -func (tx *Transaction) setDecoded(inner innerTx, size int) { +func (tx *Transaction) setDecoded(inner TxData, size int) { tx.inner = inner tx.time = time.Now() if size > 0 { @@ -324,7 +335,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e return nil, err } // Copy inner transaction. - var cpy innerTx + var cpy TxData switch inner := tx.inner.(type) { case *LegacyTx: cpy = &LegacyTx{ diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 8797040f47a7..2b0d7cff4fed 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -84,7 +84,7 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { } // Decode / verify fields according to transaction type. - var inner innerTx + var inner TxData switch typ { case LegacyTxType: var itx LegacyTx diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 32a5c9a67296..778126f8864f 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -54,7 +54,7 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { return signer } -// SignTx signs the transaction using the given signer and private key +// SignTx signs the transaction using the given signer and private key. func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error) { h := s.Hash(tx) sig, err := crypto.Sign(h[:], prv) @@ -64,6 +64,17 @@ func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, err return tx.WithSignature(s, sig) } +// SignNewTx creates a transaction and signs it. +func SignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) (*Transaction, error) { + tx := NewTx(txdata) + h := s.Hash(tx) + sig, err := crypto.Sign(h[:], prv) + if err != nil { + return nil, err + } + return tx.WithSignature(s, sig) +} + // Sender returns the address derived from the signature (V, R, S) using secp256k1 // elliptic curve and an error if it failed deriving or upon an incorrect // signature. diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index beceffe72aa9..2791599817b0 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -34,6 +34,8 @@ import ( // The values in those tests are from the Transaction Tests // at github.com/ethereum/tests. var ( + testAddr = common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b") + emptyTx = NewTransaction( 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), @@ -43,7 +45,7 @@ var ( rightvrsTx, _ = NewTransaction( 3, - common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), + testAddr, big.NewInt(10), 2000, big.NewInt(1), @@ -53,27 +55,17 @@ var ( common.Hex2Bytes("98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a301"), ) - emptyEip2718Tx = NewAccessListTransaction( - big.NewInt(1), - 3, - common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), - big.NewInt(10), - 25000, - big.NewInt(1), - common.FromHex("5544"), - nil, - ) - - signedEip2718Tx, _ = NewAccessListTransaction( - big.NewInt(1), - 3, - common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), - big.NewInt(10), - 25000, - big.NewInt(1), - common.FromHex("5544"), - nil, - ).WithSignature( + emptyEip2718Tx = NewTx(&AccessListTx{ + Chain: big.NewInt(1), + AccountNonce: 3, + Recipient: &testAddr, + Amount: big.NewInt(10), + GasLimit: 25000, + Price: big.NewInt(1), + Payload: common.FromHex("5544"), + }) + + signedEip2718Tx, _ = emptyEip2718Tx.WithSignature( NewEIP2718Signer(big.NewInt(1)), common.Hex2Bytes("c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b266032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d3752101"), ) @@ -314,6 +306,94 @@ func TestTransactionTimeSort(t *testing.T) { } } +// TestTransactionCoding tests serializing/de-serializing to/from rlp and JSON. +func TestTransactionCoding(t *testing.T) { + key, err := crypto.GenerateKey() + if err != nil { + t.Fatalf("could not generate key: %v", err) + } + var ( + signer = NewEIP2718Signer(common.Big1) + addr = common.HexToAddress("0x0000000000000000000000000000000000000001") + recipient = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87") + accesses = AccessList{ + AccessTuple{ + Address: &addr, + StorageKeys: []*common.Hash{{0}}, + }, + } + ) + for i := uint64(0); i < 500; i++ { + var txdata TxData + switch i % 5 { + case 0: + // Legacy tx. + txdata = &LegacyTx{ + AccountNonce: i, + Recipient: &recipient, + GasLimit: 1, + Price: big.NewInt(2), + Payload: []byte("abcdef"), + } + case 1: + // Legacy tx contract creation. + txdata = &LegacyTx{ + AccountNonce: i, + GasLimit: 1, + Price: big.NewInt(2), + Payload: []byte("abcdef"), + } + case 2: + // Tx with non-zero access list. + txdata = &AccessListTx{ + Chain: big.NewInt(1), + AccountNonce: i, + Recipient: &recipient, + GasLimit: 123457, + Price: big.NewInt(10), + Accesses: &accesses, + Payload: []byte("abcdef"), + } + case 3: + // Tx with empty access list. + txdata = &AccessListTx{ + Chain: big.NewInt(1), + AccountNonce: i, + Recipient: &recipient, + GasLimit: 123457, + Price: big.NewInt(10), + Payload: []byte("abcdef"), + } + case 4: + // Contract creation with access list. + txdata = &AccessListTx{ + Chain: big.NewInt(1), + AccountNonce: i, + GasLimit: 123457, + Price: big.NewInt(10), + Accesses: &accesses, + } + } + tx, err := SignNewTx(key, signer, txdata) + if err != nil { + t.Fatalf("could not sign transaction: %v", err) + } + // RLP + parsedTx, err := encodeDecodeBinary(tx) + if err != nil { + t.Fatal(err) + } + assertEqual(parsedTx, tx) + + // JSON + parsedTx, err = encodeDecodeJSON(tx) + if err != nil { + t.Fatal(err) + } + assertEqual(parsedTx, tx) + } +} + func encodeDecodeJSON(tx *Transaction) (*Transaction, error) { data, err := json.Marshal(tx) if err != nil { @@ -353,52 +433,3 @@ func assertEqual(orig *Transaction, cpy *Transaction) error { } return nil } - -// TestTransactionCoding tests serializing/de-serializing to/from rlp and JSON. -func TestTransactionCoding(t *testing.T) { - key, err := crypto.GenerateKey() - if err != nil { - t.Fatalf("could not generate key: %v", err) - } - var ( - signer = NewEIP2718Signer(common.Big1) - rawTx *Transaction - addr = common.HexToAddress("0x0000000000000000000000000000000000000001") - accesses = AccessList{ - AccessTuple{ - Address: &addr, - StorageKeys: []*common.Hash{{0}}, - }, - } - ) - for i := uint64(0); i < 500; i++ { - switch i % 6 { - case 0: - rawTx = NewTransaction(i, common.Address{1}, common.Big0, 1, common.Big2, []byte("abcdef")) - case 1: - rawTx = NewContractCreation(i, common.Big0, 1, common.Big2, []byte("abcdef")) - case 2: - rawTx = NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) - case 4: - rawTx = NewAccessListContractCreation(big.NewInt(1), 0, big.NewInt(0), 123457, big.NewInt(10), nil, &accesses) - case 5: - rawTx = NewAccessListTransaction(big.NewInt(1), 0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 123457, big.NewInt(10), nil, nil) - } - tx, err := SignTx(rawTx, signer, key) - if err != nil { - t.Fatalf("could not sign transaction: %v", err) - } - // RLP - parsedTx, err := encodeDecodeBinary(tx) - if err != nil { - t.Fatal(err) - } - assertEqual(parsedTx, tx) - // JSON - parsedTx, err = encodeDecodeJSON(tx) - if err != nil { - t.Fatal(err) - } - assertEqual(parsedTx, tx) - } -} diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index c4086ab7810a..27a1f4e03779 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1501,7 +1501,7 @@ type SendTxArgs struct { ChainID *hexutil.Big `json:"chainId,omitempty"` } -// setDefaults is a helper function that fills in default values for unspecified tx fields. +// setDefaults fills in default values for unspecified tx fields. func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error { if args.GasPrice == nil { price, err := b.SuggestPrice(ctx) @@ -1535,6 +1535,7 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error { return errors.New(`contract creation without any data provided`) } } + // Estimate the gas usage if necessary. if args.Gas == nil { // For backwards-compatibility reason, we try both input and data @@ -1566,6 +1567,8 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error { return nil } +// toTransaction converts the arguments to a transaction. +// This assumes that setDefaults has been called. func (args *SendTxArgs) toTransaction() *types.Transaction { var input []byte if args.Input != nil { @@ -1573,19 +1576,30 @@ func (args *SendTxArgs) toTransaction() *types.Transaction { } else if args.Data != nil { input = *args.Data } + + var data types.TxData if args.AccessList == nil { - // Legacy tx - if args.To == nil { - return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) + data = &types.LegacyTx{ + Recipient: args.To, + AccountNonce: uint64(*args.Nonce), + GasLimit: uint64(*args.Gas), + Price: (*big.Int)(args.GasPrice), + Amount: (*big.Int)(args.Value), + Payload: input, + } + } else { + data = &types.AccessListTx{ + Recipient: args.To, + Chain: (*big.Int)(args.ChainID), + AccountNonce: uint64(*args.Nonce), + GasLimit: uint64(*args.Gas), + Price: (*big.Int)(args.GasPrice), + Amount: (*big.Int)(args.Value), + Payload: input, + Accesses: args.AccessList, } - return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input) - } - // Access list tx - if args.To == nil { - return types.NewAccessListContractCreation((*big.Int)(args.ChainID), uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input, args.AccessList) } - return types.NewAccessListTransaction((*big.Int)(args.ChainID), uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input, args.AccessList) - + return types.NewTx(data) } // SubmitTransaction is a helper function that submits tx to txPool and logs a message. From f02d1d11a9cc461d811901f331e321ecc465bdce Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 14:27:43 +0100 Subject: [PATCH 58/83] core/types: add MustSignNewTx --- core/types/transaction_signing.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 778126f8864f..4154ff4cc117 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -75,6 +75,16 @@ func SignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) (*Transaction, er return tx.WithSignature(s, sig) } +// MustSignNewTx creates a transaction and signs it. +// This panics if the transaction cannot be signed. +func MustSignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) *Transaction { + tx, err := SignNewTx(prv, s, txdata) + if err != nil { + panic(err) + } + return tx +} + // Sender returns the address derived from the signature (V, R, S) using secp256k1 // elliptic curve and an error if it failed deriving or upon an incorrect // signature. From 6e99680c4b3ace03453b3482e8de36b0d7223753 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 14:27:54 +0100 Subject: [PATCH 59/83] miner: fix tests --- miner/worker_test.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/miner/worker_test.go b/miner/worker_test.go index b53603a92650..cc4ab2f28420 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -82,11 +82,23 @@ func init() { Period: 10, Epoch: 30000, } - tx1, _ := types.SignTx(types.NewAccessListTransaction(chainId, 0, testUserAddress, - big.NewInt(1000), params.TxGas, nil, nil, nil), types.NewEIP2718Signer(chainId), testBankKey) + + signer := types.NewEIP2718Signer(chainId) + tx1 := types.MustSignNewTx(testBankKey, signer, &types.AccessListTx{ + Chain: chainId, + AccountNonce: 0, + Recipient: &testUserAddress, + Amount: big.NewInt(1000), + GasLimit: params.TxGas, + }) pendingTxs = append(pendingTxs, tx1) - tx2, _ := types.SignTx(types.NewTransaction(1, testUserAddress, big.NewInt(1000), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey) + tx2 := types.MustSignNewTx(testBankKey, signer, &types.LegacyTx{ + AccountNonce: 1, + Recipient: &testUserAddress, + Amount: big.NewInt(1000), + GasLimit: params.TxGas, + }) newTxs = append(newTxs, tx2) rand.Seed(time.Now().UnixNano()) From 3f316e72da6a3c20a88145deeb0072e448330147 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 14:28:02 +0100 Subject: [PATCH 60/83] miner: use MakeSigner --- miner/worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/worker.go b/miner/worker.go index 3c70aadce7f2..2cee6af0c326 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -654,7 +654,7 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error { state.StartPrefetcher("miner") env := &environment{ - signer: types.NewEIP155Signer(w.chainConfig.ChainID), + signer: types.MakeSigner(w.chainConfig, header.Number), state: state, ancestors: mapset.NewSet(), family: mapset.NewSet(), From 59fcaf83ebfeb358a80b357155365d22d30f6cce Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2021 14:46:53 +0100 Subject: [PATCH 61/83] internal/ethapi: use MakeSigner in getTransactionReceipt --- internal/ethapi/api.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 27a1f4e03779..80370abed6d9 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1422,18 +1422,9 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha } receipt := receipts[index] - txType := tx.Type() - var signer types.Signer = types.FrontierSigner{} - if tx.Protected() { - switch txType { - case types.LegacyTxType: - signer = types.NewEIP155Signer(tx.ChainId()) - case types.AccessListTxType: - // EIP-2930 - signer = types.NewEIP2718Signer(tx.ChainId()) - } - } - + // Derive the sender. + bigblock := new(big.Int).SetUint64(blockNumber) + signer := types.MakeSigner(s.b.ChainConfig(), bigblock) from, _ := types.Sender(signer, tx) fields := map[string]interface{}{ From 3b92b59499dd27ef9076ef3a01314f356f777b0e Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Sun, 21 Feb 2021 15:07:29 +0100 Subject: [PATCH 62/83] internal/ethapi: fix compile flaw --- internal/ethapi/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 80370abed6d9..414d3895ef31 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1455,7 +1455,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha fields["contractAddress"] = receipt.ContractAddress } - if txType != types.LegacyTxType { + if txType := tx.Type(); txType != types.LegacyTxType { fields["type"] = hexutil.Uint(txType) } return fields, nil From dc796a48c259666d32880b0b0d71cf8b71347e15 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 12:20:59 +0100 Subject: [PATCH 63/83] internal/ethapi: use EIP2718 signer --- internal/ethapi/api.go | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 414d3895ef31..c5a3017febc2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1222,15 +1222,19 @@ type RPCTransaction struct { // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { - var signer types.Signer = types.FrontierSigner{} - if tx.Type() == types.AccessListTxType { + // Determine the signer. For replay-protected transactions, use the 'newest' signer, + // because we assume that signers are backwards-compatible with old transactions. For + // non-protected transactions, the homestead signer signer is used because the return + // value of ChainId is zero for those transactions. + var signer types.Signer + if tx.Protected() { signer = types.NewEIP2718Signer(tx.ChainId()) - } else if tx.Protected() { - signer = types.NewEIP155Signer(tx.ChainId()) + } else { + signer = types.HomesteadSigner{} } + from, _ := types.Sender(signer, tx) v, r, s := tx.RawSignatureValues() - result := &RPCTransaction{ From: from, Gas: hexutil.Uint64(tx.Gas()), @@ -1295,11 +1299,15 @@ func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransa type PublicTransactionPoolAPI struct { b Backend nonceLock *AddrLocker + signer types.Signer } // NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool. func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI { - return &PublicTransactionPoolAPI{b, nonceLock} + // The signer used by the API should always be the 'latest' known one because we expect + // signers to be backwards-compatible with old transactions. + signer := types.NewEIP2718Signer(b.ChainConfig().ChainID) + return &PublicTransactionPoolAPI{b, nonceLock, signer} } // GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number. @@ -1454,9 +1462,8 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha if receipt.ContractAddress != (common.Address{}) { fields["contractAddress"] = receipt.ContractAddress } - - if txType := tx.Type(); txType != types.LegacyTxType { - fields["type"] = hexutil.Uint(txType) + if tx.Type() != types.LegacyTxType { + fields["type"] = hexutil.Uint(tx.Type()) } return fields, nil } @@ -1758,11 +1765,7 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, err } transactions := make([]*RPCTransaction, 0, len(pending)) for _, tx := range pending { - var signer types.Signer = types.HomesteadSigner{} - if tx.Protected() { - signer = types.NewEIP155Signer(tx.ChainId()) - } - from, _ := types.Sender(signer, tx) + from, _ := types.Sender(s.signer, tx) if _, exists := accounts[from]; exists { transactions = append(transactions, newRPCPendingTransaction(tx)) } @@ -1799,13 +1802,9 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxAr return common.Hash{}, err } for _, p := range pending { - var signer types.Signer = types.HomesteadSigner{} - if p.Protected() { - signer = types.NewEIP155Signer(p.ChainId()) - } - wantSigHash := signer.Hash(matchTx) - - if pFrom, err := types.Sender(signer, p); err == nil && pFrom == sendArgs.From && signer.Hash(p) == wantSigHash { + wantSigHash := s.signer.Hash(matchTx) + pFrom, err := types.Sender(s.signer, p) + if err == nil && pFrom == sendArgs.From && s.signer.Hash(p) == wantSigHash { // Match. Re-sign and send the transaction. if gasPrice != nil && (*big.Int)(gasPrice).Sign() != 0 { sendArgs.GasPrice = gasPrice @@ -1823,7 +1822,6 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxAr return signedTx.Hash(), nil } } - return common.Hash{}, fmt.Errorf("transaction %#x not found", matchTx.Hash()) } From 068899b67ec777d8025ea794958ba009ccf3debf Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 12:23:29 +0100 Subject: [PATCH 64/83] internal/ethapi: set "type" for all transactions --- internal/ethapi/api.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index c5a3017febc2..c92ae66d3eb2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1447,6 +1447,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha "contractAddress": nil, "logs": receipt.Logs, "logsBloom": receipt.Bloom, + "type": hexutil.Uint(tx.Type()), } // Assign receipt status or post state. @@ -1462,9 +1463,6 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha if receipt.ContractAddress != (common.Address{}) { fields["contractAddress"] = receipt.ContractAddress } - if tx.Type() != types.LegacyTxType { - fields["type"] = hexutil.Uint(tx.Type()) - } return fields, nil } From 3cde5451fc19f45c2a68ddc0f8159ef8c0991e2a Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 12:27:36 +0100 Subject: [PATCH 65/83] core/types: make access list optional in JSON --- core/types/transaction_marshalling.go | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 2b0d7cff4fed..54e3cae50547 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -11,7 +11,7 @@ import ( // txJSON is the JSON representation of transactions. type txJSON struct { - Type *hexutil.Uint64 `json:"type"` + Type hexutil.Uint64 `json:"type"` // Common transaction fields: AccountNonce *hexutil.Uint64 `json:"nonce"` @@ -29,19 +29,15 @@ type txJSON struct { AccessList *AccessList `json:"accessList,omitempty"` // Only used for encoding: - Hash *common.Hash `json:"hash"` + Hash common.Hash `json:"hash"` } // MarshalJSON marshals as JSON with a hash. func (t *Transaction) MarshalJSON() ([]byte, error) { - var ( - enc txJSON - typ = hexutil.Uint64(t.Type()) - hash = t.Hash() - ) + var enc txJSON // These are set for all tx types. - enc.Hash = &hash - enc.Type = &typ + enc.Hash = t.Hash() + enc.Type = hexutil.Uint64(t.Type()) // Other fields are set conditionally depending on tx type. switch tx := t.inner.(type) { @@ -77,15 +73,10 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { if err := json.Unmarshal(input, &dec); err != nil { return err } - // Find the transaction type. - typ := hexutil.Uint64(LegacyTxType) - if dec.Type != nil { - typ = *dec.Type - } // Decode / verify fields according to transaction type. var inner TxData - switch typ { + switch dec.Type { case LegacyTxType: var itx LegacyTx inner = &itx @@ -134,10 +125,10 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { case AccessListTxType: var itx AccessListTx inner = &itx - if dec.AccessList == nil { - return errors.New("missing required field 'accessList' in transaction") + // Access list is optional for now. + if dec.AccessList != nil { + itx.Accesses = dec.AccessList } - itx.Accesses = dec.AccessList if dec.ChainID == nil { return errors.New("missing required field 'chainId' in transaction") } From c0743fe936a2c7ca8ed6e9f94e24c6d0792a9ea6 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 12:51:59 +0100 Subject: [PATCH 66/83] internal/ethapi: always return tx type, part 2 --- internal/ethapi/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index c92ae66d3eb2..f2bc592779fb 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1211,8 +1211,8 @@ type RPCTransaction struct { To *common.Address `json:"to"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` Value *hexutil.Big `json:"value"` + Type hexutil.Uint64 `json:"type"` Accesses *types.AccessList `json:"accessList,omitempty"` - Type hexutil.Uint64 `json:"type,omitempty"` ChainID *hexutil.Big `json:"chainId,omitempty"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` @@ -1236,6 +1236,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber from, _ := types.Sender(signer, tx) v, r, s := tx.RawSignatureValues() result := &RPCTransaction{ + Type: hexutil.Uint64(tx.Type()), From: from, Gas: hexutil.Uint64(tx.Gas()), GasPrice: (*hexutil.Big)(tx.GasPrice()), @@ -1254,7 +1255,6 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber result.TransactionIndex = (*hexutil.Uint64)(&index) } if tx.Type() == types.AccessListTxType { - result.Type = hexutil.Uint64(tx.Type()) result.Accesses = tx.AccessList() result.ChainID = (*hexutil.Big)(tx.ChainId()) } From d866788b77dd2f4afb5c8fdddcefe500402e7875 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 13:31:57 +0100 Subject: [PATCH 67/83] core/types: un-pointer access lists --- accounts/abi/bind/backends/simulated.go | 18 +++++------ core/blockchain_test.go | 8 ++--- core/state/statedb.go | 12 +++---- core/state_transition.go | 4 +-- core/types/access_list_tx.go | 35 ++++++++++---------- core/types/block_test.go | 7 +--- core/types/gen_access_tuple.go | 43 +++++++++++++++++++++++++ core/types/legacy_tx.go | 18 +++++------ core/types/transaction.go | 26 +++++++-------- core/types/transaction_marshalling.go | 4 +-- core/types/transaction_test.go | 11 ++----- core/vm/interface.go | 2 +- interfaces.go | 15 +++++---- internal/ethapi/api.go | 14 +++++--- 14 files changed, 125 insertions(+), 92 deletions(-) create mode 100644 core/types/gen_access_tuple.go diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 0ebce994a98d..a0ff5b93f4d6 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -707,15 +707,15 @@ type callMsg struct { ethereum.CallMsg } -func (m callMsg) From() common.Address { return m.CallMsg.From } -func (m callMsg) Nonce() uint64 { return 0 } -func (m callMsg) CheckNonce() bool { return false } -func (m callMsg) To() *common.Address { return m.CallMsg.To } -func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } -func (m callMsg) Gas() uint64 { return m.CallMsg.Gas } -func (m callMsg) Value() *big.Int { return m.CallMsg.Value } -func (m callMsg) Data() []byte { return m.CallMsg.Data } -func (m callMsg) AccessList() *types.AccessList { return m.CallMsg.AccessList } +func (m callMsg) From() common.Address { return m.CallMsg.From } +func (m callMsg) Nonce() uint64 { return 0 } +func (m callMsg) CheckNonce() bool { return false } +func (m callMsg) To() *common.Address { return m.CallMsg.To } +func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } +func (m callMsg) Gas() uint64 { return m.CallMsg.Gas } +func (m callMsg) Value() *big.Int { return m.CallMsg.Value } +func (m callMsg) Data() []byte { return m.CallMsg.Data } +func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList } // filterBackend implements filters.Backend to support filtering for logs without // taking bloom-bits acceleration structures into account. diff --git a/core/blockchain_test.go b/core/blockchain_test.go index e399ffb29087..b7143ea2150a 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -3079,11 +3079,9 @@ func TestEIP2718Transition(t *testing.T) { Recipient: &aa, GasLimit: 30000, Price: big.NewInt(1), - Accesses: &types.AccessList{types.AccessTuple{ - Address: &aa, - StorageKeys: []*common.Hash{ - {0}, - }, + Accesses: types.AccessList{{ + Address: aa, + StorageKeys: []common.Hash{{0}}, }}, }) b.AddTx(tx) diff --git a/core/state/statedb.go b/core/state/statedb.go index 5032eee88765..2e5d6e47c83c 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -992,7 +992,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { // - Add the contents of the optional tx access list (2930) // // This method should only be called if Yolov3/Berlin/2929+2930 is applicable at the current number. -func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, accessList *types.AccessList) { +func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) { s.AddAddressToAccessList(sender) if dst != nil { s.AddAddressToAccessList(*dst) @@ -1001,12 +1001,10 @@ func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, for _, addr := range precompiles { s.AddAddressToAccessList(addr) } - if accessList != nil { - for _, el := range *accessList { - s.AddAddressToAccessList(*el.Address) - for _, key := range el.StorageKeys { - s.AddSlotToAccessList(*el.Address, *key) - } + for _, el := range list { + s.AddAddressToAccessList(el.Address) + for _, key := range el.StorageKeys { + s.AddSlotToAccessList(el.Address, key) } } } diff --git a/core/state_transition.go b/core/state_transition.go index a3260b2c2a06..9e088497e188 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -68,7 +68,7 @@ type Message interface { Nonce() uint64 CheckNonce() bool Data() []byte - AccessList() *types.AccessList + AccessList() types.AccessList } // ExecutionResult includes all output after executing given evm @@ -107,7 +107,7 @@ func (result *ExecutionResult) Revert() []byte { } // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. -func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation bool, isHomestead, isEIP2028 bool) (uint64, error) { +func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool, isHomestead, isEIP2028 bool) (uint64, error) { // Set the starting gas for the raw transaction var gas uint64 if isContractCreation && isHomestead { diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 6a70be3ac994..6f44d83b5837 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -22,9 +22,11 @@ import ( "github.com/ethereum/go-ethereum/common" ) +//go:generate gencodec -type AccessTuple -out gen_access_tuple.go + type AccessTuple struct { - Address *common.Address `json:"address" gencodec:"required"` - StorageKeys []*common.Hash `json:"storageKeys" gencodec:"required"` + Address common.Address `json:"address" gencodec:"required"` + StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` } type AccessList []AccessTuple @@ -46,7 +48,7 @@ type AccessListTx struct { Recipient *common.Address `rlp:"nil"` // nil means contract creation Amount *big.Int Payload []byte - Accesses *AccessList + Accesses AccessList // Signature values V *big.Int @@ -62,7 +64,7 @@ func (tx *AccessListTx) copy() TxData { Payload: common.CopyBytes(tx.Payload), GasLimit: tx.GasLimit, // These are copied below. - Accesses: new(AccessList), + Accesses: make(AccessList, len(tx.Accesses)), Amount: new(big.Int), Chain: new(big.Int), Price: new(big.Int), @@ -70,10 +72,7 @@ func (tx *AccessListTx) copy() TxData { R: new(big.Int), S: new(big.Int), } - if tx.Accesses != nil { - // TODO: deep copy - cpy.Accesses = tx.Accesses - } + copy(cpy.Accesses, tx.Accesses) if tx.Amount != nil { cpy.Amount.Set(tx.Amount) } @@ -97,15 +96,15 @@ func (tx *AccessListTx) copy() TxData { // accessors for innerTx. -func (tx *AccessListTx) txType() byte { return AccessListTxType } -func (tx *AccessListTx) chainID() *big.Int { return tx.Chain } -func (tx *AccessListTx) protected() bool { return true } -func (tx *AccessListTx) accessList() *AccessList { return tx.Accesses } -func (tx *AccessListTx) data() []byte { return tx.Payload } -func (tx *AccessListTx) gas() uint64 { return tx.GasLimit } -func (tx *AccessListTx) gasPrice() *big.Int { return tx.Price } -func (tx *AccessListTx) value() *big.Int { return tx.Amount } -func (tx *AccessListTx) nonce() uint64 { return tx.AccountNonce } -func (tx *AccessListTx) to() *common.Address { return tx.Recipient } +func (tx *AccessListTx) txType() byte { return AccessListTxType } +func (tx *AccessListTx) chainID() *big.Int { return tx.Chain } +func (tx *AccessListTx) protected() bool { return true } +func (tx *AccessListTx) accessList() AccessList { return tx.Accesses } +func (tx *AccessListTx) data() []byte { return tx.Payload } +func (tx *AccessListTx) gas() uint64 { return tx.GasLimit } +func (tx *AccessListTx) gasPrice() *big.Int { return tx.Price } +func (tx *AccessListTx) value() *big.Int { return tx.Amount } +func (tx *AccessListTx) nonce() uint64 { return tx.AccountNonce } +func (tx *AccessListTx) to() *common.Address { return tx.Recipient } func (tx *AccessListTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } diff --git a/core/types/block_test.go b/core/types/block_test.go index 7792472f7a03..fd53fb6f2946 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -110,12 +110,7 @@ func TestEIP2718BlockEncoding(t *testing.T) { Recipient: &to, GasLimit: 123457, Price: big.NewInt(10), - Accesses: &AccessList{AccessTuple{ - Address: &addr, - StorageKeys: []*common.Hash{ - {0}, - }, - }}, + Accesses: AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}, }) sig2 := common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401") tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), sig2) diff --git a/core/types/gen_access_tuple.go b/core/types/gen_access_tuple.go new file mode 100644 index 000000000000..fc48a84cc0c0 --- /dev/null +++ b/core/types/gen_access_tuple.go @@ -0,0 +1,43 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package types + +import ( + "encoding/json" + "errors" + + "github.com/ethereum/go-ethereum/common" +) + +// MarshalJSON marshals as JSON. +func (a AccessTuple) MarshalJSON() ([]byte, error) { + type AccessTuple struct { + Address common.Address `json:"address" gencodec:"required"` + StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` + } + var enc AccessTuple + enc.Address = a.Address + enc.StorageKeys = a.StorageKeys + return json.Marshal(&enc) +} + +// UnmarshalJSON unmarshals from JSON. +func (a *AccessTuple) UnmarshalJSON(input []byte) error { + type AccessTuple struct { + Address *common.Address `json:"address" gencodec:"required"` + StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` + } + var dec AccessTuple + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.Address == nil { + return errors.New("missing required field 'address' for AccessTuple") + } + a.Address = *dec.Address + if dec.StorageKeys == nil { + return errors.New("missing required field 'storageKeys' for AccessTuple") + } + a.StorageKeys = dec.StorageKeys + return nil +} diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index f75ef7cbc770..7f2f3f7f0cc1 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -95,15 +95,15 @@ func (tx *LegacyTx) copy() TxData { // accessors for innerTx. -func (tx *LegacyTx) txType() byte { return LegacyTxType } -func (tx *LegacyTx) chainID() *big.Int { return deriveChainId(tx.V) } -func (tx *LegacyTx) accessList() *AccessList { return nil } -func (tx *LegacyTx) data() []byte { return tx.Payload } -func (tx *LegacyTx) gas() uint64 { return tx.GasLimit } -func (tx *LegacyTx) gasPrice() *big.Int { return tx.Price } -func (tx *LegacyTx) value() *big.Int { return tx.Amount } -func (tx *LegacyTx) nonce() uint64 { return tx.AccountNonce } -func (tx *LegacyTx) to() *common.Address { return tx.Recipient } +func (tx *LegacyTx) txType() byte { return LegacyTxType } +func (tx *LegacyTx) chainID() *big.Int { return deriveChainId(tx.V) } +func (tx *LegacyTx) accessList() AccessList { return nil } +func (tx *LegacyTx) data() []byte { return tx.Payload } +func (tx *LegacyTx) gas() uint64 { return tx.GasLimit } +func (tx *LegacyTx) gasPrice() *big.Int { return tx.Price } +func (tx *LegacyTx) value() *big.Int { return tx.Amount } +func (tx *LegacyTx) nonce() uint64 { return tx.AccountNonce } +func (tx *LegacyTx) to() *common.Address { return tx.Recipient } func (tx *LegacyTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S diff --git a/core/types/transaction.go b/core/types/transaction.go index 6782630b1547..d090d5571a3d 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -70,7 +70,7 @@ type TxData interface { copy() TxData // creates a deep copy and initializes all fields chainID() *big.Int - accessList() *AccessList + accessList() AccessList data() []byte gas() uint64 gasPrice() *big.Int @@ -250,7 +250,7 @@ func (tx *Transaction) ChainId() *big.Int { func (tx *Transaction) Data() []byte { return tx.inner.data() } // AccessList returns the access list of the transaction. -func (tx *Transaction) AccessList() *AccessList { return tx.inner.accessList() } +func (tx *Transaction) AccessList() AccessList { return tx.inner.accessList() } // Gas returns the gas limit of the transaction. func (tx *Transaction) Gas() uint64 { return tx.inner.gas() } @@ -517,11 +517,11 @@ type Message struct { gasLimit uint64 gasPrice *big.Int data []byte - accessList *AccessList + accessList AccessList checkNonce bool } -func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList *AccessList, checkNonce bool) Message { +func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList AccessList, checkNonce bool) Message { return Message{ from: from, to: to, @@ -553,12 +553,12 @@ func (tx *Transaction) AsMessage(s Signer) (Message, error) { return msg, err } -func (m Message) From() common.Address { return m.from } -func (m Message) To() *common.Address { return m.to } -func (m Message) GasPrice() *big.Int { return m.gasPrice } -func (m Message) Value() *big.Int { return m.amount } -func (m Message) Gas() uint64 { return m.gasLimit } -func (m Message) Nonce() uint64 { return m.nonce } -func (m Message) Data() []byte { return m.data } -func (m Message) AccessList() *AccessList { return m.accessList } -func (m Message) CheckNonce() bool { return m.checkNonce } +func (m Message) From() common.Address { return m.from } +func (m Message) To() *common.Address { return m.to } +func (m Message) GasPrice() *big.Int { return m.gasPrice } +func (m Message) Value() *big.Int { return m.amount } +func (m Message) Gas() uint64 { return m.gasLimit } +func (m Message) Nonce() uint64 { return m.nonce } +func (m Message) Data() []byte { return m.data } +func (m Message) AccessList() AccessList { return m.accessList } +func (m Message) CheckNonce() bool { return m.checkNonce } diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 54e3cae50547..168d266c0c35 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -53,7 +53,7 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { enc.S = (*hexutil.Big)(tx.S) case *AccessListTx: enc.ChainID = (*hexutil.Big)(tx.Chain) - enc.AccessList = tx.Accesses + enc.AccessList = &tx.Accesses enc.AccountNonce = (*hexutil.Uint64)(&tx.AccountNonce) enc.GasLimit = (*hexutil.Uint64)(&tx.GasLimit) enc.Price = (*hexutil.Big)(tx.Price) @@ -127,7 +127,7 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { inner = &itx // Access list is optional for now. if dec.AccessList != nil { - itx.Accesses = dec.AccessList + itx.Accesses = *dec.AccessList } if dec.ChainID == nil { return errors.New("missing required field 'chainId' in transaction") diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 2791599817b0..69bf0d0025cd 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -316,12 +316,7 @@ func TestTransactionCoding(t *testing.T) { signer = NewEIP2718Signer(common.Big1) addr = common.HexToAddress("0x0000000000000000000000000000000000000001") recipient = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87") - accesses = AccessList{ - AccessTuple{ - Address: &addr, - StorageKeys: []*common.Hash{{0}}, - }, - } + accesses = AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}} ) for i := uint64(0); i < 500; i++ { var txdata TxData @@ -351,7 +346,7 @@ func TestTransactionCoding(t *testing.T) { Recipient: &recipient, GasLimit: 123457, Price: big.NewInt(10), - Accesses: &accesses, + Accesses: accesses, Payload: []byte("abcdef"), } case 3: @@ -371,7 +366,7 @@ func TestTransactionCoding(t *testing.T) { AccountNonce: i, GasLimit: 123457, Price: big.NewInt(10), - Accesses: &accesses, + Accesses: accesses, } } tx, err := SignNewTx(key, signer, txdata) diff --git a/core/vm/interface.go b/core/vm/interface.go index f8ee4f8f6761..ad9b05d666a8 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -57,7 +57,7 @@ type StateDB interface { // is defined according to EIP161 (balance = nonce = code = 0). Empty(common.Address) bool - PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses *types.AccessList) + PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) AddressInAccessList(addr common.Address) bool SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool) // AddAddressToAccessList adds the given address to the access list. This operation is safe to perform diff --git a/interfaces.go b/interfaces.go index 2a5c1bfb4543..afcdc17e5824 100644 --- a/interfaces.go +++ b/interfaces.go @@ -113,13 +113,14 @@ type ChainSyncReader interface { // CallMsg contains parameters for contract calls. type CallMsg struct { - From common.Address // the sender of the 'transaction' - To *common.Address // the destination contract (nil for contract creation) - Gas uint64 // if 0, the call executes with near-infinite gas - GasPrice *big.Int // wei <-> gas exchange ratio - Value *big.Int // amount of wei sent along with the call - Data []byte // input data, usually an ABI-encoded contract method invocation - AccessList *types.AccessList // EIP-2930 access list + From common.Address // the sender of the 'transaction' + To *common.Address // the destination contract (nil for contract creation) + Gas uint64 // if 0, the call executes with near-infinite gas + GasPrice *big.Int // wei <-> gas exchange ratio + Value *big.Int // amount of wei sent along with the call + Data []byte // input data, usually an ABI-encoded contract method invocation + + AccessList types.AccessList // EIP-2930 access list. } // A ContractCaller provides contract calls, essentially transactions that are executed by diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index f2bc592779fb..6ad626804477 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -781,17 +781,20 @@ func (args *CallArgs) ToMessage(globalGasCap uint64) types.Message { if args.GasPrice != nil { gasPrice = args.GasPrice.ToInt() } - value := new(big.Int) if args.Value != nil { value = args.Value.ToInt() } - var data []byte if args.Data != nil { data = *args.Data } - msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, args.AccessList, false) + var accessList types.AccessList + if args.AccessList != nil { + accessList = *args.AccessList + } + + msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, accessList, false) return msg } @@ -1255,7 +1258,8 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber result.TransactionIndex = (*hexutil.Uint64)(&index) } if tx.Type() == types.AccessListTxType { - result.Accesses = tx.AccessList() + al := tx.AccessList() + result.Accesses = &al result.ChainID = (*hexutil.Big)(tx.ChainId()) } return result @@ -1592,7 +1596,7 @@ func (args *SendTxArgs) toTransaction() *types.Transaction { Price: (*big.Int)(args.GasPrice), Amount: (*big.Int)(args.Value), Payload: input, - Accesses: args.AccessList, + Accesses: *args.AccessList, } } return types.NewTx(data) From 857123f8ddad6b8ce73bd2c78517d8d13e49c4f8 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 13:35:33 +0100 Subject: [PATCH 68/83] core/types: add documentation for access list transaction types --- core/types/access_list_tx.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 6f44d83b5837..b36fa96ab32c 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -24,14 +24,21 @@ import ( //go:generate gencodec -type AccessTuple -out gen_access_tuple.go +// AccessList is an EIP-2930 access list. +type AccessList []AccessTuple + +// AccessTuple is the element type of an access list. type AccessTuple struct { Address common.Address `json:"address" gencodec:"required"` StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` } -type AccessList []AccessTuple +// Addresses returns the number of accounts covered by the access list. +func (al *AccessList) Addresses() int { + return len(*al) +} -func (al *AccessList) Addresses() int { return len(*al) } +// StorageKeys returns the total number of storage keys in the access list. func (al *AccessList) StorageKeys() int { sum := 0 for _, tuple := range *al { @@ -40,6 +47,7 @@ func (al *AccessList) StorageKeys() int { return sum } +// AccessListTx is the transaction data of EIP-2930 access list transactions. type AccessListTx struct { Chain *big.Int AccountNonce uint64 From f5af3c42a617ee3ce63dfb330eb18bfe4ba5ccf7 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 13:39:45 +0100 Subject: [PATCH 69/83] core/types: use copy() in WithSignature --- core/types/access_list_tx.go | 8 +++++++- core/types/legacy_tx.go | 4 ++++ core/types/transaction.go | 40 +++++------------------------------- 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index b36fa96ab32c..b36e141d7519 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -115,4 +115,10 @@ func (tx *AccessListTx) value() *big.Int { return tx.Amount } func (tx *AccessListTx) nonce() uint64 { return tx.AccountNonce } func (tx *AccessListTx) to() *common.Address { return tx.Recipient } -func (tx *AccessListTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } +func (tx *AccessListTx) rawSignatureValues() (v, r, s *big.Int) { + return tx.V, tx.R, tx.S +} + +func (tx *AccessListTx) setSignatureValues(v, r, s *big.Int) { + tx.V, tx.R, tx.S = v, r, s +} diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 7f2f3f7f0cc1..ca2e49bd199f 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -108,3 +108,7 @@ func (tx *LegacyTx) to() *common.Address { return tx.Recipient } func (tx *LegacyTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } + +func (tx *LegacyTx) setSignatureValues(v, r, s *big.Int) { + tx.V, tx.R, tx.S = v, r, s +} diff --git a/core/types/transaction.go b/core/types/transaction.go index d090d5571a3d..32b9a7dd3226 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -77,7 +77,9 @@ type TxData interface { value() *big.Int nonce() uint64 to() *common.Address + rawSignatureValues() (v, r, s *big.Int) + setSignatureValues(v, r, s *big.Int) } // EncodeRLP implements rlp.Encoder @@ -334,41 +336,9 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e if err != nil { return nil, err } - // Copy inner transaction. - var cpy TxData - switch inner := tx.inner.(type) { - case *LegacyTx: - cpy = &LegacyTx{ - AccountNonce: inner.AccountNonce, - Price: inner.Price, - GasLimit: inner.GasLimit, - Recipient: inner.Recipient, - Amount: inner.Amount, - Payload: inner.Payload, - V: v, - R: r, - S: s, - } - case *AccessListTx: - cpy = &AccessListTx{ - Chain: inner.Chain, - AccountNonce: inner.AccountNonce, - Price: inner.Price, - GasLimit: inner.GasLimit, - Recipient: inner.Recipient, - Amount: inner.Amount, - Payload: inner.Payload, - Accesses: inner.Accesses, - V: v, - R: r, - S: s, - } - default: - return nil, ErrInvalidTxType - } - // Copy outer transaction. - ret := &Transaction{inner: cpy, time: tx.time} - return ret, nil + cpy := tx.inner.copy() + cpy.setSignatureValues(v, r, s) + return &Transaction{inner: cpy, time: tx.time}, nil } // Transactions implements DerivableList for transactions. From 0fbc0484b843ee851cb39f4cbaa96b3b25704bb3 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 13:50:48 +0100 Subject: [PATCH 70/83] core/types: add documentation comment for LegacyTx --- core/types/legacy_tx.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index ca2e49bd199f..0a5fe986ac2b 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -22,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" ) +// LegacyTx is the transaction data of regular Ethereum transactions. type LegacyTx struct { AccountNonce uint64 Price *big.Int From fa857ea545d9202ba9c32ae25f5fcd2ec41e7427 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 22 Feb 2021 13:55:58 +0100 Subject: [PATCH 71/83] core/types: remove AccessList.Addresses --- core/state_transition.go | 2 +- core/types/access_list_tx.go | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 9e088497e188..0d589a6119f7 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -141,7 +141,7 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b gas += z * params.TxDataZeroGas } if accessList != nil { - gas += uint64(accessList.Addresses()) * params.TxAccessListAddressGas + gas += uint64(len(accessList)) * params.TxAccessListAddressGas gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas } return gas, nil diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index b36e141d7519..8d37aefc255a 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -33,15 +33,10 @@ type AccessTuple struct { StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` } -// Addresses returns the number of accounts covered by the access list. -func (al *AccessList) Addresses() int { - return len(*al) -} - // StorageKeys returns the total number of storage keys in the access list. -func (al *AccessList) StorageKeys() int { +func (al AccessList) StorageKeys() int { sum := 0 - for _, tuple := range *al { + for _, tuple := range al { sum += len(tuple.StorageKeys) } return sum From 130c1e500fb5aae54753eceb53aba92413746fbd Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 23 Feb 2021 09:20:16 +0100 Subject: [PATCH 72/83] cmd/evm: fix t8ntool receipt root hash --- cmd/evm/internal/t8ntool/execution.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 00e1c536dce4..ea913f39cab2 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -168,7 +168,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, root = statedb.IntermediateRoot(chainConfig.IsEIP158(vmContext.BlockNumber)).Bytes() } - receipt := types.NewReceipt(root, msgResult.Failed(), gasUsed) + receipt = types.NewEIP2718Receipt(tx.Type(), root, msgResult.Failed(), gasUsed) receipt.TxHash = tx.Hash() receipt.GasUsed = msgResult.UsedGas // if the transaction created a contract, store the creation address in the receipt. @@ -180,7 +180,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) // These three are non-consensus fields //receipt.BlockHash - //receipt.BlockNumber = + //receipt.BlockNumber receipt.TransactionIndex = uint(txIndex) receipts = append(receipts, receipt) } From 0578680a43e5b837941c0d0f8ccc909cb71ab86a Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 23 Feb 2021 09:24:19 +0100 Subject: [PATCH 73/83] core: simplify receipt logic in state processor --- core/state_processor.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index 484ba8d30a6a..d72c9a3d3989 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -110,12 +110,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon // Create a new receipt for the transaction, storing the intermediate root and gas used by the tx // based on the eip phase, we're passing whether the root touch-delete accounts. - var receipt *types.Receipt - if config.IsYoloV3(header.Number) { - receipt = types.NewEIP2718Receipt(tx.Type(), root, result.Failed(), *usedGas) - } else { - receipt = types.NewReceipt(root, result.Failed(), *usedGas) - } + receipt := types.NewEIP2718Receipt(tx.Type(), root, result.Failed(), *usedGas) receipt.TxHash = tx.Hash() receipt.GasUsed = result.UsedGas // if the transaction created a contract, store the creation address in the receipt. From 131c3883938b0f78f58a572997a333d76bc4f08b Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 23 Feb 2021 16:29:07 +0100 Subject: [PATCH 74/83] core/types: remove NewEIP2718Receipt --- cmd/evm/internal/t8ntool/execution.go | 21 ++++++++++++++++----- core/state_processor.go | 19 +++++++++++++------ core/types/receipt.go | 12 ++++++------ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index ea913f39cab2..c3f1b16efc9b 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -159,7 +159,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, return nil, nil, NewError(ErrorMissingBlockhash, hashError) } gasUsed += msgResult.UsedGas - // Create a new receipt for the transaction, storing the intermediate root and gas used by the tx + + // Receipt: { var root []byte if chainConfig.IsByzantium(vmContext.BlockNumber) { @@ -168,22 +169,32 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, root = statedb.IntermediateRoot(chainConfig.IsEIP158(vmContext.BlockNumber)).Bytes() } - receipt = types.NewEIP2718Receipt(tx.Type(), root, msgResult.Failed(), gasUsed) + // Create a new receipt for the transaction, storing the intermediate root and + // gas used by the tx. + receipt := &types.Receipt{Type: tx.Type(), PostState: root, CumulativeGasUsed: gasUsed} + if msgResult.Failed() { + receipt.Status = types.ReceiptStatusFailed + } else { + receipt.Status = types.ReceiptStatusSuccessful + } receipt.TxHash = tx.Hash() receipt.GasUsed = msgResult.UsedGas - // if the transaction created a contract, store the creation address in the receipt. + + // If the transaction created a contract, store the creation address in the receipt. if msg.To() == nil { receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce()) } - // Set the receipt logs and create a bloom for filtering + + // Set the receipt logs and create the bloom filter. receipt.Logs = statedb.GetLogs(tx.Hash()) receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) - // These three are non-consensus fields + // These three are non-consensus fields: //receipt.BlockHash //receipt.BlockNumber receipt.TransactionIndex = uint(txIndex) receipts = append(receipts, receipt) } + txIndex++ } statedb.IntermediateRoot(chainConfig.IsEIP158(vmContext.BlockNumber)) diff --git a/core/state_processor.go b/core/state_processor.go index d72c9a3d3989..40a953f0d4f8 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -99,6 +99,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon if err != nil { return nil, err } + // Update the state with pending changes. var root []byte if config.IsByzantium(header.Number) { @@ -108,22 +109,28 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon } *usedGas += result.UsedGas - // Create a new receipt for the transaction, storing the intermediate root and gas used by the tx - // based on the eip phase, we're passing whether the root touch-delete accounts. - receipt := types.NewEIP2718Receipt(tx.Type(), root, result.Failed(), *usedGas) + // Create a new receipt for the transaction, storing the intermediate root and gas used + // by the tx. + receipt := &types.Receipt{Type: tx.Type(), PostState: root, CumulativeGasUsed: *usedGas} + if result.Failed() { + receipt.Status = types.ReceiptStatusFailed + } else { + receipt.Status = types.ReceiptStatusSuccessful + } receipt.TxHash = tx.Hash() receipt.GasUsed = result.UsedGas - // if the transaction created a contract, store the creation address in the receipt. + + // If the transaction created a contract, store the creation address in the receipt. if msg.To() == nil { receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce()) } - // Set the receipt logs and create a bloom for filtering + + // Set the receipt logs and create the bloom filter. receipt.Logs = statedb.GetLogs(tx.Hash()) receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) receipt.BlockHash = statedb.BlockHash() receipt.BlockNumber = header.Number receipt.TransactionIndex = uint(statedb.TxIndex()) - return receipt, err } diff --git a/core/types/receipt.go b/core/types/receipt.go index 52b92de29eb5..2aa6196604bc 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -117,13 +117,13 @@ type v3StoredReceiptRLP struct { } // NewReceipt creates a barebone transaction receipt, copying the init fields. +// Deprecated: create receipts using a struct literal instead. func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt { - return NewEIP2718Receipt(LegacyTxType, root, failed, cumulativeGasUsed) -} - -// NewEIP2718Receipt creates a barebone transaction receipt for typed transactions, copying the init fields. -func NewEIP2718Receipt(typ uint8, root []byte, failed bool, cumulativeGasUsed uint64) *Receipt { - r := &Receipt{Type: typ, PostState: common.CopyBytes(root), CumulativeGasUsed: cumulativeGasUsed} + r := &Receipt{ + Type: LegacyTxType, + PostState: common.CopyBytes(root), + CumulativeGasUsed: cumulativeGasUsed, + } if failed { r.Status = ReceiptStatusFailed } else { From b74446779bef579085e5718106d01c4321f46fd6 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 23 Feb 2021 16:35:53 +0100 Subject: [PATCH 75/83] core/types: rename LegacyTx/AccessListTx fields This renames the fields of the new tx data types to match the accessor names of Transaction. --- core/blockchain_test.go | 12 ++-- core/types/access_list_tx.go | 76 ++++++++++----------- core/types/block_test.go | 22 +++--- core/types/legacy_tx.go | 78 ++++++++++----------- core/types/receipt_test.go | 28 ++++---- core/types/transaction_marshalling.go | 98 +++++++++++++-------------- core/types/transaction_test.go | 68 +++++++++---------- internal/ethapi/api.go | 28 ++++---- miner/worker_test.go | 18 ++--- 9 files changed, 210 insertions(+), 218 deletions(-) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index b7143ea2150a..100c2fc932c1 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -3074,12 +3074,12 @@ func TestEIP2718Transition(t *testing.T) { // One transaction to 0xAAAA signer := types.NewEIP2718Signer(gspec.Config.ChainID) tx, _ := types.SignNewTx(key, signer, &types.AccessListTx{ - Chain: gspec.Config.ChainID, - AccountNonce: 0, - Recipient: &aa, - GasLimit: 30000, - Price: big.NewInt(1), - Accesses: types.AccessList{{ + ChainID: gspec.Config.ChainID, + Nonce: 0, + To: &aa, + Gas: 30000, + GasPrice: big.NewInt(1), + AccessList: types.AccessList{{ Address: aa, StorageKeys: []common.Hash{{0}}, }}, diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index 8d37aefc255a..d6556ca4aea5 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -42,48 +42,44 @@ func (al AccessList) StorageKeys() int { return sum } -// AccessListTx is the transaction data of EIP-2930 access list transactions. +// AccessListTx is the data of EIP-2930 access list transactions. type AccessListTx struct { - Chain *big.Int - AccountNonce uint64 - Price *big.Int - GasLimit uint64 - Recipient *common.Address `rlp:"nil"` // nil means contract creation - Amount *big.Int - Payload []byte - Accesses AccessList - - // Signature values - V *big.Int - R *big.Int - S *big.Int + ChainID *big.Int // destination chain ID + Nonce uint64 // nonce of sender account + GasPrice *big.Int // wei per gas + Gas uint64 // gas limit + To *common.Address `rlp:"nil"` // nil means contract creation + Value *big.Int // wei amount + Data []byte // contract invocation input data + AccessList AccessList // EIP-2930 access list + V, R, S *big.Int // signature values } // copy creates a deep copy of the transaction data and initializes all fields. func (tx *AccessListTx) copy() TxData { cpy := &AccessListTx{ - AccountNonce: tx.AccountNonce, - Recipient: tx.Recipient, // TODO: copy pointed-to address - Payload: common.CopyBytes(tx.Payload), - GasLimit: tx.GasLimit, + Nonce: tx.Nonce, + To: tx.To, // TODO: copy pointed-to address + Data: common.CopyBytes(tx.Data), + Gas: tx.Gas, // These are copied below. - Accesses: make(AccessList, len(tx.Accesses)), - Amount: new(big.Int), - Chain: new(big.Int), - Price: new(big.Int), - V: new(big.Int), - R: new(big.Int), - S: new(big.Int), + AccessList: make(AccessList, len(tx.AccessList)), + Value: new(big.Int), + ChainID: new(big.Int), + GasPrice: new(big.Int), + V: new(big.Int), + R: new(big.Int), + S: new(big.Int), } - copy(cpy.Accesses, tx.Accesses) - if tx.Amount != nil { - cpy.Amount.Set(tx.Amount) + copy(cpy.AccessList, tx.AccessList) + if tx.Value != nil { + cpy.Value.Set(tx.Value) } - if tx.Chain != nil { - cpy.Chain.Set(tx.Chain) + if tx.ChainID != nil { + cpy.ChainID.Set(tx.ChainID) } - if tx.Price != nil { - cpy.Price.Set(tx.Price) + if tx.GasPrice != nil { + cpy.GasPrice.Set(tx.GasPrice) } if tx.V != nil { cpy.V.Set(tx.V) @@ -100,15 +96,15 @@ func (tx *AccessListTx) copy() TxData { // accessors for innerTx. func (tx *AccessListTx) txType() byte { return AccessListTxType } -func (tx *AccessListTx) chainID() *big.Int { return tx.Chain } +func (tx *AccessListTx) chainID() *big.Int { return tx.ChainID } func (tx *AccessListTx) protected() bool { return true } -func (tx *AccessListTx) accessList() AccessList { return tx.Accesses } -func (tx *AccessListTx) data() []byte { return tx.Payload } -func (tx *AccessListTx) gas() uint64 { return tx.GasLimit } -func (tx *AccessListTx) gasPrice() *big.Int { return tx.Price } -func (tx *AccessListTx) value() *big.Int { return tx.Amount } -func (tx *AccessListTx) nonce() uint64 { return tx.AccountNonce } -func (tx *AccessListTx) to() *common.Address { return tx.Recipient } +func (tx *AccessListTx) accessList() AccessList { return tx.AccessList } +func (tx *AccessListTx) data() []byte { return tx.Data } +func (tx *AccessListTx) gas() uint64 { return tx.Gas } +func (tx *AccessListTx) gasPrice() *big.Int { return tx.GasPrice } +func (tx *AccessListTx) value() *big.Int { return tx.Value } +func (tx *AccessListTx) nonce() uint64 { return tx.Nonce } +func (tx *AccessListTx) to() *common.Address { return tx.To } func (tx *AccessListTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S diff --git a/core/types/block_test.go b/core/types/block_test.go index fd53fb6f2946..1ab22be7745b 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -93,11 +93,11 @@ func TestEIP2718BlockEncoding(t *testing.T) { // Create legacy tx. to := common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87") tx1 := NewTx(&LegacyTx{ - AccountNonce: 0, - Recipient: &to, - Amount: big.NewInt(10), - GasLimit: 50000, - Price: big.NewInt(10), + Nonce: 0, + To: &to, + Value: big.NewInt(10), + Gas: 50000, + GasPrice: big.NewInt(10), }) sig := common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100") tx1, _ = tx1.WithSignature(HomesteadSigner{}, sig) @@ -105,12 +105,12 @@ func TestEIP2718BlockEncoding(t *testing.T) { // Create ACL tx. addr := common.HexToAddress("0x0000000000000000000000000000000000000001") tx2 := NewTx(&AccessListTx{ - Chain: big.NewInt(1), - AccountNonce: 0, - Recipient: &to, - GasLimit: 123457, - Price: big.NewInt(10), - Accesses: AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}, + ChainID: big.NewInt(1), + Nonce: 0, + To: &to, + Gas: 123457, + GasPrice: big.NewInt(10), + AccessList: AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}, }) sig2 := common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401") tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), sig2) diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 0a5fe986ac2b..46f1a0e2ee15 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -24,29 +24,25 @@ import ( // LegacyTx is the transaction data of regular Ethereum transactions. type LegacyTx struct { - AccountNonce uint64 - Price *big.Int - GasLimit uint64 - Recipient *common.Address `rlp:"nil"` // nil means contract creation - Amount *big.Int - Payload []byte - - // Signature values. - V *big.Int - R *big.Int - S *big.Int + Nonce uint64 // nonce of sender account + GasPrice *big.Int // wei per gas + Gas uint64 // gas limit + To *common.Address `rlp:"nil"` // nil means contract creation + Value *big.Int // wei amount + Data []byte // contract invocation input data + V, R, S *big.Int // signature values } // NewTransaction creates an unsigned legacy transaction. // Deprecated: use NewTx instead. func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { return NewTx(&LegacyTx{ - AccountNonce: nonce, - Recipient: &to, - Amount: amount, - GasLimit: gasLimit, - Price: gasPrice, - Payload: data, + Nonce: nonce, + To: &to, + Value: amount, + Gas: gasLimit, + GasPrice: gasPrice, + Data: data, }) } @@ -54,33 +50,33 @@ func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit u // Deprecated: use NewTx instead. func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { return NewTx(&LegacyTx{ - AccountNonce: nonce, - Amount: amount, - GasLimit: gasLimit, - Price: gasPrice, - Payload: data, + Nonce: nonce, + Value: amount, + Gas: gasLimit, + GasPrice: gasPrice, + Data: data, }) } // copy creates a deep copy of the transaction data and initializes all fields. func (tx *LegacyTx) copy() TxData { cpy := &LegacyTx{ - AccountNonce: tx.AccountNonce, - Recipient: tx.Recipient, // TODO: copy pointed-to address - Payload: common.CopyBytes(tx.Payload), - GasLimit: tx.GasLimit, + Nonce: tx.Nonce, + To: tx.To, // TODO: copy pointed-to address + Data: common.CopyBytes(tx.Data), + Gas: tx.Gas, // These are initialized below. - Amount: new(big.Int), - Price: new(big.Int), - V: new(big.Int), - R: new(big.Int), - S: new(big.Int), + Value: new(big.Int), + GasPrice: new(big.Int), + V: new(big.Int), + R: new(big.Int), + S: new(big.Int), } - if tx.Amount != nil { - cpy.Amount.Set(tx.Amount) + if tx.Value != nil { + cpy.Value.Set(tx.Value) } - if tx.Price != nil { - cpy.Price.Set(tx.Price) + if tx.GasPrice != nil { + cpy.GasPrice.Set(tx.GasPrice) } if tx.V != nil { cpy.V.Set(tx.V) @@ -99,12 +95,12 @@ func (tx *LegacyTx) copy() TxData { func (tx *LegacyTx) txType() byte { return LegacyTxType } func (tx *LegacyTx) chainID() *big.Int { return deriveChainId(tx.V) } func (tx *LegacyTx) accessList() AccessList { return nil } -func (tx *LegacyTx) data() []byte { return tx.Payload } -func (tx *LegacyTx) gas() uint64 { return tx.GasLimit } -func (tx *LegacyTx) gasPrice() *big.Int { return tx.Price } -func (tx *LegacyTx) value() *big.Int { return tx.Amount } -func (tx *LegacyTx) nonce() uint64 { return tx.AccountNonce } -func (tx *LegacyTx) to() *common.Address { return tx.Recipient } +func (tx *LegacyTx) data() []byte { return tx.Data } +func (tx *LegacyTx) gas() uint64 { return tx.Gas } +func (tx *LegacyTx) gasPrice() *big.Int { return tx.GasPrice } +func (tx *LegacyTx) value() *big.Int { return tx.Value } +func (tx *LegacyTx) nonce() uint64 { return tx.Nonce } +func (tx *LegacyTx) to() *common.Address { return tx.To } func (tx *LegacyTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index 7a32120f1f81..22a316c2374b 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -167,24 +167,24 @@ func TestDeriveFields(t *testing.T) { to3 := common.HexToAddress("0x3") txs := Transactions{ NewTx(&LegacyTx{ - AccountNonce: 1, - Amount: big.NewInt(1), - GasLimit: 1, - Price: big.NewInt(1), + Nonce: 1, + Value: big.NewInt(1), + Gas: 1, + GasPrice: big.NewInt(1), }), NewTx(&LegacyTx{ - Recipient: &to2, - AccountNonce: 2, - Amount: big.NewInt(2), - GasLimit: 2, - Price: big.NewInt(2), + To: &to2, + Nonce: 2, + Value: big.NewInt(2), + Gas: 2, + GasPrice: big.NewInt(2), }), NewTx(&AccessListTx{ - Recipient: &to3, - AccountNonce: 3, - Amount: big.NewInt(3), - GasLimit: 3, - Price: big.NewInt(3), + To: &to3, + Nonce: 3, + Value: big.NewInt(3), + Gas: 3, + GasPrice: big.NewInt(3), }), } // Create the corresponding receipts diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 168d266c0c35..184a17d5b52e 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -14,15 +14,15 @@ type txJSON struct { Type hexutil.Uint64 `json:"type"` // Common transaction fields: - AccountNonce *hexutil.Uint64 `json:"nonce"` - Price *hexutil.Big `json:"gasPrice"` - GasLimit *hexutil.Uint64 `json:"gas"` - Amount *hexutil.Big `json:"value"` - Payload *hexutil.Bytes `json:"input"` - V *hexutil.Big `json:"v"` - R *hexutil.Big `json:"r"` - S *hexutil.Big `json:"s"` - Recipient *common.Address `json:"to"` + Nonce *hexutil.Uint64 `json:"nonce"` + GasPrice *hexutil.Big `json:"gasPrice"` + Gas *hexutil.Uint64 `json:"gas"` + Value *hexutil.Big `json:"value"` + Data *hexutil.Bytes `json:"input"` + V *hexutil.Big `json:"v"` + R *hexutil.Big `json:"r"` + S *hexutil.Big `json:"s"` + To *common.Address `json:"to"` // Access list transaction fields: ChainID *hexutil.Big `json:"chainId,omitempty"` @@ -42,24 +42,24 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { // Other fields are set conditionally depending on tx type. switch tx := t.inner.(type) { case *LegacyTx: - enc.AccountNonce = (*hexutil.Uint64)(&tx.AccountNonce) - enc.GasLimit = (*hexutil.Uint64)(&tx.GasLimit) - enc.Price = (*hexutil.Big)(tx.Price) - enc.Amount = (*hexutil.Big)(tx.Amount) - enc.Payload = (*hexutil.Bytes)(&tx.Payload) - enc.Recipient = t.To() + enc.Nonce = (*hexutil.Uint64)(&tx.Nonce) + enc.Gas = (*hexutil.Uint64)(&tx.Gas) + enc.GasPrice = (*hexutil.Big)(tx.GasPrice) + enc.Value = (*hexutil.Big)(tx.Value) + enc.Data = (*hexutil.Bytes)(&tx.Data) + enc.To = t.To() enc.V = (*hexutil.Big)(tx.V) enc.R = (*hexutil.Big)(tx.R) enc.S = (*hexutil.Big)(tx.S) case *AccessListTx: - enc.ChainID = (*hexutil.Big)(tx.Chain) - enc.AccessList = &tx.Accesses - enc.AccountNonce = (*hexutil.Uint64)(&tx.AccountNonce) - enc.GasLimit = (*hexutil.Uint64)(&tx.GasLimit) - enc.Price = (*hexutil.Big)(tx.Price) - enc.Amount = (*hexutil.Big)(tx.Amount) - enc.Payload = (*hexutil.Bytes)(&tx.Payload) - enc.Recipient = t.To() + enc.ChainID = (*hexutil.Big)(tx.ChainID) + enc.AccessList = &tx.AccessList + enc.Nonce = (*hexutil.Uint64)(&tx.Nonce) + enc.Gas = (*hexutil.Uint64)(&tx.Gas) + enc.GasPrice = (*hexutil.Big)(tx.GasPrice) + enc.Value = (*hexutil.Big)(tx.Value) + enc.Data = (*hexutil.Bytes)(&tx.Data) + enc.To = t.To() enc.V = (*hexutil.Big)(tx.V) enc.R = (*hexutil.Big)(tx.R) enc.S = (*hexutil.Big)(tx.S) @@ -80,29 +80,29 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { case LegacyTxType: var itx LegacyTx inner = &itx - if dec.Recipient != nil { - itx.Recipient = dec.Recipient + if dec.To != nil { + itx.To = dec.To } - if dec.AccountNonce == nil { + if dec.Nonce == nil { return errors.New("missing required field 'nonce' in transaction") } - itx.AccountNonce = uint64(*dec.AccountNonce) - if dec.Price == nil { + itx.Nonce = uint64(*dec.Nonce) + if dec.GasPrice == nil { return errors.New("missing required field 'gasPrice' in transaction") } - itx.Price = (*big.Int)(dec.Price) - if dec.GasLimit == nil { + itx.GasPrice = (*big.Int)(dec.GasPrice) + if dec.Gas == nil { return errors.New("missing required field 'gas' in transaction") } - itx.GasLimit = uint64(*dec.GasLimit) - if dec.Amount == nil { + itx.Gas = uint64(*dec.Gas) + if dec.Value == nil { return errors.New("missing required field 'value' in transaction") } - itx.Amount = (*big.Int)(dec.Amount) - if dec.Payload == nil { + itx.Value = (*big.Int)(dec.Value) + if dec.Data == nil { return errors.New("missing required field 'input' in transaction") } - itx.Payload = *dec.Payload + itx.Data = *dec.Data if dec.V == nil { return errors.New("missing required field 'v' in transaction") } @@ -127,35 +127,35 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { inner = &itx // Access list is optional for now. if dec.AccessList != nil { - itx.Accesses = *dec.AccessList + itx.AccessList = *dec.AccessList } if dec.ChainID == nil { return errors.New("missing required field 'chainId' in transaction") } - itx.Chain = (*big.Int)(dec.ChainID) - if dec.Recipient != nil { - itx.Recipient = dec.Recipient + itx.ChainID = (*big.Int)(dec.ChainID) + if dec.To != nil { + itx.To = dec.To } - if dec.AccountNonce == nil { + if dec.Nonce == nil { return errors.New("missing required field 'nonce' in transaction") } - itx.AccountNonce = uint64(*dec.AccountNonce) - if dec.Price == nil { + itx.Nonce = uint64(*dec.Nonce) + if dec.GasPrice == nil { return errors.New("missing required field 'gasPrice' in transaction") } - itx.Price = (*big.Int)(dec.Price) - if dec.GasLimit == nil { + itx.GasPrice = (*big.Int)(dec.GasPrice) + if dec.Gas == nil { return errors.New("missing required field 'gas' in transaction") } - itx.GasLimit = uint64(*dec.GasLimit) - if dec.Amount == nil { + itx.Gas = uint64(*dec.Gas) + if dec.Value == nil { return errors.New("missing required field 'value' in transaction") } - itx.Amount = (*big.Int)(dec.Amount) - if dec.Payload == nil { + itx.Value = (*big.Int)(dec.Value) + if dec.Data == nil { return errors.New("missing required field 'input' in transaction") } - itx.Payload = *dec.Payload + itx.Data = *dec.Data if dec.V == nil { return errors.New("missing required field 'v' in transaction") } diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 69bf0d0025cd..7e67a3c84e55 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -56,13 +56,13 @@ var ( ) emptyEip2718Tx = NewTx(&AccessListTx{ - Chain: big.NewInt(1), - AccountNonce: 3, - Recipient: &testAddr, - Amount: big.NewInt(10), - GasLimit: 25000, - Price: big.NewInt(1), - Payload: common.FromHex("5544"), + ChainID: big.NewInt(1), + Nonce: 3, + To: &testAddr, + Value: big.NewInt(10), + Gas: 25000, + GasPrice: big.NewInt(1), + Data: common.FromHex("5544"), }) signedEip2718Tx, _ = emptyEip2718Tx.WithSignature( @@ -324,49 +324,49 @@ func TestTransactionCoding(t *testing.T) { case 0: // Legacy tx. txdata = &LegacyTx{ - AccountNonce: i, - Recipient: &recipient, - GasLimit: 1, - Price: big.NewInt(2), - Payload: []byte("abcdef"), + Nonce: i, + To: &recipient, + Gas: 1, + GasPrice: big.NewInt(2), + Data: []byte("abcdef"), } case 1: // Legacy tx contract creation. txdata = &LegacyTx{ - AccountNonce: i, - GasLimit: 1, - Price: big.NewInt(2), - Payload: []byte("abcdef"), + Nonce: i, + Gas: 1, + GasPrice: big.NewInt(2), + Data: []byte("abcdef"), } case 2: // Tx with non-zero access list. txdata = &AccessListTx{ - Chain: big.NewInt(1), - AccountNonce: i, - Recipient: &recipient, - GasLimit: 123457, - Price: big.NewInt(10), - Accesses: accesses, - Payload: []byte("abcdef"), + ChainID: big.NewInt(1), + Nonce: i, + To: &recipient, + Gas: 123457, + GasPrice: big.NewInt(10), + AccessList: accesses, + Data: []byte("abcdef"), } case 3: // Tx with empty access list. txdata = &AccessListTx{ - Chain: big.NewInt(1), - AccountNonce: i, - Recipient: &recipient, - GasLimit: 123457, - Price: big.NewInt(10), - Payload: []byte("abcdef"), + ChainID: big.NewInt(1), + Nonce: i, + To: &recipient, + Gas: 123457, + GasPrice: big.NewInt(10), + Data: []byte("abcdef"), } case 4: // Contract creation with access list. txdata = &AccessListTx{ - Chain: big.NewInt(1), - AccountNonce: i, - GasLimit: 123457, - Price: big.NewInt(10), - Accesses: accesses, + ChainID: big.NewInt(1), + Nonce: i, + Gas: 123457, + GasPrice: big.NewInt(10), + AccessList: accesses, } } tx, err := SignNewTx(key, signer, txdata) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 6ad626804477..9209d1488eae 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1580,23 +1580,23 @@ func (args *SendTxArgs) toTransaction() *types.Transaction { var data types.TxData if args.AccessList == nil { data = &types.LegacyTx{ - Recipient: args.To, - AccountNonce: uint64(*args.Nonce), - GasLimit: uint64(*args.Gas), - Price: (*big.Int)(args.GasPrice), - Amount: (*big.Int)(args.Value), - Payload: input, + To: args.To, + Nonce: uint64(*args.Nonce), + Gas: uint64(*args.Gas), + GasPrice: (*big.Int)(args.GasPrice), + Value: (*big.Int)(args.Value), + Data: input, } } else { data = &types.AccessListTx{ - Recipient: args.To, - Chain: (*big.Int)(args.ChainID), - AccountNonce: uint64(*args.Nonce), - GasLimit: uint64(*args.Gas), - Price: (*big.Int)(args.GasPrice), - Amount: (*big.Int)(args.Value), - Payload: input, - Accesses: *args.AccessList, + To: args.To, + ChainID: (*big.Int)(args.ChainID), + Nonce: uint64(*args.Nonce), + Gas: uint64(*args.Gas), + GasPrice: (*big.Int)(args.GasPrice), + Value: (*big.Int)(args.Value), + Data: input, + AccessList: *args.AccessList, } } return types.NewTx(data) diff --git a/miner/worker_test.go b/miner/worker_test.go index cc4ab2f28420..c0dabbfc601e 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -85,19 +85,19 @@ func init() { signer := types.NewEIP2718Signer(chainId) tx1 := types.MustSignNewTx(testBankKey, signer, &types.AccessListTx{ - Chain: chainId, - AccountNonce: 0, - Recipient: &testUserAddress, - Amount: big.NewInt(1000), - GasLimit: params.TxGas, + ChainID: chainId, + Nonce: 0, + To: &testUserAddress, + Value: big.NewInt(1000), + Gas: params.TxGas, }) pendingTxs = append(pendingTxs, tx1) tx2 := types.MustSignNewTx(testBankKey, signer, &types.LegacyTx{ - AccountNonce: 1, - Recipient: &testUserAddress, - Amount: big.NewInt(1000), - GasLimit: params.TxGas, + Nonce: 1, + To: &testUserAddress, + Value: big.NewInt(1000), + Gas: params.TxGas, }) newTxs = append(newTxs, tx2) From 20b14c6272e08738c85c620d7f4489c399e6493f Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 23 Feb 2021 17:17:03 +0100 Subject: [PATCH 76/83] core/types: add API to get the latest signer This updates everything to use EIP2718Signer instead of EIP155Signer. To make this simpler next time, I have added two new API functions for creating signers: - LatestSigner is for places which have chain config available - LatestSignerForChainID is for places where only the chain ID is available --- accounts/abi/bind/auth.go | 4 +-- accounts/abi/bind/backends/simulated.go | 8 ++++-- accounts/keystore/keystore.go | 15 ++++------- accounts/scwallet/wallet.go | 2 +- accounts/usbwallet/trezor.go | 2 ++ core/blockchain_test.go | 26 +++++++++---------- core/tx_pool.go | 2 +- core/types/block_test.go | 2 +- core/types/transaction_signing.go | 33 +++++++++++++++++++++++++ eth/gasprice/gasprice_test.go | 2 +- ethclient/ethclient_test.go | 2 +- graphql/graphql.go | 6 +---- internal/ethapi/api.go | 12 ++++----- les/benchmark.go | 2 +- light/txpool.go | 2 +- miner/worker_test.go | 3 +-- 16 files changed, 76 insertions(+), 47 deletions(-) diff --git a/accounts/abi/bind/auth.go b/accounts/abi/bind/auth.go index 1190772676c5..b8065e8488ed 100644 --- a/accounts/abi/bind/auth.go +++ b/accounts/abi/bind/auth.go @@ -120,7 +120,7 @@ func NewKeyStoreTransactorWithChainID(keystore *keystore.KeyStore, account accou if chainID == nil { return nil, ErrNoChainID } - signer := types.NewEIP155Signer(chainID) + signer := types.LatestSignerForChainID(chainID) return &TransactOpts{ From: account.Address, Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) { @@ -143,7 +143,7 @@ func NewKeyedTransactorWithChainID(key *ecdsa.PrivateKey, chainID *big.Int) (*Tr if chainID == nil { return nil, ErrNoChainID } - signer := types.NewEIP155Signer(chainID) + signer := types.LatestSignerForChainID(chainID) return &TransactOpts{ From: keyAddr, Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) { diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index a0ff5b93f4d6..d6d525eae10d 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -559,7 +559,10 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa b.mu.Lock() defer b.mu.Unlock() - sender, err := types.Sender(types.NewEIP155Signer(b.config.ChainID), tx) + // Check transaction validity. + block := b.blockchain.CurrentBlock() + signer := types.MakeSigner(b.blockchain.Config(), block.Number()) + sender, err := types.Sender(signer, tx) if err != nil { panic(fmt.Errorf("invalid transaction: %v", err)) } @@ -568,7 +571,8 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa panic(fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce)) } - blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) { + // Include tx in chain. + blocks, _ := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) { for _, tx := range b.pendingBlock.Transactions() { block.AddTxWithChain(b.blockchain, tx) } diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index 5ea059c3d68f..88dcfbeb69e0 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -284,10 +284,8 @@ func (ks *KeyStore) SignTx(a accounts.Account, tx *types.Transaction, chainID *b return nil, ErrLocked } // Depending on the presence of the chain ID, sign with 2718 or homestead - if chainID != nil { - return types.SignTx(tx, types.NewEIP2718Signer(chainID), unlockedKey.PrivateKey) - } - return types.SignTx(tx, types.HomesteadSigner{}, unlockedKey.PrivateKey) + signer := types.LatestSignerForChainID(chainID) + return types.SignTx(tx, signer, unlockedKey.PrivateKey) } // SignHashWithPassphrase signs hash if the private key matching the given address @@ -310,12 +308,9 @@ func (ks *KeyStore) SignTxWithPassphrase(a accounts.Account, passphrase string, return nil, err } defer zeroKey(key.PrivateKey) - - // Depending on the presence of the chain ID, sign with EIP155 or homestead - if chainID != nil { - return types.SignTx(tx, types.NewEIP155Signer(chainID), key.PrivateKey) - } - return types.SignTx(tx, types.HomesteadSigner{}, key.PrivateKey) + // Depending on the presence of the chain ID, sign with or without replay protection. + signer := types.LatestSignerForChainID(chainID) + return types.SignTx(tx, signer, key.PrivateKey) } // Unlock unlocks the given account indefinitely. diff --git a/accounts/scwallet/wallet.go b/accounts/scwallet/wallet.go index 6476646d7f07..b4d229bc0bf5 100644 --- a/accounts/scwallet/wallet.go +++ b/accounts/scwallet/wallet.go @@ -699,7 +699,7 @@ func (w *Wallet) signHash(account accounts.Account, hash []byte) ([]byte, error) // the needed details via SignTxWithPassphrase, or by other means (e.g. unlock // the account in a keystore). func (w *Wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) { - signer := types.NewEIP155Signer(chainID) + signer := types.LatestSignerForChainID(chainID) hash := signer.Hash(tx) sig, err := w.signHash(account, hash[:]) if err != nil { diff --git a/accounts/usbwallet/trezor.go b/accounts/usbwallet/trezor.go index 1892097baf65..0546458c47bd 100644 --- a/accounts/usbwallet/trezor.go +++ b/accounts/usbwallet/trezor.go @@ -255,9 +255,11 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction if chainID == nil { signer = new(types.HomesteadSigner) } else { + // Trezor backend does not support typed transactions yet. signer = types.NewEIP155Signer(chainID) signature[64] -= byte(chainID.Uint64()*2 + 35) } + // Inject the final signature into the transaction and sanity check the sender signed, err := tx.WithSignature(signer, signature) if err != nil { diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 100c2fc932c1..3e4757f8b63f 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -600,7 +600,7 @@ func TestFastVsFullChains(t *testing.T) { Alloc: GenesisAlloc{address: {Balance: funds}}, } genesis = gspec.MustCommit(gendb) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, 1024, func(i int, block *BlockGen) { block.SetCoinbase(common.Address{0x00}) @@ -839,7 +839,7 @@ func TestChainTxReorgs(t *testing.T) { }, } genesis = gspec.MustCommit(db) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) // Create two transactions shared between the chains: @@ -944,7 +944,7 @@ func TestLogReorgs(t *testing.T) { code = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00") gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}} genesis = gspec.MustCommit(db) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) @@ -998,7 +998,7 @@ func TestLogRebirth(t *testing.T) { db = rawdb.NewMemoryDatabase() gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}} genesis = gspec.MustCommit(db) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) engine = ethash.NewFaker() blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil) ) @@ -1062,7 +1062,7 @@ func TestSideLogRebirth(t *testing.T) { db = rawdb.NewMemoryDatabase() gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}} genesis = gspec.MustCommit(db) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) ) @@ -1135,7 +1135,7 @@ func TestReorgSideEvent(t *testing.T) { Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}, } genesis = gspec.MustCommit(db) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) @@ -1295,7 +1295,7 @@ func TestEIP155Transition(t *testing.T) { } block.AddTx(tx) - tx, err = basicTx(types.NewEIP155Signer(gspec.Config.ChainID)) + tx, err = basicTx(types.LatestSigner(gspec.Config)) if err != nil { t.Fatal(err) } @@ -1307,7 +1307,7 @@ func TestEIP155Transition(t *testing.T) { } block.AddTx(tx) - tx, err = basicTx(types.NewEIP155Signer(gspec.Config.ChainID)) + tx, err = basicTx(types.LatestSigner(gspec.Config)) if err != nil { t.Fatal(err) } @@ -1345,7 +1345,7 @@ func TestEIP155Transition(t *testing.T) { } ) if i == 0 { - tx, err = basicTx(types.NewEIP155Signer(big.NewInt(2))) + tx, err = basicTx(types.LatestSigner(config)) if err != nil { t.Fatal(err) } @@ -1385,7 +1385,7 @@ func TestEIP161AccountRemoval(t *testing.T) { var ( tx *types.Transaction err error - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) switch i { case 0: @@ -2078,7 +2078,7 @@ func TestTransactionIndices(t *testing.T) { funds = big.NewInt(1000000000) gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{address: {Balance: funds}}} genesis = gspec.MustCommit(gendb) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) height := uint64(128) blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, int(height), func(i int, block *BlockGen) { @@ -2205,7 +2205,7 @@ func TestSkipStaleTxIndicesInFastSync(t *testing.T) { funds = big.NewInt(1000000000) gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{address: {Balance: funds}}} genesis = gspec.MustCommit(gendb) - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) height := uint64(128) blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, int(height), func(i int, block *BlockGen) { @@ -3072,7 +3072,7 @@ func TestEIP2718Transition(t *testing.T) { b.SetCoinbase(common.Address{1}) // One transaction to 0xAAAA - signer := types.NewEIP2718Signer(gspec.Config.ChainID) + signer := types.LatestSigner(gspec.Config) tx, _ := types.SignNewTx(key, signer, &types.AccessListTx{ ChainID: gspec.Config.ChainID, Nonce: 0, diff --git a/core/tx_pool.go b/core/tx_pool.go index 98d6f90cef73..52e698f9ed10 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -269,7 +269,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block config: config, chainconfig: chainconfig, chain: chain, - signer: types.NewEIP2718Signer(chainconfig.ChainID), + signer: types.LatestSigner(chainconfig), pending: make(map[common.Address]*txList), queue: make(map[common.Address]*txList), beats: make(map[common.Address]time.Time), diff --git a/core/types/block_test.go b/core/types/block_test.go index 1ab22be7745b..a2b31b14a697 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -181,7 +181,7 @@ func makeBenchBlock() *Block { key, _ = crypto.GenerateKey() txs = make([]*Transaction, 70) receipts = make([]*Receipt, len(txs)) - signer = NewEIP155Signer(params.TestChainConfig.ChainID) + signer = LatestSigner(params.TestChainConfig) uncles = make([]*Header, 3) ) header := &Header{ diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 4154ff4cc117..e4fafd6cff41 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -54,6 +54,39 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { return signer } +// LatestSigner returns the 'most permissive' Signer available for the given chain +// configuration. Specifically, this enables support of EIP-155 replay protection and +// EIP-2930 access list transactions depending on whether their respective forks are +// scheduled to occur at any block number in the config. +// +// Use this in transaction-handling code where the current block number is unknown. If you +// have the current block number available, use MakeSigner instead. +func LatestSigner(config *params.ChainConfig) Signer { + if config.ChainID != nil { + if config.YoloV3Block != nil { + return NewEIP2718Signer(config.ChainID) + } + if config.EIP155Block != nil { + return NewEIP155Signer(config.ChainID) + } + } + return HomesteadSigner{} +} + +// LatestSignerForChainID returns the 'most permissive' Signer available. Specifically, +// this enables support for EIP-155 replay protection and all implemented EIP-2718 +// transaction types if chainID is non-nil. +// +// Use this in transaction-handling code where the current block number and fork +// configuration are unknown. If you have a ChainConfig, use LatestSigner instead. +// If you have a ChainConfig and know the current block number, use MakeSigner instead. +func LatestSignerForChainID(chainID *big.Int) Signer { + if chainID == nil { + return HomesteadSigner{} + } + return NewEIP2718Signer(chainID) +} + // SignTx signs the transaction using the given signer and private key. func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error) { h := s.Hash(tx) diff --git a/eth/gasprice/gasprice_test.go b/eth/gasprice/gasprice_test.go index 89caeeb45bf4..4fd2df10e2bd 100644 --- a/eth/gasprice/gasprice_test.go +++ b/eth/gasprice/gasprice_test.go @@ -63,7 +63,7 @@ func newTestBackend(t *testing.T) *testBackend { Config: params.TestChainConfig, Alloc: core.GenesisAlloc{addr: {Balance: big.NewInt(math.MaxInt64)}}, } - signer = types.NewEIP155Signer(gspec.Config.ChainID) + signer = types.LatestSigner(gspec.Config) ) engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() diff --git a/ethclient/ethclient_test.go b/ethclient/ethclient_test.go index 8b175ee066b9..9a5a45e34fa2 100644 --- a/ethclient/ethclient_test.go +++ b/ethclient/ethclient_test.go @@ -560,7 +560,7 @@ func sendTransaction(ec *Client) error { } // Create transaction tx := types.NewTransaction(0, common.Address{1}, big.NewInt(1), 22000, big.NewInt(1), nil) - signer := types.NewEIP155Signer(chainID) + signer := types.LatestSignerForChainID(chainID) signature, err := crypto.Sign(signer.Hash(tx).Bytes(), testKey) if err != nil { return err diff --git a/graphql/graphql.go b/graphql/graphql.go index 70205fcd8147..2374beb8e112 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -245,12 +245,8 @@ func (t *Transaction) From(ctx context.Context, args BlockNumberArgs) (*Account, if err != nil || tx == nil { return nil, err } - var signer types.Signer = types.HomesteadSigner{} - if tx.Protected() { - signer = types.NewEIP155Signer(tx.ChainId()) - } + signer := types.LatestSigner(t.backend.ChainConfig()) from, _ := types.Sender(signer, tx) - return &Account{ backend: t.backend, address: from, diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9209d1488eae..622063cf6497 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1225,13 +1225,13 @@ type RPCTransaction struct { // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { - // Determine the signer. For replay-protected transactions, use the 'newest' signer, - // because we assume that signers are backwards-compatible with old transactions. For - // non-protected transactions, the homestead signer signer is used because the return - // value of ChainId is zero for those transactions. + // Determine the signer. For replay-protected transactions, use the most permissive + // signer, because we assume that signers are backwards-compatible with old + // transactions. For non-protected transactions, the homestead signer signer is used + // because the return value of ChainId is zero for those transactions. var signer types.Signer if tx.Protected() { - signer = types.NewEIP2718Signer(tx.ChainId()) + signer = types.LatestSignerForChainID(tx.ChainId()) } else { signer = types.HomesteadSigner{} } @@ -1310,7 +1310,7 @@ type PublicTransactionPoolAPI struct { func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI { // The signer used by the API should always be the 'latest' known one because we expect // signers to be backwards-compatible with old transactions. - signer := types.NewEIP2718Signer(b.ChainConfig().ChainID) + signer := types.LatestSigner(b.ChainConfig()) return &PublicTransactionPoolAPI{b, nonceLock, signer} } diff --git a/les/benchmark.go b/les/benchmark.go index 6255c1049e8d..757822a6b31a 100644 --- a/les/benchmark.go +++ b/les/benchmark.go @@ -171,7 +171,7 @@ type benchmarkTxSend struct { func (b *benchmarkTxSend) init(h *serverHandler, count int) error { key, _ := crypto.GenerateKey() addr := crypto.PubkeyToAddress(key.PublicKey) - signer := types.NewEIP155Signer(big.NewInt(18)) + signer := types.LatestSigner(h.server.chainConfig) b.txs = make(types.Transactions, count) for i := range b.txs { diff --git a/light/txpool.go b/light/txpool.go index 0c904000e6aa..bf5f9ff5833e 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -90,7 +90,7 @@ type TxRelayBackend interface { func NewTxPool(config *params.ChainConfig, chain *LightChain, relay TxRelayBackend) *TxPool { pool := &TxPool{ config: config, - signer: types.NewEIP155Signer(config.ChainID), + signer: types.LatestSigner(config), nonce: make(map[common.Address]uint64), pending: make(map[common.Hash]*types.Transaction), mined: make(map[common.Hash][]*types.Transaction), diff --git a/miner/worker_test.go b/miner/worker_test.go index c0dabbfc601e..96e83ab640c8 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -77,13 +77,12 @@ func init() { testTxPoolConfig.Journal = "" ethashChainConfig = params.TestChainConfig cliqueChainConfig = params.TestChainConfig - chainId := params.TestChainConfig.ChainID cliqueChainConfig.Clique = ¶ms.CliqueConfig{ Period: 10, Epoch: 30000, } - signer := types.NewEIP2718Signer(chainId) + signer := types.LatestSigner(params.TestChainConfig) tx1 := types.MustSignNewTx(testBankKey, signer, &types.AccessListTx{ ChainID: chainId, Nonce: 0, From 406af1ba839e44781e5a5f3f8f557ac3ec46deff Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 23 Feb 2021 18:33:02 +0100 Subject: [PATCH 77/83] core/types: rename and unexport EIP2718Signer The signer doesn't accept all EIP-2718 transactions, only EIP-2930 access list transactions. This is why it is now called eip2930Signer. Also unexport this new signer type because it is not supposed to be used directly. I'd love to unexport EIP155Signer as well, but can't do that because it's been around for so long, --- core/types/block_test.go | 2 +- core/types/transaction_signing.go | 30 ++++++++++++++++-------------- core/types/transaction_test.go | 8 ++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/core/types/block_test.go b/core/types/block_test.go index a2b31b14a697..63904f882c92 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -113,7 +113,7 @@ func TestEIP2718BlockEncoding(t *testing.T) { AccessList: AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}, }) sig2 := common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401") - tx2, _ = tx2.WithSignature(NewEIP2718Signer(big.NewInt(1)), sig2) + tx2, _ = tx2.WithSignature(NewEIP2930Signer(big.NewInt(1)), sig2) check("len(Transactions)", len(block.Transactions()), 2) check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash()) diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index e4fafd6cff41..45eb5181820c 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -43,7 +43,7 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { var signer Signer switch { case config.IsYoloV3(blockNumber): - signer = NewEIP2718Signer(config.ChainID) + signer = NewEIP2930Signer(config.ChainID) case config.IsEIP155(blockNumber): signer = NewEIP155Signer(config.ChainID) case config.IsHomestead(blockNumber): @@ -64,7 +64,7 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { func LatestSigner(config *params.ChainConfig) Signer { if config.ChainID != nil { if config.YoloV3Block != nil { - return NewEIP2718Signer(config.ChainID) + return NewEIP2930Signer(config.ChainID) } if config.EIP155Block != nil { return NewEIP155Signer(config.ChainID) @@ -84,7 +84,7 @@ func LatestSignerForChainID(chainID *big.Int) Signer { if chainID == nil { return HomesteadSigner{} } - return NewEIP2718Signer(chainID) + return NewEIP2930Signer(chainID) } // SignTx signs the transaction using the given signer and private key. @@ -158,19 +158,20 @@ type Signer interface { Equal(Signer) bool } -// EIP2718Signer implements Signer using the EIP2718 rules. -type EIP2718Signer struct{ EIP155Signer } +type eip2930Signer struct{ EIP155Signer } -func NewEIP2718Signer(chainId *big.Int) EIP2718Signer { - return EIP2718Signer{NewEIP155Signer(chainId)} +// NewEIP2930Signer returns a signer that accepts EIP-2930 access list transactions, +// EIP-155 replay protected transactions, and legacy Homestead transactions. +func NewEIP2930Signer(chainId *big.Int) Signer { + return eip2930Signer{NewEIP155Signer(chainId)} } -func (s EIP2718Signer) Equal(s2 Signer) bool { - eip2718, ok := s2.(EIP2718Signer) - return ok && eip2718.chainId.Cmp(s.chainId) == 0 +func (s eip2930Signer) Equal(s2 Signer) bool { + x, ok := s2.(eip2930Signer) + return ok && x.chainId.Cmp(s.chainId) == 0 } -func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { +func (s eip2930Signer) Sender(tx *Transaction) (common.Address, error) { V, R, S := tx.RawSignatureValues() switch tx.Type() { case LegacyTxType: @@ -192,7 +193,7 @@ func (s EIP2718Signer) Sender(tx *Transaction) (common.Address, error) { return recoverPlain(s.Hash(tx), R, S, V, true) } -func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) { +func (s eip2930Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) { switch tx.Type() { case LegacyTxType: R, S, V = decodeSignature(sig) @@ -211,7 +212,7 @@ func (s EIP2718Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *bi // Hash returns the hash to be signed by the sender. // It does not uniquely identify the transaction. -func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { +func (s eip2930Signer) Hash(tx *Transaction) common.Hash { switch tx.Type() { case LegacyTxType: return rlpHash([]interface{}{ @@ -245,7 +246,8 @@ func (s EIP2718Signer) Hash(tx *Transaction) common.Hash { } } -// EIP155Signer implements Signer using the EIP155 rules. +// EIP155Signer implements Signer using the EIP-155 rules. This accepts transactions which +// are replay-protected as well as unprotected homestead transactions. type EIP155Signer struct { chainId, chainIdMul *big.Int } diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 7e67a3c84e55..2f9e1931903d 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -66,7 +66,7 @@ var ( }) signedEip2718Tx, _ = emptyEip2718Tx.WithSignature( - NewEIP2718Signer(big.NewInt(1)), + NewEIP2930Signer(big.NewInt(1)), common.Hex2Bytes("c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b266032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d3752101"), ) ) @@ -102,7 +102,7 @@ func TestTransactionEncode(t *testing.T) { } func TestEIP2718TransactionSigHash(t *testing.T) { - s := NewEIP2718Signer(big.NewInt(1)) + s := NewEIP2930Signer(big.NewInt(1)) if s.Hash(emptyEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") { t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", s.Hash(emptyEip2718Tx)) } @@ -113,7 +113,7 @@ func TestEIP2718TransactionSigHash(t *testing.T) { func TestEIP2718SigHashes(t *testing.T) { // the signer chainid doesn't matter for the sighash - signer := NewEIP2718Signer(big.NewInt(0)) + signer := NewEIP2930Signer(big.NewInt(0)) for i, tc := range []struct { rlpData string sigHash common.Hash @@ -313,7 +313,7 @@ func TestTransactionCoding(t *testing.T) { t.Fatalf("could not generate key: %v", err) } var ( - signer = NewEIP2718Signer(common.Big1) + signer = NewEIP2930Signer(common.Big1) addr = common.HexToAddress("0x0000000000000000000000000000000000000001") recipient = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87") accesses = AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}} From ee66c67ef5c70660444be4a47b43d860d8dcb6fe Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 23 Feb 2021 18:36:42 +0100 Subject: [PATCH 78/83] miner: fix test --- miner/worker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/worker_test.go b/miner/worker_test.go index 96e83ab640c8..0fe62316e1f1 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -84,7 +84,7 @@ func init() { signer := types.LatestSigner(params.TestChainConfig) tx1 := types.MustSignNewTx(testBankKey, signer, &types.AccessListTx{ - ChainID: chainId, + ChainID: params.TestChainConfig.ChainID, Nonce: 0, To: &testUserAddress, Value: big.NewInt(1000), From 559cb21e77e8ed925157a79769da43b2dd422c85 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 24 Feb 2021 13:39:44 +0100 Subject: [PATCH 79/83] core/types: make the receipt-type 0x-prefixed string in json --- core/types/gen_receipt_json.go | 8 ++++---- core/types/receipt.go | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index 9a4b836ff37f..bb892f85bec8 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -16,7 +16,7 @@ var _ = (*receiptMarshaling)(nil) // MarshalJSON marshals as JSON. func (r Receipt) MarshalJSON() ([]byte, error) { type Receipt struct { - Type uint8 `json:"type,omitempty"` + Type hexutil.Uint64 `json:"type,omitempty"` PostState hexutil.Bytes `json:"root"` Status hexutil.Uint64 `json:"status"` CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` @@ -30,7 +30,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) { TransactionIndex hexutil.Uint `json:"transactionIndex"` } var enc Receipt - enc.Type = r.Type + enc.Type = hexutil.Uint64(r.Type) enc.PostState = r.PostState enc.Status = hexutil.Uint64(r.Status) enc.CumulativeGasUsed = hexutil.Uint64(r.CumulativeGasUsed) @@ -48,7 +48,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals from JSON. func (r *Receipt) UnmarshalJSON(input []byte) error { type Receipt struct { - Type *uint8 `json:"type,omitempty"` + Type *hexutil.Uint64 `json:"type,omitempty"` PostState *hexutil.Bytes `json:"root"` Status *hexutil.Uint64 `json:"status"` CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` @@ -66,7 +66,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { return err } if dec.Type != nil { - r.Type = *dec.Type + r.Type = uint8(*dec.Type) } if dec.PostState != nil { r.PostState = *dec.PostState diff --git a/core/types/receipt.go b/core/types/receipt.go index 2aa6196604bc..48f4aef06ae9 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -72,6 +72,7 @@ type Receipt struct { } type receiptMarshaling struct { + Type hexutil.Uint64 PostState hexutil.Bytes Status hexutil.Uint64 CumulativeGasUsed hexutil.Uint64 From dd2483c0d902f503bd868279bb1f729608ad3ac1 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 24 Feb 2021 15:50:48 +0100 Subject: [PATCH 80/83] core/types: fix chain ID handling in eip2930Signer --- core/types/access_list_tx.go | 4 +- core/types/legacy_tx.go | 2 +- core/types/transaction.go | 4 +- core/types/transaction_signing.go | 52 +++++++++++++----- core/types/transaction_test.go | 88 ++++++++++++++++++++++++------- 5 files changed, 115 insertions(+), 35 deletions(-) diff --git a/core/types/access_list_tx.go b/core/types/access_list_tx.go index d6556ca4aea5..65ee95adf611 100644 --- a/core/types/access_list_tx.go +++ b/core/types/access_list_tx.go @@ -110,6 +110,6 @@ func (tx *AccessListTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } -func (tx *AccessListTx) setSignatureValues(v, r, s *big.Int) { - tx.V, tx.R, tx.S = v, r, s +func (tx *AccessListTx) setSignatureValues(chainID, v, r, s *big.Int) { + tx.ChainID, tx.V, tx.R, tx.S = chainID, v, r, s } diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 46f1a0e2ee15..41ad44f37985 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -106,6 +106,6 @@ func (tx *LegacyTx) rawSignatureValues() (v, r, s *big.Int) { return tx.V, tx.R, tx.S } -func (tx *LegacyTx) setSignatureValues(v, r, s *big.Int) { +func (tx *LegacyTx) setSignatureValues(chainID, v, r, s *big.Int) { tx.V, tx.R, tx.S = v, r, s } diff --git a/core/types/transaction.go b/core/types/transaction.go index 32b9a7dd3226..14759b579d58 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -79,7 +79,7 @@ type TxData interface { to() *common.Address rawSignatureValues() (v, r, s *big.Int) - setSignatureValues(v, r, s *big.Int) + setSignatureValues(chainID, v, r, s *big.Int) } // EncodeRLP implements rlp.Encoder @@ -337,7 +337,7 @@ func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, e return nil, err } cpy := tx.inner.copy() - cpy.setSignatureValues(v, r, s) + cpy.setSignatureValues(signer.ChainID(), v, r, s) return &Transaction{inner: cpy, time: tx.time}, nil } diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 45eb5181820c..1645369b4fbe 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -27,9 +27,7 @@ import ( "github.com/ethereum/go-ethereum/params" ) -var ( - ErrInvalidChainId = errors.New("invalid chain id for signer") -) +var ErrInvalidChainId = errors.New("invalid chain id for signer") // sigCache is used to cache the derived sender and contains // the signer used to derive it. @@ -56,8 +54,8 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { // LatestSigner returns the 'most permissive' Signer available for the given chain // configuration. Specifically, this enables support of EIP-155 replay protection and -// EIP-2930 access list transactions depending on whether their respective forks are -// scheduled to occur at any block number in the config. +// EIP-2930 access list transactions when their respective forks are scheduled to occur at +// any block number in the chain config. // // Use this in transaction-handling code where the current block number is unknown. If you // have the current block number available, use MakeSigner instead. @@ -144,16 +142,25 @@ func Sender(signer Signer, tx *Transaction) (common.Address, error) { return addr, nil } -// Signer encapsulates transaction signature handling. Note that this interface is not a -// stable API and may change at any time to accommodate new protocol rules. +// Signer encapsulates transaction signature handling. The name of this type is slightly +// misleading because Signers don't actually sign, they're just for validating and +// processing of signatures. +// +// Note that this interface is not a stable API and may change at any time to accommodate +// new protocol rules. type Signer interface { // Sender returns the sender address of the transaction. Sender(tx *Transaction) (common.Address, error) + // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) - // Hash returns the hash to be signed. + ChainID() *big.Int + + // Hash returns 'signature hash', i.e. the transaction hash that is signed by the + // private key. This hash does not uniquely identify the transaction. Hash(tx *Transaction) common.Hash + // Equal returns true if the given signer is the same as the receiver. Equal(Signer) bool } @@ -166,6 +173,10 @@ func NewEIP2930Signer(chainId *big.Int) Signer { return eip2930Signer{NewEIP155Signer(chainId)} } +func (s eip2930Signer) ChainID() *big.Int { + return s.chainId +} + func (s eip2930Signer) Equal(s2 Signer) bool { x, ok := s2.(eip2930Signer) return ok && x.chainId.Cmp(s.chainId) == 0 @@ -194,14 +205,19 @@ func (s eip2930Signer) Sender(tx *Transaction) (common.Address, error) { } func (s eip2930Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) { - switch tx.Type() { - case LegacyTxType: + switch txdata := tx.inner.(type) { + case *LegacyTx: R, S, V = decodeSignature(sig) if s.chainId.Sign() != 0 { V = big.NewInt(int64(sig[64] + 35)) V.Add(V, s.chainIdMul) } - case AccessListTxType: + case *AccessListTx: + // Check that chain ID of tx matches the signer. We also accept ID zero here, + // because it indicates that the chain ID was not specified in the tx. + if txdata.ChainID.Sign() != 0 && txdata.ChainID.Cmp(s.chainId) != 0 { + return nil, nil, nil, ErrInvalidChainId + } R, S, _ = decodeSignature(sig) V = big.NewInt(int64(sig[64])) default: @@ -228,7 +244,7 @@ func (s eip2930Signer) Hash(tx *Transaction) common.Hash { return prefixedRlpHash( tx.Type(), []interface{}{ - tx.ChainId(), + s.chainId, tx.Nonce(), tx.GasPrice(), tx.Gas(), @@ -262,6 +278,10 @@ func NewEIP155Signer(chainId *big.Int) EIP155Signer { } } +func (s EIP155Signer) ChainID() *big.Int { + return s.chainId +} + func (s EIP155Signer) Equal(s2 Signer) bool { eip155, ok := s2.(EIP155Signer) return ok && eip155.chainId.Cmp(s.chainId) == 0 @@ -317,6 +337,10 @@ func (s EIP155Signer) Hash(tx *Transaction) common.Hash { // homestead rules. type HomesteadSigner struct{ FrontierSigner } +func (s HomesteadSigner) ChainID() *big.Int { + return nil +} + func (s HomesteadSigner) Equal(s2 Signer) bool { _, ok := s2.(HomesteadSigner) return ok @@ -338,6 +362,10 @@ func (hs HomesteadSigner) Sender(tx *Transaction) (common.Address, error) { type FrontierSigner struct{} +func (s FrontierSigner) ChainID() *big.Int { + return nil +} + func (s FrontierSigner) Equal(s2 Signer) bool { _, ok := s2.(FrontierSigner) return ok diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 2f9e1931903d..3cece9c2358d 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -111,26 +111,79 @@ func TestEIP2718TransactionSigHash(t *testing.T) { } } -func TestEIP2718SigHashes(t *testing.T) { - // the signer chainid doesn't matter for the sighash - signer := NewEIP2930Signer(big.NewInt(0)) - for i, tc := range []struct { - rlpData string - sigHash common.Hash - fullHash common.Hash +// This test checks signature operations on access list transactions. +func TestEIP2930Signer(t *testing.T) { + + var ( + key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + keyAddr = crypto.PubkeyToAddress(key.PublicKey) + signer1 = NewEIP2930Signer(big.NewInt(1)) + signer2 = NewEIP2930Signer(big.NewInt(2)) + tx0 = NewTx(&AccessListTx{Nonce: 1}) + tx1 = NewTx(&AccessListTx{ChainID: big.NewInt(1), Nonce: 1}) + tx2, _ = SignNewTx(key, signer2, &AccessListTx{ChainID: big.NewInt(2), Nonce: 1}) + ) + + tests := []struct { + tx *Transaction + signer Signer + wantSignerHash common.Hash + wantSenderErr error + wantSignErr error + wantHash common.Hash // after signing }{ { - rlpData: "0xb8a701f8a486796f6c6f763380843b9aca008262d4948a8eafb1cf62bfbeb1741769dae1a9dd479961928080f838f7940000000000000000000000000000000000001337e1a0000000000000000000000000000000000000000000000000000000000000000080a0775101f92dcca278a56bfe4d613428624a1ebfc3cd9e0bcc1de80c41455b9021a06c9deac205afe7b124907d4ba54a9f46161498bd3990b90d175aac12c9a40ee9", - sigHash: common.HexToHash("0xf8eb2089f9add782b02e4c0ce41540817688bf579c14736576cb1d6d562c2f6b"), - fullHash: common.HexToHash("0x212a85be428a85d00fb5335b013bc8d3cf7511ffdd8938de768f4ca8bf1caf50"), + tx: tx0, + signer: signer1, + wantSignerHash: common.HexToHash("846ad7672f2a3a40c1f959cd4a8ad21786d620077084d84c8d7c077714caa139"), + wantSenderErr: ErrInvalidChainId, + wantHash: common.HexToHash("1ccd12d8bbdb96ea391af49a35ab641e219b2dd638dea375f2bc94dd290f2549"), + }, + { + tx: tx1, + signer: signer1, + wantSenderErr: ErrInvalidSig, + wantSignerHash: common.HexToHash("846ad7672f2a3a40c1f959cd4a8ad21786d620077084d84c8d7c077714caa139"), + wantHash: common.HexToHash("1ccd12d8bbdb96ea391af49a35ab641e219b2dd638dea375f2bc94dd290f2549"), + }, + { + // This checks what happens when trying to sign an unsigned tx for the wrong chain. + tx: tx1, + signer: signer2, + wantSenderErr: ErrInvalidChainId, + wantSignerHash: common.HexToHash("367967247499343401261d718ed5aa4c9486583e4d89251afce47f4a33c33362"), + wantSignErr: ErrInvalidChainId, + }, + { + // This checks what happens when trying to re-sign a signed tx for the wrong chain. + tx: tx2, + signer: signer1, + wantSenderErr: ErrInvalidChainId, + wantSignerHash: common.HexToHash("846ad7672f2a3a40c1f959cd4a8ad21786d620077084d84c8d7c077714caa139"), + wantSignErr: ErrInvalidChainId, }, - } { - var tx Transaction - rlp.DecodeBytes(common.FromHex(tc.rlpData), &tx) - hash := tx.Hash() - sigHash := signer.Hash(&tx) - if sigHash != tc.sigHash || hash != tc.fullHash { - t.Fatalf("test %d: got\nsighash %x want %x\nhash: %x want %x\n", i, sigHash, tc.sigHash, hash, tc.fullHash) + } + + for i, test := range tests { + sigHash := test.signer.Hash(test.tx) + if sigHash != test.wantSignerHash { + t.Errorf("test %d: wrong sig hash: got %x, want %x", i, sigHash, test.wantSignerHash) + } + sender, err := Sender(test.signer, test.tx) + if err != test.wantSenderErr { + t.Errorf("test %d: wrong Sender error %q", i, err) + } + if err == nil && sender != keyAddr { + t.Errorf("test %d: wrong sender address %x", i, sender) + } + signedTx, err := SignTx(test.tx, test.signer, key) + if err != test.wantSignErr { + t.Fatalf("test %d: wrong SignTx error %q", i, err) + } + if signedTx != nil { + if signedTx.Hash() != test.wantHash { + t.Errorf("test %d: wrong tx hash after signing: got %x, want %x", i, signedTx.Hash(), test.wantHash) + } } } } @@ -163,7 +216,6 @@ func TestEIP2718TransactionEncode(t *testing.T) { func decodeTx(data []byte) (*Transaction, error) { var tx Transaction t, err := &tx, rlp.Decode(bytes.NewReader(data), &tx) - return t, err } From dfba23bad2450189fa31398b93e465f5fdf81efa Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 24 Feb 2021 20:10:32 +0100 Subject: [PATCH 81/83] ethclient: fix signer --- ethclient/signer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ethclient/signer.go b/ethclient/signer.go index 74a93f1e2fd6..9de020b352a3 100644 --- a/ethclient/signer.go +++ b/ethclient/signer.go @@ -51,6 +51,9 @@ func (s *senderFromServer) Sender(tx *types.Transaction) (common.Address, error) return s.addr, nil } +func (s *senderFromServer) ChainID() *big.Int { + panic("can't sign with senderFromServer") +} func (s *senderFromServer) Hash(tx *types.Transaction) common.Hash { panic("can't sign with senderFromServer") } From 8f1528ec959a62c04bb3219be45f463468bd3c75 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 25 Feb 2021 10:12:05 +0100 Subject: [PATCH 82/83] core/types: fix check in tx decoder The EIP says: TransactionType is a positive unsigned 8-bit number between 0 and 0x7f that represents the type of the transaction. --- core/types/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 14759b579d58..49127630ae45 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -148,7 +148,7 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error { // UnmarshalBinary decodes the canonical encoding of transactions. // It supports legacy RLP transactions and EIP2718 typed transactions. func (tx *Transaction) UnmarshalBinary(b []byte) error { - if len(b) > 0 && b[0] >= 0x7f { + if len(b) > 0 && b[0] > 0x7f { // It's a legacy transaction. var data LegacyTx err := rlp.DecodeBytes(b, &data) From 9750e9b2469978e4b9a7546ff09ce052015ace8c Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 25 Feb 2021 13:21:03 +0100 Subject: [PATCH 83/83] core: move tx type check earlier --- core/tx_pool.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 52e698f9ed10..28ac822131f4 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -229,7 +229,7 @@ type TxPool struct { mu sync.RWMutex istanbul bool // Fork indicator whether we are in the istanbul stage. - eip2718 bool // Fork indicator whether we are using EIp-2718 type transactions. + eip2718 bool // Fork indicator whether we are using EIP-2718 type transactions. currentState *state.StateDB // Current state in the blockchain head pendingNonces *txNoncer // Pending state tracking virtual nonces @@ -523,6 +523,10 @@ func (pool *TxPool) local() map[common.Address]types.Transactions { // validateTx checks whether a transaction is valid according to the consensus // rules and adheres to some heuristic limits of the local node (price and size). func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { + // Accept only legacy transactions until EIP-2718/2930 activates. + if !pool.eip2718 && tx.Type() != types.LegacyTxType { + return ErrTxTypeNotSupported + } // Reject transactions over defined size to prevent DOS attacks if uint64(tx.Size()) > txMaxSize { return ErrOversizedData @@ -536,10 +540,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if pool.currentMaxGas < tx.Gas() { return ErrGasLimit } - // Accept only legacy transactions if before 2718/2930. - if !pool.eip2718 && tx.Type() != types.LegacyTxType { - return ErrTxTypeNotSupported - } // Make sure the transaction is signed properly. from, err := types.Sender(pool.signer, tx) if err != nil {