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:
@ -502,6 +502,16 @@ func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
|
||||
return (*big.Int)(&hex), nil
|
||||
}
|
||||
|
||||
// SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559 to
|
||||
// allow a timely execution of a transaction.
|
||||
func (ec *Client) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||
var hex hexutil.Big
|
||||
if err := ec.c.CallContext(ctx, &hex, "eth_maxPriorityFeePerGas"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return (*big.Int)(&hex), nil
|
||||
}
|
||||
|
||||
// EstimateGas tries to estimate the gas needed to execute a specific transaction based on
|
||||
// the current pending state of the backend blockchain. There is no guarantee that this is
|
||||
// the true gas limit requirement as other transactions may be added or removed by miners,
|
||||
|
@ -184,7 +184,7 @@ func TestToFilterArg(t *testing.T) {
|
||||
var (
|
||||
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
|
||||
testBalance = big.NewInt(2e10)
|
||||
testBalance = big.NewInt(2e15)
|
||||
)
|
||||
|
||||
func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
|
||||
@ -220,6 +220,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
|
||||
Alloc: core.GenesisAlloc{testAddr: {Balance: testBalance}},
|
||||
ExtraData: []byte("test genesis"),
|
||||
Timestamp: 9000,
|
||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||
}
|
||||
generate := func(i int, g *core.BlockGen) {
|
||||
g.OffsetTime(5)
|
||||
@ -457,9 +458,17 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if gasPrice.Cmp(big.NewInt(1000000000)) != 0 {
|
||||
if gasPrice.Cmp(big.NewInt(1875000000)) != 0 { // 1 gwei tip + 0.875 basefee after a 1 gwei fee empty block
|
||||
t.Fatalf("unexpected gas price: %v", gasPrice)
|
||||
}
|
||||
// SuggestGasTipCap (should suggest 1 Gwei)
|
||||
gasTipCap, err := ec.SuggestGasTipCap(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if gasTipCap.Cmp(big.NewInt(1000000000)) != 0 {
|
||||
t.Fatalf("unexpected gas tip cap: %v", gasTipCap)
|
||||
}
|
||||
}
|
||||
|
||||
func testCallContract(t *testing.T, client *rpc.Client) {
|
||||
@ -467,11 +476,10 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
||||
|
||||
// EstimateGas
|
||||
msg := ethereum.CallMsg{
|
||||
From: testAddr,
|
||||
To: &common.Address{},
|
||||
Gas: 21000,
|
||||
GasPrice: big.NewInt(1),
|
||||
Value: big.NewInt(1),
|
||||
From: testAddr,
|
||||
To: &common.Address{},
|
||||
Gas: 21000,
|
||||
Value: big.NewInt(1),
|
||||
}
|
||||
gas, err := ec.EstimateGas(context.Background(), msg)
|
||||
if err != nil {
|
||||
@ -560,7 +568,7 @@ func sendTransaction(ec *Client) error {
|
||||
return err
|
||||
}
|
||||
// Create transaction
|
||||
tx := types.NewTransaction(0, common.Address{1}, big.NewInt(1), 22000, big.NewInt(1), nil)
|
||||
tx := types.NewTransaction(0, common.Address{1}, big.NewInt(1), 22000, big.NewInt(params.InitialBaseFee), nil)
|
||||
signer := types.LatestSignerForChainID(chainID)
|
||||
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), testKey)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user