adjustments to get building and tests passing after rebase onto 1.9.15

This commit is contained in:
Ian Norden 2020-07-03 15:27:26 -05:00
parent 890ffecd86
commit 28dcf09397
23 changed files with 220 additions and 191 deletions

View File

@ -107,7 +107,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
// Create a transaction to an account.
code := "6060604052600a8060106000396000f360606040526008565b00"
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, big.NewInt(1), common.FromHex(code))
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, big.NewInt(1), common.FromHex(code), nil, nil)
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@ -119,7 +119,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
}
// Create a transaction that is not mined.
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, big.NewInt(1), common.FromHex(code))
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, big.NewInt(1), common.FromHex(code), nil, nil)
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
go func() {

View File

@ -696,7 +696,7 @@ func (api *RetestethAPI) AccountRange(ctx context.Context,
if vmenv.ChainConfig().IsEIP1559(block.Number()) {
gp1559 = new(core.GasPool).AddGas(tx.Gas())
}
if _, _, _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), gp1559); err != nil {
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), gp1559); err != nil {
return AccountRangeResult{}, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err)
}
// Ensure any modifications are committed to the state
@ -810,7 +810,7 @@ func (api *RetestethAPI) StorageRangeAt(ctx context.Context,
if vmenv.ChainConfig().IsEIP1559(block.Number()) {
gp1559 = new(core.GasPool).AddGas(tx.Gas())
}
if _, _, _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), gp1559); err != nil {
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), gp1559); err != nil {
return StorageRangeResult{}, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err)
}
// Ensure any modifications are committed to the state

View File

