mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Merge pull request #20 from flashbots/fix/port-upstream-29023
core/vm, params: ensure order of forks, prevent overflow
This commit is contained in:
commit
389d537304
3 changed files with 13 additions and 6 deletions
|
|
@ -187,7 +187,12 @@ func makeCallVariantGasCallEIP2929(oldCalculator gasFunc) gasFunc {
|
|||
// outside of this function, as part of the dynamic gas, and that will make it
|
||||
// also become correctly reported to tracers.
|
||||
contract.Gas += coldCost
|
||||
return gas + coldCost, nil
|
||||
|
||||
var overflow bool
|
||||
if gas, overflow = math.SafeAdd(gas, coldCost); overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
return gas, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1459,6 +1459,7 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
|
|||
tx *types.Transaction
|
||||
err error
|
||||
)
|
||||
b.SetPoS()
|
||||
switch i {
|
||||
case 0:
|
||||
// transfer 1000wei
|
||||
|
|
@ -1507,7 +1508,6 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
|
|||
b.AddTx(tx)
|
||||
txHashes[i] = tx.Hash()
|
||||
}
|
||||
b.SetPoS()
|
||||
})
|
||||
return backend, txHashes
|
||||
}
|
||||
|
|
|
|||
|
|
@ -859,6 +859,8 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
|
|||
if chainID == nil {
|
||||
chainID = new(big.Int)
|
||||
}
|
||||
// disallow setting Merge out of order
|
||||
isMerge = isMerge && c.IsLondon(num)
|
||||
return Rules{
|
||||
ChainID: new(big.Int).Set(chainID),
|
||||
IsHomestead: c.IsHomestead(num),
|
||||
|
|
@ -872,9 +874,9 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
|
|||
IsBerlin: c.IsBerlin(num),
|
||||
IsLondon: c.IsLondon(num),
|
||||
IsMerge: isMerge,
|
||||
IsShanghai: c.IsShanghai(num, timestamp),
|
||||
IsCancun: c.IsCancun(num, timestamp),
|
||||
IsPrague: c.IsPrague(num, timestamp),
|
||||
IsVerkle: c.IsVerkle(num, timestamp),
|
||||
IsShanghai: isMerge && c.IsShanghai(num, timestamp),
|
||||
IsCancun: isMerge && c.IsCancun(num, timestamp),
|
||||
IsPrague: isMerge && c.IsPrague(num, timestamp),
|
||||
IsVerkle: isMerge && c.IsVerkle(num, timestamp),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue