forked from relayooor/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge changes from validation (ethereum#4)
* Implement block validation API * Validate proposer payment assuming its the last transaction in the block (ethereum#4) * Validate that the coinbase and feeRecipient are not blacklisted (ethereum#5) * Validate that the proposer payment has no calldata and its gas usage (ethereum#6) * Validate gas limit is set correctly wrt registered (ethereum#8) * Pass validation-specific config (ethereum#9)
- Loading branch information
Showing
10 changed files
with
109 additions
and
55 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
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,29 @@ | ||
package utils | ||
|
||
import "github.com/ethereum/go-ethereum/params" | ||
|
||
// CalcGasLimit computes the gas limit of the next block after parent. It aims | ||
// to keep the baseline gas close to the provided target, and increase it towards | ||
// the target if the baseline gas is lower. | ||
func CalcGasLimit(parentGasLimit, desiredLimit uint64) uint64 { | ||
delta := parentGasLimit/params.GasLimitBoundDivisor - 1 | ||
limit := parentGasLimit | ||
if desiredLimit < params.MinGasLimit { | ||
desiredLimit = params.MinGasLimit | ||
} | ||
// If we're outside our allowed gas range, we try to hone towards them | ||
if limit < desiredLimit { | ||
limit = parentGasLimit + delta | ||
if limit > desiredLimit { | ||
limit = desiredLimit | ||
} | ||
return limit | ||
} | ||
if limit > desiredLimit { | ||
limit = parentGasLimit - delta | ||
if limit < desiredLimit { | ||
limit = desiredLimit | ||
} | ||
} | ||
return limit | ||
} |
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
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