mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Clean up sanitizeCall
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
This commit is contained in:
parent
73ff7e51f6
commit
5d8c058fd4
2 changed files with 6 additions and 9 deletions
|
|
@ -264,18 +264,15 @@ func (sim *simulator) sanitizeCall(call *TransactionArgs, state *state.StateDB,
|
|||
nonce := state.GetNonce(call.from())
|
||||
call.Nonce = (*hexutil.Uint64)(&nonce)
|
||||
}
|
||||
var gas uint64
|
||||
if call.Gas != nil {
|
||||
gas = uint64(*call.Gas)
|
||||
}
|
||||
if *gasUsed+gas > blockContext.GasLimit {
|
||||
return &blockGasLimitReachedError{fmt.Sprintf("block gas limit reached: %d >= %d", gasUsed, blockContext.GasLimit)}
|
||||
}
|
||||
// Let the call run wild unless explicitly specified.
|
||||
if call.Gas == nil {
|
||||
remaining := blockContext.GasLimit - *gasUsed
|
||||
call.Gas = (*hexutil.Uint64)(&remaining)
|
||||
}
|
||||
if *gasUsed+uint64(*call.Gas) > blockContext.GasLimit {
|
||||
return &blockGasLimitReachedError{fmt.Sprintf("block gas limit reached: %d >= %d", gasUsed, blockContext.GasLimit)}
|
||||
}
|
||||
|
||||
if err := call.CallDefaults(sim.gp.Gas(), header.BaseFee, sim.chainConfig.ChainID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ func TestSimulateSanitizeBlockOrder(t *testing.T) {
|
|||
if b.BlockOverrides.Time == nil {
|
||||
t.Fatalf("testcase %d: block time not set", i)
|
||||
}
|
||||
if (uint64)(*b.BlockOverrides.Time) != tc.expected[bi].timestamp {
|
||||
t.Errorf("testcase %d: block timestamp mismatch. Want %d, have %d", i, tc.expected[bi].timestamp, (uint64)(*b.BlockOverrides.Time))
|
||||
if uint64(*b.BlockOverrides.Time) != tc.expected[bi].timestamp {
|
||||
t.Errorf("testcase %d: block timestamp mismatch. Want %d, have %d", i, tc.expected[bi].timestamp, uint64(*b.BlockOverrides.Time))
|
||||
}
|
||||
have := b.BlockOverrides.Number.ToInt().Uint64()
|
||||
if have != tc.expected[bi].number {
|
||||
|
|
|
|||
Loading…
Reference in a new issue