accounts/abi/bind: fix bounded contracts and sim backend for 1559 (#23038)

* accounts/abi/bind: fix bounded contracts and sim backend for 1559

* accounts/abi/bind, ethclient: don't rely on chain config for gas prices

* all: enable London for all internal tests

* les: get receipt type info in les tests

* les: fix weird test

Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
Péter Szilágyi
2021-06-15 13:56:14 +03:00
committed by GitHub
parent 087ed9c92e
commit 7a7abe3de8
40 changed files with 449 additions and 236 deletions

View File

@ -24,6 +24,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
@ -145,6 +146,9 @@ func (api *consensusAPI) AssembleBlock(params assembleBlockParams) (*executableD
Extra: []byte{},
Time: params.Timestamp,
}
if config := api.eth.BlockChain().Config(); config.IsLondon(header.Number) {
header.BaseFee = misc.CalcBaseFee(config, parent.Header())
}
err = api.eth.Engine().Prepare(bc, header)
if err != nil {
return nil, err
@ -246,7 +250,7 @@ func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) {
return txs, nil
}
func insertBlockParamsToBlock(params executableData) (*types.Block, error) {
func insertBlockParamsToBlock(config *chainParams.ChainConfig, parent *types.Header, params executableData) (*types.Block, error) {
txs, err := decodeTransactions(params.Transactions)
if err != nil {
return nil, err
@ -268,6 +272,9 @@ func insertBlockParamsToBlock(params executableData) (*types.Block, error) {
GasUsed: params.GasUsed,
Time: params.Timestamp,
}
if config.IsLondon(number) {
header.BaseFee = misc.CalcBaseFee(config, parent)
}
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */)
return block, nil
}
@ -280,11 +287,10 @@ func (api *consensusAPI) NewBlock(params executableData) (*newBlockResponse, err
if parent == nil {
return &newBlockResponse{false}, fmt.Errorf("could not find parent %x", params.ParentHash)
}
block, err := insertBlockParamsToBlock(params)
block, err := insertBlockParamsToBlock(api.eth.BlockChain().Config(), parent.Header(), params)
if err != nil {
return nil, err
}
_, err = api.eth.BlockChain().InsertChainWithoutSealVerification(block)
return &newBlockResponse{err == nil}, err
}