@ -1666,6 +1666,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
setDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
}
}
// If we are configuring custom EIP1559 params, do so now
if ctx.GlobalBool(EIP1559CLIConfigure.Name) {
if cfg.Genesis == nil {
cfg.Genesis = core.DefaultGenesisBlock()
}
setEIP1559Params(ctx, cfg)
}
}
// setDNSDiscoveryDefaults configures DNS discovery with the given URL if
@ -1682,14 +1690,6 @@ func setDNSDiscoveryDefaults(cfg *eth.Config, genesis common.Hash) {
if url := params.KnownDNSNetwork(genesis, protocol); url != "" {
cfg.DiscoveryURLs = []string{url}
}
// If we are configuring custom EIP1559 params, do so now
if ctx.GlobalBool(EIP1559CLIConfigure.Name) {
if cfg.Genesis == nil {
cfg.Genesis = core.DefaultGenesisBlock()
}
setEIP1559Params(ctx, cfg)
}
}
func setEIP1559Params(ctx *cli.Context, config *eth.Config) {

View File

@ -127,7 +127,7 @@ func TestHeaderVerificationEIP1559(t *testing.T) {
headers[i] = block.Header()
}
// Run the header checker for blocks one-by-one, checking for both valid and invalid nonces
chain, _ := NewBlockChain(testdb, nil, params.EIP1559ChainConfig, ethash.NewFaker(), vm.Config{}, nil)
chain, _ := NewBlockChain(testdb, nil, params.EIP1559ChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
defer chain.Stop()
for i := 0; i < len(blocks); i++ {
@ -211,7 +211,7 @@ func TestHeaderVerificationEIP1559Finalized(t *testing.T) {
headers[i] = block.Header()
}
// Run the header checker for blocks one-by-one, checking for both valid and invalid nonces
chain, _ := NewBlockChain(testdb, nil, params.EIP1559FinalizedChainConfig, ethash.NewFaker(), vm.Config{}, nil)
chain, _ := NewBlockChain(testdb, nil, params.EIP1559FinalizedChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
defer chain.Stop()
for i := 0; i < len(blocks); i++ {
@ -351,11 +351,11 @@ func testHeaderConcurrentVerificationEIP1559(t *testing.T, threads int) {
var results <-chan error
if valid {
chain, _ := NewBlockChain(testdb, nil, params.EIP1559ChainConfig, ethash.NewFaker(), vm.Config{}, nil)
chain, _ := NewBlockChain(testdb, nil, params.EIP1559ChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
chain.Stop()
} else {
chain, _ := NewBlockChain(testdb, nil, params.EIP1559ChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil)
chain, _ := NewBlockChain(testdb, nil, params.EIP1559ChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil, nil)
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
chain.Stop()
}
@ -427,11 +427,11 @@ func testHeaderConcurrentVerificationEIP1559Finalized(t *testing.T, threads int)
var results <-chan error
if valid {
chain, _ := NewBlockChain(testdb, nil, params.EIP1559FinalizedChainConfig, ethash.NewFaker(), vm.Config{}, nil)
chain, _ := NewBlockChain(testdb, nil, params.EIP1559FinalizedChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
chain.Stop()
} else {
chain, _ := NewBlockChain(testdb, nil, params.EIP1559FinalizedChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil)
chain, _ := NewBlockChain(testdb, nil, params.EIP1559FinalizedChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil, nil)
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
chain.Stop()
}

View File

@ -306,7 +306,10 @@ func testShorterFork(t *testing.T, full bool, chainConfig *params.ChainConfig, b
func TestLongerForkHeaders(t *testing.T) {
testLongerFork(t, false, params.AllEthashProtocolChanges, nil)
}
func TestLongerForkBlocks(t *testing.T) { testLongerFork(t, true, params.AllEthashProtocolChanges, nil) }
func TestLongerForkBlocks(t *testing.T) {
testLongerFork(t, true, params.AllEthashProtocolChanges, nil)
}
func TestLongerForkHeadersEIP1559(t *testing.T) {
testLongerFork(t, false, params.EIP1559ChainConfig, new(big.Int).SetUint64(params.EIP1559InitialBaseFee))
}
@ -347,8 +350,12 @@ func testLongerFork(t *testing.T, full bool, chainConfig *params.ChainConfig, ba
// Tests that given a starting canonical chain of a given size, creating equal
// forks do take canonical ownership.
func TestEqualForkHeaders(t *testing.T) { testEqualFork(t, false, params.AllEthashProtocolChanges, nil) }
func TestEqualForkBlocks(t *testing.T) { testEqualFork(t, true, params.AllEthashProtocolChanges, nil) }
func TestEqualForkHeaders(t *testing.T) {
testEqualFork(t, false, params.AllEthashProtocolChanges, nil)
}
func TestEqualForkBlocks(t *testing.T) {
testEqualFork(t, true, params.AllEthashProtocolChanges, nil)
}
func TestEqualForkHeadersEIP1559(t *testing.T) {
testEqualFork(t, false, params.EIP1559ChainConfig, new(big.Int).SetUint64(params.EIP1559InitialBaseFee))
}
@ -431,8 +438,12 @@ func testBrokenChain(t *testing.T, full bool, chainConfig *params.ChainConfig, b
// Tests that reorganising a long difficult chain after a short easy one
// overwrites the canonical numbers and links in the database.
func TestReorgLongHeaders(t *testing.T) { testReorgLong(t, false, params.AllEthashProtocolChanges, nil) }
func TestReorgLongBlocks(t *testing.T) { testReorgLong(t, true, params.AllEthashProtocolChanges, nil) }
func TestReorgLongHeaders(t *testing.T) {
testReorgLong(t, false, params.AllEthashProtocolChanges, nil)
}
func TestReorgLongBlocks(t *testing.T) {
testReorgLong(t, true, params.AllEthashProtocolChanges, nil)
}
func TestReorgLongHeadersEIP1559(t *testing.T) {
testReorgLong(t, false, params.EIP1559ChainConfig, new(big.Int).SetUint64(params.EIP1559InitialBaseFee))
}
@ -2246,7 +2257,7 @@ func TestTransactionIndices(t *testing.T) {
)
height := uint64(128)
blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, int(height), func(i int, block *BlockGen) {
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, nil, nil), signer, key)
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, new(big.Int), nil, nil, nil), signer, key)
if err != nil {
panic(err)
}
@ -2373,7 +2384,7 @@ func TestSkipStaleTxIndicesInFastSync(t *testing.T) {
)
height := uint64(128)
blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, int(height), func(i int, block *BlockGen) {
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, nil, nil), signer, key)
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, new(big.Int), nil, nil, nil), signer, key)
if err != nil {
panic(err)
}
@ -2768,11 +2779,11 @@ func TestDeleteRecreateSlots(t *testing.T) {
b.SetCoinbase(common.Address{1})
// One transaction to AA, to kill it
tx, _ := types.SignTx(types.NewTransaction(0, aa,
big.NewInt(0), 50000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
big.NewInt(0), 50000, big.NewInt(1), nil, nil, nil), types.HomesteadSigner{}, key)
b.AddTx(tx)
// One transaction to BB, to recreate AA
tx, _ = types.SignTx(types.NewTransaction(1, bb,
big.NewInt(0), 100000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
big.NewInt(0), 100000, big.NewInt(1), nil, nil, nil), types.HomesteadSigner{}, key)
b.AddTx(tx)
})
// Import the canonical chain
@ -2848,11 +2859,11 @@ func TestDeleteRecreateAccount(t *testing.T) {
b.SetCoinbase(common.Address{1})
// One transaction to AA, to kill it
tx, _ := types.SignTx(types.NewTransaction(0, aa,
big.NewInt(0), 50000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
big.NewInt(0), 50000, big.NewInt(1), nil, nil, nil), types.HomesteadSigner{}, key)
b.AddTx(tx)
// One transaction to AA, to recreate it (but without storage
tx, _ = types.SignTx(types.NewTransaction(1, aa,
big.NewInt(1), 100000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
big.NewInt(1), 100000, big.NewInt(1), nil, nil, nil), types.HomesteadSigner{}, key)
b.AddTx(tx)
})
// Import the canonical chain
@ -2982,7 +2993,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) {
var expectations []*expectation
var newDestruct = func(e *expectation) *types.Transaction {
tx, _ := types.SignTx(types.NewTransaction(nonce, aa,
big.NewInt(0), 50000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
big.NewInt(0), 50000, big.NewInt(1), nil, nil, nil), types.HomesteadSigner{}, key)
nonce++
if e.exist {
e.exist = false
@ -2993,7 +3004,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) {
}
var newResurrect = func(e *expectation) *types.Transaction {
tx, _ := types.SignTx(types.NewTransaction(nonce, bb,
big.NewInt(0), 100000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
big.NewInt(0), 100000, big.NewInt(1), nil, nil, nil), types.HomesteadSigner{}, key)
nonce++
if !e.exist {
e.exist = true
@ -3157,7 +3168,7 @@ func TestInitThenFailCreateContract(t *testing.T) {
b.SetCoinbase(common.Address{1})
// One transaction to BB
tx, _ := types.SignTx(types.NewTransaction(nonce, bb,
big.NewInt(0), 100000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
big.NewInt(0), 100000, big.NewInt(1), nil, nil, nil), types.HomesteadSigner{}, key)
b.AddTx(tx)
nonce++
})

View File

@ -170,7 +170,7 @@ func generateChainBeforeActivation(t *testing.T) {
})
// Import the chain. This runs all block validation rules.
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil)
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
defer blockchain.Stop()
if i, err := blockchain.InsertChain(chain); err != nil {
@ -231,7 +231,7 @@ func generateChainDuringTransition(t *testing.T) {
})
// Import the chain. This runs all block validation rules.
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil)
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
defer blockchain.Stop()
if i, err := blockchain.InsertChain(chain); err != nil {
@ -316,7 +316,7 @@ func generateChainAfterFinalization(t *testing.T) {
})
// Import the chain. This runs all block validation rules.
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil)
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
defer blockchain.Stop()
if i, err := blockchain.InsertChain(chain); err != nil {
@ -378,7 +378,7 @@ func generateChainAfterFinalization2(t *testing.T) {
})
// Import the chain. This runs all block validation rules.
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil)
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
defer blockchain.Stop()
if i, err := blockchain.InsertChain(chain); err != nil {

View File

@ -36,7 +36,7 @@ func TestChainIterator(t *testing.T) {
if i == 0 {
block = types.NewBlock(&types.Header{Number: big.NewInt(int64(i))}, nil, nil, nil) // Empty genesis block
} else {
tx := types.NewTransaction(i, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
tx := types.NewTransaction(i, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}, nil, nil)
txs = append(txs, tx)
block = types.NewBlock(&types.Header{Number: big.NewInt(int64(i))}, []*types.Transaction{tx}, nil, nil)
}

View File

@ -55,7 +55,7 @@ func getBlock(transactions int, uncles int, dataSize int) *types.Block {
// Add transactions and stuff on the last block
for i := 0; i < transactions; i++ {
tx, _ := types.SignTx(types.NewTransaction(uint64(i), aa,
big.NewInt(0), 50000, big.NewInt(1), make([]byte, dataSize)), types.HomesteadSigner{}, key)
big.NewInt(0), 50000, big.NewInt(1), make([]byte, dataSize), nil, nil), types.HomesteadSigner{}, key)
b.AddTx(tx)
}
for i := 0; i < uncles; i++ {

View File

@ -100,6 +100,6 @@ func precacheTransaction(config *params.ChainConfig, bc ChainContext, author *co
context := NewEVMContext(msg, header, bc, author)
vm := vm.NewEVM(context, statedb, config, cfg)
_, _, _, err = ApplyMessage(vm, msg, gaspool, gp1559)
_, err = ApplyMessage(vm, msg, gaspool, gp1559)
return err
}

View File

@ -108,7 +108,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
// about the transaction and calling mechanisms.
vmenv := vm.NewEVM(context, statedb, config, cfg)
// Apply the transaction to the current state (included in the env)
_, gas, failed, err := ApplyMessage(vmenv, msg, gp, gp1559)
res, err := ApplyMessage(vmenv, msg, gp, gp1559)
if err != nil {
return nil, err
}
@ -119,13 +119,13 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
} else {
root = statedb.IntermediateRoot(config.IsEIP158(header.Number)).Bytes()
}
*usedGas += result.UsedGas
*usedGas += res.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.NewReceipt(root, result.Failed(), *usedGas)
receipt := types.NewReceipt(root, res.Failed(), *usedGas)
receipt.TxHash = tx.Hash()
receipt.GasUsed = result.UsedGas
receipt.GasUsed = res.UsedGas
// if the transaction created a contract, store the creation address in the receipt.
if msg.To() == nil {
receipt.ContractAddress = crypto.CreateAddress(vmenv.Context.Origin, tx.Nonce())

View File

@ -17,6 +17,7 @@
package core
import (
"errors"
"math"
"math/big"
@ -182,7 +183,7 @@ func NewStateTransition(evm *vm.EVM, msg Message, gp, gp1559 *GasPool) *StateTra
// the gas used (which includes gas refunds) and an error if it failed. An error always
// indicates a core error meaning that the message would always fail for that particular
// state and would never be accepted within a block.
func ApplyMessage(evm *vm.EVM, msg Message, gp, gp1559 *GasPool) ([]byte, uint64, bool, error) {
func ApplyMessage(evm *vm.EVM, msg Message, gp, gp1559 *GasPool) (*ExecutionResult, error) {
return NewStateTransition(evm, msg, gp, gp1559).TransitionDb()
}
@ -337,7 +338,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
// coinbaseCredit cannot be negative since we precheck that eip1559GasPrice >= st.evm.BaseFee
st.state.AddBalance(st.evm.Coinbase, coinBaseCredit)
return ret, st.gasUsed(), vmerr != nil, err
return &ExecutionResult{
UsedGas: st.gasUsed(),
Err: vmerr,
ReturnData: ret,
}, nil
}
st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice))

View File

@ -108,7 +108,7 @@ func setupTxPool() (*TxPool, *ecdsa.PrivateKey) {
}
func setupEIP1559TxPool(baseFee *big.Int) (*TxPool, *ecdsa.PrivateKey) {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), baseFee}
key, _ := crypto.GenerateKey()
@ -118,7 +118,7 @@ func setupEIP1559TxPool(baseFee *big.Int) (*TxPool, *ecdsa.PrivateKey) {
}
func setupEIP1559FinalizedTxPool(baseFee *big.Int) (*TxPool, *ecdsa.PrivateKey) {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), baseFee}
key, _ := crypto.GenerateKey()
@ -267,7 +267,7 @@ func TestStateChangeDuringTransactionPoolResetEIP1559(t *testing.T) {
var (
key, _ = crypto.GenerateKey()
address = crypto.PubkeyToAddress(key.PublicKey)
statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
trigger = false
)
@ -313,7 +313,7 @@ func TestStateChangeDuringTransactionPoolResetEIP1559Finalized(t *testing.T) {
var (
key, _ = crypto.GenerateKey()
address = crypto.PubkeyToAddress(key.PublicKey)
statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
trigger = false
)
@ -358,7 +358,7 @@ func TestTransactionPoolBaseFeeEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
pool := NewTxPool(testTxPoolConfig, params.EIP1559ChainConfig, blockchain)
@ -376,7 +376,7 @@ func TestTransactionPoolBaseFeeEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
pool := NewTxPool(testTxPoolConfig, params.EIP1559FinalizedChainConfig, blockchain)
@ -480,20 +480,16 @@ func TestInvalidTransactionsEIP1559(t *testing.T) {
if err := pool.AddRemote(tx); err != nil {
t.Error("expected", nil, "got", err)
}
if err := pool.AddLocal(tx); err.Error() != fmt.Sprintf("known transaction: %s", tx.Hash().String()[2:]) {
t.Error("expected", fmt.Sprintf("known transaction: %s", tx.Hash().String()[2:]), "got", err)
if err := pool.AddLocal(tx); err != ErrAlreadyKnown {
t.Error("expected", fmt.Sprintf(ErrAlreadyKnown.Error(), "got", err))
}
tx = eip1559Transaction(2, 100000, key, big.NewInt(1), big.NewInt(10))
if err := pool.AddRemote(tx); err != nil {
t.Error("expected", nil, "got", err)
}
if err := pool.AddLocal(tx); err.Error() != fmt.Sprintf("known transaction: %s", tx.Hash().String()[2:]) {
t.Error("expected", fmt.Sprintf("known transaction: %s", tx.Hash().String()[2:]), "got", err)
}
if err := pool.AddLocal(tx); err.Error() != fmt.Sprintf("known transaction: %s", tx.Hash().String()[2:]) {
t.Error("expected", fmt.Sprintf("known transaction: %s", tx.Hash().String()[2:]), "got", err)
if err := pool.AddLocal(tx); err != ErrAlreadyKnown {
t.Error("expected", fmt.Sprintf(ErrAlreadyKnown.Error(), "got", err))
}
tx = malformedTransaction(2, 100000, key, big.NewInt(5), big.NewInt(1), big.NewInt(10))
@ -777,7 +773,7 @@ func TestTransactionChainFork(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
statedb.AddBalance(addr, big.NewInt(100000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed), nil}
@ -806,7 +802,7 @@ func TestTransactionChainForkEIP1559(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
statedb.AddBalance(addr, big.NewInt(100000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(5)}
@ -835,7 +831,7 @@ func TestTransactionChainForkEIP1559Finalized(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
statedb.AddBalance(addr, big.NewInt(100000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(5)}
@ -915,7 +911,7 @@ func TestTransactionDoubleNonceEIP1559(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
statedb.AddBalance(addr, big.NewInt(100000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(5)}
@ -995,7 +991,7 @@ func TestTransactionDoubleNonceEIP1559Finalized(t *testing.T) {
addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
statedb.AddBalance(addr, big.NewInt(100000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(5)}
@ -1495,7 +1491,7 @@ func TestTransactionPostponing(t *testing.T) {
t.Parallel()
// Create the pool to test the postponing with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain)
@ -1606,7 +1602,7 @@ func TestTransactionPostponingEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the postponing with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559ChainConfig, blockchain)
@ -1717,7 +1713,7 @@ func TestTransactionPostponingEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the postponing with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559FinalizedChainConfig, blockchain)
@ -2100,7 +2096,7 @@ func testTransactionQueueGlobalLimiting(t *testing.T, nolocals bool) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -2184,7 +2180,7 @@ func testTransactionQueueGlobalLimitingEIP1559(t *testing.T, nolocals bool) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2268,7 +2264,7 @@ func testTransactionQueueGlobalLimitingEIP1559Finalized(t *testing.T, nolocals b
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2347,8 +2343,12 @@ func testTransactionQueueGlobalLimitingEIP1559Finalized(t *testing.T, nolocals b
//
// This logic should not hold for local transactions, unless the local tracking
// mechanism is disabled.
func TestTransactionQueueTimeLimiting(t *testing.T) { testTransactionQueueTimeLimiting(t, false) }
func TestTransactionQueueTimeLimitingNoLocals(t *testing.T) { testTransactionQueueTimeLimiting(t, true) }
func TestTransactionQueueTimeLimiting(t *testing.T) {
testTransactionQueueTimeLimiting(t, false)
}
func TestTransactionQueueTimeLimitingNoLocals(t *testing.T) {
testTransactionQueueTimeLimiting(t, true)
}
func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) {
// Reduce the eviction interval to a testable amount
@ -2356,7 +2356,7 @@ func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) {
evictionInterval = time.Second
// Create the pool to test the non-expiration enforcement
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -2424,7 +2424,7 @@ func testTransactionQueueTimeLimitingEIP1559(t *testing.T, nolocals bool) {
evictionInterval = time.Second
// Create the pool to test the non-expiration enforcement
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2492,7 +2492,7 @@ func testTransactionQueueTimeLimitingEIP1559Finalized(t *testing.T, nolocals boo
evictionInterval = time.Second
// Create the pool to test the non-expiration enforcement
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2671,7 +2671,7 @@ func TestTransactionPendingGlobalLimiting(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -2716,7 +2716,7 @@ func TestTransactionPendingGlobalLimitingEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2761,7 +2761,7 @@ func TestTransactionPendingGlobalLimitingEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2807,7 +2807,7 @@ func TestTransactionCapClearsFromAll(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -2838,7 +2838,7 @@ func TestTransactionCapClearsFromAllEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2869,7 +2869,7 @@ func TestTransactionCapClearsFromAllEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -2903,7 +2903,7 @@ func TestTransactionPendingMinimumAllowance(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -2946,7 +2946,7 @@ func TestTransactionPendingMinimumAllowanceEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -2989,7 +2989,7 @@ func TestTransactionPendingMinimumAllowanceEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -3037,7 +3037,7 @@ func TestTransactionPoolRepricing(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain)
@ -3156,7 +3156,7 @@ func TestTransactionPoolRepricingEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559ChainConfig, blockchain)
@ -3275,7 +3275,7 @@ func TestTransactionPoolRepricingEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559FinalizedChainConfig, blockchain)
@ -3396,7 +3396,7 @@ func TestTransactionPoolRepricingKeepsLocals(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain)
@ -3453,7 +3453,7 @@ func TestTransactionPoolRepricingKeepsLocalsEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559ChainConfig, blockchain)
@ -3510,7 +3510,7 @@ func TestTransactionPoolRepricingKeepsLocalsEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559FinalizedChainConfig, blockchain)
@ -3572,7 +3572,7 @@ func TestTransactionPoolUnderpricing(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()),nil)
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -3675,7 +3675,7 @@ func TestTransactionPoolUnderpricingEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -4068,7 +4068,7 @@ func TestTransactionPoolStableUnderpricingEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -4197,7 +4197,7 @@ func TestTransactionDeduplicationEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559ChainConfig, blockchain)
@ -4261,7 +4261,7 @@ func TestTransactionDeduplicationEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559FinalizedChainConfig, blockchain)
@ -4582,7 +4582,7 @@ func testTransactionJournaling(t *testing.T, nolocals bool) {
os.Remove(journal)
// Create the original pool to inject transaction into the journal
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), nil}
config := testTxPoolConfig
@ -4675,8 +4675,12 @@ func testTransactionJournaling(t *testing.T, nolocals bool) {
pool.Stop()
}
func TestTransactionJournalingEIP1559(t *testing.T) { testTransactionJournalingEIP1559(t, false) }
func TestTransactionJournalingNoLocalsEIP1559(t *testing.T) { testTransactionJournalingEIP1559(t, true) }
func TestTransactionJournalingEIP1559(t *testing.T) {
testTransactionJournalingEIP1559(t, false)
}
func TestTransactionJournalingNoLocalsEIP1559(t *testing.T) {
testTransactionJournalingEIP1559(t, true)
}
func testTransactionJournalingEIP1559(t *testing.T, nolocals bool) {
t.Parallel()
@ -4694,7 +4698,7 @@ func testTransactionJournalingEIP1559(t *testing.T, nolocals bool) {
os.Remove(journal)
// Create the original pool to inject transaction into the journal
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
config := testTxPoolConfig
@ -4963,7 +4967,7 @@ func TestTransactionStatusCheckEIP1559(t *testing.T) {
t.Parallel()
// Create the pool to test the status retrievals with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559ChainConfig, blockchain)
@ -5017,7 +5021,7 @@ func TestTransactionStatusCheckEIP1559Finalized(t *testing.T) {
t.Parallel()
// Create the pool to test the status retrievals with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed), big.NewInt(1)}
pool := NewTxPool(testTxPoolConfig, params.EIP1559FinalizedChainConfig, blockchain)

View File

@ -506,7 +506,7 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block,
gp1559 = new(core.GasPool).AddGas(msg.Gas())
}
vmenv := vm.NewEVM(vmctx, statedb, api.eth.blockchain.Config(), vm.Config{})
if _, _, _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), gp1559); err != nil {
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), gp1559); err != nil {
failed = err
break
}
@ -604,7 +604,7 @@ func (api *PrivateDebugAPI) standardTraceBlockToFile(ctx context.Context, block
if api.eth.blockchain.Config().IsEIP1559(block.Number()) {
gp1559 = new(core.GasPool).AddGas(msg.Gas())
}
_, _, _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), gp1559)
_, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), gp1559)
if writer != nil {
writer.Flush()
}
@ -770,7 +770,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
// Run the transaction with tracing enabled.
vmenv := vm.NewEVM(vmctx, statedb, api.eth.blockchain.Config(), vm.Config{Debug: true, Tracer: tracer})
ret, gas, failed, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas()), gp1559)
result, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas()), gp1559)
if err != nil {
return nil, fmt.Errorf("tracing failed: %v", err)
}
@ -828,7 +828,7 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree
}
// Not yet the searched for transaction, execute on top of the current state
vmenv := vm.NewEVM(context, statedb, api.eth.blockchain.Config(), vm.Config{})
if _, _, _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), gp1559); err != nil {
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), gp1559); err != nil {
return nil, vm.Context{}, nil, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err)
}
// Ensure any modifications are committed to the state

