-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Ensures that for mainnet, alfajores and baklava, nodes will return the correct block gas limit up to the gingerbread fork even if they are not archive nodes when running in eth compatibility mode (I.E. --disablerpcethcompatibility is not set). More detail can be found here: #2214 Also includes a small re-factor of GetBlockByNumber and GetBlockByHash to reduce the depth of nesting. This change is not backwards compatible since it is changing what is returned by the rpc for historical blocks.
- Loading branch information
Showing
3 changed files
with
116 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package params | ||
|
||
import "math/big" | ||
|
||
type GasLimits struct { | ||
// changes holds all gas limit changes, it is assumed that the first change ocurrs at block 0. | ||
changes []LimitChange | ||
} | ||
|
||
type LimitChange struct { | ||
block *big.Int | ||
gasLimit uint64 | ||
} | ||
|
||
func (g *GasLimits) Limit(block *big.Int) uint64 { | ||
// Grab the gas limit at block 0 | ||
curr := g.changes[0].gasLimit | ||
for _, c := range g.changes[1:] { | ||
if block.Cmp(c.block) < 0 { | ||
return curr | ||
} | ||
curr = c.gasLimit | ||
} | ||
return curr | ||
} |