forked from cerc-io/plugeth
eth, miner: fix enforcing the minimum miner tip (#28933)
* eth, miner: fix enforcing the minimum miner tip * ethclient/simulated: fix failing test due the min tip change * accounts/abi/bind: fix simulater gas tip issue
This commit is contained in:
@@ -52,7 +52,7 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) {
|
||||
|
||||
// create a signed transaction to send
|
||||
head, _ := client.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(params.GWei))
|
||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||
chainid, _ := client.ChainID(context.Background())
|
||||
nonce, err := client.PendingNonceAt(context.Background(), addr)
|
||||
@@ -62,7 +62,7 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) {
|
||||
tx := types.NewTx(&types.DynamicFeeTx{
|
||||
ChainID: chainid,
|
||||
Nonce: nonce,
|
||||
GasTipCap: big.NewInt(1),
|
||||
GasTipCap: big.NewInt(params.GWei),
|
||||
GasFeeCap: gasPrice,
|
||||
Gas: 21000,
|
||||
To: &addr,
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package simulated
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
)
|
||||
@@ -37,3 +39,17 @@ func WithCallGasLimit(gaslimit uint64) func(nodeConf *node.Config, ethConf *ethc
|
||||
ethConf.RPCGasCap = gaslimit
|
||||
}
|
||||
}
|
||||
|
||||
// WithMinerMinTip configures the simulated backend to require a specific minimum
|
||||
// gas tip for a transaction to be included.
|
||||
//
|
||||
// 0 is not possible as a live Geth node would reject that due to DoS protection,
|
||||
// so the simulated backend will replicate that behavior for consisntency.
|
||||
func WithMinerMinTip(tip *big.Int) func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||
if tip == nil || tip.Cmp(new(big.Int)) <= 0 {
|
||||
panic("invalid miner minimum tip")
|
||||
}
|
||||
return func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||
ethConf.Miner.GasPrice = tip
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user