View File

@ -159,7 +159,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
closeBloomHandler: make(chan struct{}),
networkID: config.NetworkId,
gasPrice: config.Miner.GasPrice,
perTxGasLimit: config.Miner.PerTxGasLimit,
perTxGasLimit: config.Miner.PerTxGasLimit,
etherbase: config.Miner.Etherbase,
bloomRequests: make(chan chan *bloombits.Retrieval),
bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms),

View File

@ -32,10 +32,10 @@ import (
var (
// testTxs is a set of transactions to use during testing that have meaningful hashes.
testTxs = []*types.Transaction{
types.NewTransaction(5577006791947779410, common.Address{0x0f}, new(big.Int), 0, new(big.Int), nil),
types.NewTransaction(15352856648520921629, common.Address{0xbb}, new(big.Int), 0, new(big.Int), nil),
types.NewTransaction(3916589616287113937, common.Address{0x86}, new(big.Int), 0, new(big.Int), nil),
types.NewTransaction(9828766684487745566, common.Address{0xac}, new(big.Int), 0, new(big.Int), nil),
types.NewTransaction(5577006791947779410, common.Address{0x0f}, new(big.Int), 0, new(big.Int), nil, nil, nil),
types.NewTransaction(15352856648520921629, common.Address{0xbb}, new(big.Int), 0, new(big.Int), nil, nil, nil),
types.NewTransaction(3916589616287113937, common.Address{0x86}, new(big.Int), 0, new(big.Int), nil, nil, nil),
types.NewTransaction(9828766684487745566, common.Address{0xac}, new(big.Int), 0, new(big.Int), nil, nil, nil),
}
// testTxsHashes is the hashes of the test transactions above
testTxsHashes = []common.Hash{testTxs[0].Hash(), testTxs[1].Hash(), testTxs[2].Hash(), testTxs[3].Hash()}
@ -908,7 +908,7 @@ func TestTransactionFetcherUnderpricedDoSProtection(t *testing.T) {
// Create a slew of transactions to max out the underpriced set
var txs []*types.Transaction
for i := 0; i < maxTxUnderpricedSetSize+1; i++ {
txs = append(txs, types.NewTransaction(rand.Uint64(), common.Address{byte(rand.Intn(256))}, new(big.Int), 0, new(big.Int), nil))
txs = append(txs, types.NewTransaction(rand.Uint64(), common.Address{byte(rand.Intn(256))}, new(big.Int), 0, new(big.Int), nil, nil, nil))
}
hashes := make([]common.Hash, len(txs))
for i, tx := range txs {

View File

@ -183,7 +183,7 @@ func TestPrestateTracerCreate2(t *testing.T) {
t.Fatalf("failed to prepare transaction for tracing: %v", err)
}
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.Gas()), nil)
if _, _, _, err = st.TransitionDb(); err != nil {
if _, err = st.TransitionDb(); err != nil {
t.Fatalf("failed to execute transaction: %v", err)
}
// Retrieve the trace result and compare against the etalon
@ -262,7 +262,7 @@ func TestCallTracer(t *testing.T) {
gp1559 = new(core.GasPool).AddGas(tx.Gas())
}
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.Gas()), gp1559)
if _, _, _, err = st.TransitionDb(); err != nil {
if _, err = st.TransitionDb(); err != nil {
t.Fatalf("failed to execute transaction: %v", err)
}
// Retrieve the trace result and compare against the etalon

View File

@ -48,6 +48,10 @@ import (
"github.com/tyler-smith/go-bip39"
)
const (
defaultGasPrice = params.GWei
)
// PublicEthereumAPI provides an API to access Ethereum related information.
// It offers only methods that operate on public data that is freely available to anyone.
type PublicEthereumAPI struct {
@ -771,9 +775,13 @@ func (args *CallArgs) ToMessage(globalGasCap *big.Int) types.Message {
log.Warn("Caller gas above allowance, capping", "requested", gas, "cap", globalGasCap)
gas = globalGasCap.Uint64()
}
gasPrice := new(big.Int)
if args.GasPrice != nil {
gasPrice = args.GasPrice.ToInt()
var gasPrice *big.Int
if args.GasPremium == nil {
gasPrice = new(big.Int).SetUint64(defaultGasPrice)
if args.GasPrice != nil {
gasPrice = args.GasPrice.ToInt()
}
}
value := new(big.Int)
@ -786,7 +794,8 @@ func (args *CallArgs) ToMessage(globalGasCap *big.Int) types.Message {
data = []byte(*args.Data)
}
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, false)
// Create new call message
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, false, (*big.Int)(args.GasPremium), (*big.Int)(args.FeeCap))
return msg
}
@ -811,30 +820,30 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
eip1559 := b.ChainConfig().IsEIP1559(b.CurrentBlock().Number())
eip1559Finalized := b.ChainConfig().IsEIP1559Finalized(b.CurrentBlock().Number())
if eip1559 && b.CurrentBlock().BaseFee() == nil {
return nil, 0, false, core.ErrNoBaseFee
return nil, core.ErrNoBaseFee
}
if eip1559Finalized && (args.GasPremium == nil || args.FeeCap == nil || args.GasPrice != nil) {
return nil, 0, false, core.ErrTxNotEIP1559
return nil, core.ErrTxNotEIP1559
}
if !eip1559 && (args.GasPremium != nil || args.FeeCap != nil || args.GasPrice == nil) {
return nil, 0, false, core.ErrTxIsEIP1559
return nil, core.ErrTxIsEIP1559
}
if args.GasPrice != nil && (args.GasPremium != nil || args.FeeCap != nil) {
return nil, 0, false, core.ErrTxSetsLegacyAndEIP1559Fields
return nil, core.ErrTxSetsLegacyAndEIP1559Fields
}
if args.FeeCap != nil && args.GasPremium == nil {
return nil, 0, false, errors.New("if FeeCap is set, GasPremium must be set")
return nil, errors.New("if FeeCap is set, GasPremium must be set")
}
if args.GasPremium != nil {
if args.FeeCap == nil {
return nil, 0, false, errors.New("if GasPremium is set, FeeCap must be set")
return nil, errors.New("if GasPremium is set, FeeCap must be set")
}
gasPrice := new(big.Int).Add(b.CurrentBlock().BaseFee(), args.GasPremium.ToInt())
if gasPrice.Cmp(args.FeeCap.ToInt()) > 0 {
gasPrice.Set(args.FeeCap.ToInt())
}
if gasPrice.Cmp(b.CurrentBlock().BaseFee()) < 0 {
return nil, 0, false, core.ErrEIP1559GasPriceLessThanBaseFee
return nil, core.ErrEIP1559GasPriceLessThanBaseFee
}
}
@ -902,7 +911,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
if evm.ChainConfig().IsEIP1559(header.Number) {
gp1559 = new(core.GasPool).AddGas(math.MaxUint64)
}
res, gas, failed, err := core.ApplyMessage(evm, msg, gp, gp1559)
res, err := core.ApplyMessage(evm, msg, gp, gp1559)
if err := vmError(); err != nil {
return nil, err
}
@ -910,7 +919,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
if evm.Cancelled() {
return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout)
}
return result, err
return res, err
}
func newRevertError(result *core.ExecutionResult) *revertError {

View File

@ -19,8 +19,8 @@ package les
import (
"fmt"
"time"
"math/big"
"time"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/abi/bind"

View File

@ -139,8 +139,8 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
if config.IsEIP1559(header.Number) {
gp1559 = new(core.GasPool).AddGas(math.MaxUint64)
}
ret, _, _, _ := core.ApplyMessage(vmenv, msg, gp, gp1559)
res = append(res, ret...)
ret, _ := core.ApplyMessage(vmenv, msg, gp, gp1559)
res = append(res, ret.Return()...)
}
} else {
header := lc.GetHeaderByHash(bhash)
@ -154,9 +154,9 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
if config.IsEIP1559(header.Number) {
gp1559 = new(core.GasPool).AddGas(math.MaxUint64)
}
ret, _, _, _ := core.ApplyMessage(vmenv, msg, gp, gp1559)
ret, _ := core.ApplyMessage(vmenv, msg, gp, gp1559)
if state.Error() == nil {
res = append(res, result.Return()...)
res = append(res, ret.Return()...)
}
}
}

