Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EC-302] Adding maximum gasLimit validation #301

Merged
merged 6 commits into from
Sep 14, 2017

Conversation

KonradStaniec
Copy link
Contributor

Validating that block header gas limit is lower than 2**63-1

@rtkaczyk
Copy link
Contributor

rtkaczyk commented Sep 7, 2017

Could we add a unit test for this?

val gasLimitDiffLimit = parentHeader.gasLimit / GasLimitBoundDivisor
if(gasLimitDiff < gasLimitDiffLimit && blockHeader.gasLimit >= MinGasLimit) Right(blockHeader)
else Left(HeaderGasLimitError)
if(blockHeader.gasLimit > MaxGasLimit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: space after if

else {
val gasLimitDiff = (blockHeader.gasLimit - parentHeader.gasLimit).abs
val gasLimitDiffLimit = parentHeader.gasLimit / GasLimitBoundDivisor
if(gasLimitDiff < gasLimitDiffLimit && blockHeader.gasLimit >= MinGasLimit) Right(blockHeader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: space after if

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more concise to just extend this conditional with MaxGasLimit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to calculate unnecessary gasLimitDiff and gasLimitDiffLimit, but this is probably such small thing that for me both versions are ok

@ntallar
Copy link

ntallar commented Sep 8, 2017

Code LGTM!
Do you know if Geth/Parity implement this EIP or if it is implemented in Ethereum Classic? I know it's needed for passing the tests but I wasn't able to find any information on when it was accepted and included into ETH/ETC.

@KonradStaniec
Copy link
Contributor Author

Copy link
Contributor

@rtkaczyk rtkaczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nico raises a very good point. This is about ETC vs ETH. The geth code you've referred to is for ETH. We need to find out whether ETC clients also implement this. For geth try this repo: https://github.com/ethereumproject/go-ethereum

(I'm not requesting changes, I'm requesting more investigation; can't seem to be able to dismiss own review anymore)

@KonradStaniec
Copy link
Contributor Author

After research added a possibility to configure eip106 block number similar way to parity. If the eip106-block-number is not defined, it will have default value Long.maxValue so basically it will be unused.

@@ -280,6 +281,8 @@ object BlockchainConfig {
}

override val monetaryPolicyConfig = MonetaryPolicyConfig(blockchainConfig.getConfig("monetary-policy"))

override val eip106BlockNumber: BigInt = Try(blockchainConfig.getString("eip106-block-number")).map(BigInt(_)).getOrElse(Long.MaxValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather avoid optional settings in the config. Can we make this required and use high values for disabling? Just like other clients do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually parity uses optional values https://github.com/paritytech/parity/blob/246b5282e546333c086b2e725de024fdfab0b8d9/json/src/spec/ethash.rs#L101, but ok that way we will be consistent with our other configuration values.

@rtkaczyk
Copy link
Contributor

Please copy the new setting (commented out) with doc to src/universal/conf/blockchain.conf. Those files serve as config documentation for the users.

@KonradStaniec KonradStaniec force-pushed the feature/EIP106_MaxGasLimitValidation branch from 29b92ea to 6739aea Compare September 14, 2017 10:18
@KonradStaniec KonradStaniec merged commit f7935f8 into phase/daedalus Sep 14, 2017
@KonradStaniec KonradStaniec deleted the feature/EIP106_MaxGasLimitValidation branch September 14, 2017 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants