mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/vm: set basefee to 0 internally on eth_call
This commit is contained in:
parent
e91cdb49be
commit
849c0d4a40
2 changed files with 44 additions and 2 deletions
|
|
@ -215,8 +215,12 @@ func opTstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
|||
|
||||
// opBaseFee implements BASEFEE opcode
|
||||
func opBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||
if interpreter.evm.Config.NoBaseFee {
|
||||
scope.Stack.push(new(uint256.Int))
|
||||
} else {
|
||||
baseFee, _ := uint256.FromBig(interpreter.evm.Context.BaseFee)
|
||||
scope.Stack.push(baseFee)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -678,6 +678,44 @@ func TestEstimateGas(t *testing.T) {
|
|||
},
|
||||
expectErr: core.ErrInsufficientFunds,
|
||||
},
|
||||
// Test for a bug where the gas price was set to zero but the basefee non-zero
|
||||
//
|
||||
// contract Tipper {
|
||||
// constructor() {
|
||||
// tx.gasprice - block.basefee;
|
||||
// }
|
||||
// }
|
||||
{
|
||||
blockNumber: rpc.LatestBlockNumber,
|
||||
call: TransactionArgs{
|
||||
From: &accounts[0].addr,
|
||||
Input: hex2Bytes("6080604052348015600f57600080fd5b50483a601a91906058565b506085565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000606182601f565b9150606a83601f565b9250828203905081811115607f57607e6029565b5b92915050565b603f8060926000396000f3fe6080604052600080fdfea2646970667358221220389a4956b32bb784f6afd2e9db61cef06edaed0e2609234a291e7830e025853364736f6c63430008160033"),
|
||||
GasPrice: (*hexutil.Big)(big.NewInt(1_000_000_000)), // Legacy as pricing
|
||||
},
|
||||
expectErr: nil,
|
||||
want: 68757,
|
||||
},
|
||||
{
|
||||
blockNumber: rpc.LatestBlockNumber,
|
||||
call: TransactionArgs{
|
||||
From: &accounts[0].addr,
|
||||
Input: hex2Bytes("6080604052348015600f57600080fd5b50483a601a91906058565b506085565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000606182601f565b9150606a83601f565b9250828203905081811115607f57607e6029565b5b92915050565b603f8060926000396000f3fe6080604052600080fdfea2646970667358221220389a4956b32bb784f6afd2e9db61cef06edaed0e2609234a291e7830e025853364736f6c63430008160033"),
|
||||
MaxFeePerGas: (*hexutil.Big)(big.NewInt(1_000_000_000)), // 1559 gas pricing
|
||||
},
|
||||
expectErr: nil,
|
||||
want: 68757,
|
||||
},
|
||||
{
|
||||
blockNumber: rpc.LatestBlockNumber,
|
||||
call: TransactionArgs{
|
||||
From: &accounts[0].addr,
|
||||
Input: hex2Bytes("6080604052348015600f57600080fd5b50483a601a91906058565b506085565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000606182601f565b9150606a83601f565b9250828203905081811115607f57607e6029565b5b92915050565b603f8060926000396000f3fe6080604052600080fdfea2646970667358221220389a4956b32bb784f6afd2e9db61cef06edaed0e2609234a291e7830e025853364736f6c63430008160033"),
|
||||
GasPrice: nil, // No legacy gas pricing
|
||||
MaxFeePerGas: nil, // No 1559 gas pricing
|
||||
},
|
||||
expectErr: nil,
|
||||
want: 68757,
|
||||
},
|
||||
}
|
||||
for i, tc := range testSuite {
|
||||
result, err := api.EstimateGas(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides)
|
||||
|
|
|
|||
Loading…
Reference in a new issue