View File

@ -202,8 +202,8 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
if config.IsEIP1559(header.Number) {
gp1559 = new(core.GasPool).AddGas(math.MaxUint64)
}
ret, _, _, _ := core.ApplyMessage(vmenv, msg, gp, gp1559)
res = append(res, ret...)
ret, _ := core.ApplyMessage(vmenv, msg, gp, gp1559)
res = append(res, ret.Return()...)
if st.Error() != nil {
return res, st.Error()
}

View File

@ -98,19 +98,19 @@ var (
// RopstenChainConfig contains the chain parameters to run a node on the Ropsten test network.
RopstenChainConfig = &ChainConfig{
ChainID: big.NewInt(3),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
EIP155Block: big.NewInt(10),
EIP158Block: big.NewInt(10),
ByzantiumBlock: big.NewInt(1700000),
ConstantinopleBlock: big.NewInt(4230000),
PetersburgBlock: big.NewInt(4939394),
IstanbulBlock: big.NewInt(6485846),
MuirGlacierBlock: big.NewInt(7117117),
ChainID: big.NewInt(3),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
EIP155Block: big.NewInt(10),
EIP158Block: big.NewInt(10),
ByzantiumBlock: big.NewInt(1700000),
ConstantinopleBlock: big.NewInt(4230000),
PetersburgBlock: big.NewInt(4939394),
IstanbulBlock: big.NewInt(6485846),
MuirGlacierBlock: big.NewInt(7117117),
EIP1559Block: nil,
EIP1559FinalizedBlock: nil,
EWASMBlock: nil,
@ -141,19 +141,19 @@ var (
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
RinkebyChainConfig = &ChainConfig{
ChainID: big.NewInt(4),
HomesteadBlock: big.NewInt(1),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(2),
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(1035301),
ConstantinopleBlock: big.NewInt(3660663),
PetersburgBlock: big.NewInt(4321234),
IstanbulBlock: big.NewInt(5435345),
MuirGlacierBlock: nil,
ChainID: big.NewInt(4),
HomesteadBlock: big.NewInt(1),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(2),
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(1035301),
ConstantinopleBlock: big.NewInt(3660663),
PetersburgBlock: big.NewInt(4321234),
IstanbulBlock: big.NewInt(5435345),
MuirGlacierBlock: nil,
EIP1559Block: nil,
EIP1559FinalizedBlock: nil,
EWASMBlock: nil,
@ -186,18 +186,18 @@ var (
// GoerliChainConfig contains the chain parameters to run a node on the Görli test network.
GoerliChainConfig = &ChainConfig{
ChainID: big.NewInt(5),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(1561651),
MuirGlacierBlock: nil,
ChainID: big.NewInt(5),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(1561651),
MuirGlacierBlock: nil,
EIP1559Block: nil,
EIP1559FinalizedBlock: nil,
EWASMBlock: nil,
@ -255,22 +255,22 @@ var (
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllEthashProtocolChanges = &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, new(EthashConfig), nil, DefaultEIP1559Config}
AllEthashProtocolChanges = &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, nil, new(EthashConfig), nil, DefaultEIP1559Config}
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus.
//
// 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, nil, &CliqueConfig{Period: 0, Epoch: 30000}, DefaultEIP1559Config}
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, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, DefaultEIP1559Config}
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, nil, new(EthashConfig), nil, DefaultEIP1559Config}
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, nil, nil, new(EthashConfig), nil, DefaultEIP1559Config}
TestRules = TestChainConfig.Rules(new(big.Int))
// EIP1559 test configs
EIP1559ChainConfig = &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, big.NewInt(0), nil, nil, new(EthashConfig), nil, DefaultEIP1559Config}
EIP1559FinalizedChainConfig = &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, big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, DefaultEIP1559Config}
EIP1559ChainConfig = &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), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, new(EthashConfig), nil, DefaultEIP1559Config}
EIP1559FinalizedChainConfig = &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), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, DefaultEIP1559Config}
EIP1559TestRules = EIP1559ChainConfig.Rules(new(big.Int))
EIP1559FinalizedTestRules = EIP1559FinalizedChainConfig.Rules(new(big.Int))
@ -344,12 +344,12 @@ type ChainConfig struct {
IstanbulBlock *big.Int `json:"istanbulBlock,omitempty"` // Istanbul switch block (nil = no fork, 0 = already on istanbul)
MuirGlacierBlock *big.Int `json:"muirGlacierBlock,omitempty"` // Eip-2384 (bomb delay) switch block (nil = no fork, 0 = already activated)
YoloV1Block *big.Int `json:"yoloV1Block,omitempty"` // YOLO v1: https://github.com/ethereum/EIPs/pull/2657 (Ephemeral testnet)
YoloV1Block *big.Int `json:"yoloV1Block,omitempty"` // YOLO v1: https://github.com/ethereum/EIPs/pull/2657 (Ephemeral testnet)
EIP1559Block *big.Int `json:"eip1559Block,omitempty"` // EIP1559 switch block (nil = no fork, 0 = already on eip1559)
EIP1559FinalizedBlock *big.Int `json:"eip1559FinalizedBlock,omitempty"` // EIP1559 finalization switch block (nil = no fork, 0 = already on eip1559 finalized)
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)
// Various consensus engines
// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`
@ -693,7 +693,7 @@ type Rules struct {
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
IsMuirGlacier, IsYoloV1, IsEIP1559, IsEIP1559Finalized bool
IsEWASM bool
IsEWASM bool
}
// Rules ensures c's ChainID is not nil.
@ -703,17 +703,17 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
chainID = new(big.Int)
}
return Rules{
ChainID: new(big.Int).Set(chainID),
IsHomestead: c.IsHomestead(num),
IsEIP150: c.IsEIP150(num),
IsEIP155: c.IsEIP155(num),
IsEIP158: c.IsEIP158(num),
IsByzantium: c.IsByzantium(num),
IsConstantinople: c.IsConstantinople(num),
IsPetersburg: c.IsPetersburg(num),
IsIstanbul: c.IsIstanbul(num),
ChainID: new(big.Int).Set(chainID),
IsHomestead: c.IsHomestead(num),
IsEIP150: c.IsEIP150(num),
IsEIP155: c.IsEIP155(num),
IsEIP158: c.IsEIP158(num),
IsByzantium: c.IsByzantium(num),
IsConstantinople: c.IsConstantinople(num),
IsPetersburg: c.IsPetersburg(num),
IsIstanbul: c.IsIstanbul(num),
IsMuirGlacier: c.IsMuirGlacier(num),
IsYoloV1: c.IsYoloV1(num),
IsYoloV1: c.IsYoloV1(num),
IsEIP1559: c.IsEIP1559(num),
IsEIP1559Finalized: c.IsEIP1559Finalized(num),
IsEWASM: c.IsEWASM(num),

View File

@ -44,7 +44,7 @@ func init() {
}
txs = make([]*types.Transaction, 65536) // We need to bump enough to hit all the limits
for i := 0; i < len(txs); i++ {
txs[i] = types.NewTransaction(rand.Uint64(), common.Address{byte(rand.Intn(256))}, new(big.Int), 0, new(big.Int), nil)
txs[i] = types.NewTransaction(rand.Uint64(), common.Address{byte(rand.Intn(256))}, new(big.Int), 0, new(big.Int), nil, nil, nil)
}
}

View File

@ -193,7 +193,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
}
snapshot := statedb.Snapshot()
if _, _, _, err := core.ApplyMessage(evm, msg, gaspool, gp1559); err != nil {
if _, err := core.ApplyMessage(evm, msg, gaspool, gp1559); err != nil {
statedb.RevertToSnapshot(snapshot)
}
// Commit block