diff --git a/cmd/evm/internal/t8ntool/transaction.go b/cmd/evm/internal/t8ntool/transaction.go index 28329e9611..4faca69cf7 100644 --- a/cmd/evm/internal/t8ntool/transaction.go +++ b/cmd/evm/internal/t8ntool/transaction.go @@ -133,8 +133,14 @@ func Transaction(ctx *cli.Context) error { r.Address = sender } // Check intrinsic gas + value, overflow := uint256.FromBig(tx.Value()) + if overflow { + // A 256-bit overflow is reported by the field validation below; use a + // non-zero placeholder so intrinsic gas is still computed and reported. + value = uint256.NewInt(1) + } rules := chainConfig.Rules(common.Big0, true, 0) - cost, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), r.Address, tx.To(), uint256.MustFromBig(tx.Value()), rules, params.CostPerStateByte) + cost, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), r.Address, tx.To(), value, rules, params.CostPerStateByte) if err != nil { r.Error = err results = append(results, r) diff --git a/core/txpool/validation.go b/core/txpool/validation.go index 404e350468..642b27570f 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -125,9 +125,14 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types if tx.Nonce()+1 < tx.Nonce() { return core.ErrNonceMax } + // Sanity check for extremely large numbers (supported by RLP or RPC) + value, overflow := uint256.FromBig(tx.Value()) + if overflow { + return core.ErrInsufficientFunds + } // Ensure the transaction has more gas than the bare minimum needed to cover // the transaction metadata - intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), from, tx.To(), uint256.MustFromBig(tx.Value()), rules, params.CostPerStateByte) + intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), from, tx.To(), value, rules, params.CostPerStateByte) if err != nil { return err } diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index 7cf2ac66cf..c87b6988ce 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -82,7 +82,11 @@ func (tt *TransactionTest) Run() error { return } // Intrinsic cost - cost, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), sender, tx.To(), uint256.MustFromBig(tx.Value()), rules, params.CostPerStateByte) + value, overflow := uint256.FromBig(tx.Value()) + if overflow { + return sender, hash, 0, errors.New("value exceeds 256 bits") + } + cost, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), sender, tx.To(), value, rules, params.CostPerStateByte) if err != nil { return }