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

Feature/etcm 354/forkid #1018

Merged
merged 8 commits into from
Jun 22, 2021
Merged

Feature/etcm 354/forkid #1018

merged 8 commits into from
Jun 22, 2021

Conversation

lukasz-golebiewski
Copy link
Contributor

Description

First part of https://eips.ethereum.org/EIPS/eip-2124
Adds the ForkId calculation and it's RLP encoding

@lukasz-golebiewski lukasz-golebiewski force-pushed the feature/etcm-354/forkid branch 2 times, most recently from d6daa34 to 06a87e1 Compare June 18, 2021 12:30
@dzajkowski
Copy link
Contributor

were the geth test of any use? https://github.com/etclabscore/core-geth/blob/master/core/forkid/forkid_test.go#L132-L169


def gatherForks(config: BlockchainConfig): List[BigInt] =
(config.daoForkConfig.map(_.forkBlockNumber).toList ++
config.forkBlockNumbers.productIterator.toList.flatMap {
Copy link
Contributor

Choose a reason for hiding this comment

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

this assumes the order of fields in config case classes, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The list is being sorted at the very end

Copy link
Contributor

Choose a reason for hiding this comment

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

I would put that part with the productIterator inside ForkBlockNumbers directly. Even though it seem reasonable that every BigInt there will be a fork block number we never really know. If we put this function inside ForkBlockNumbers we make this assumption more explicit for devs modifying the case class.

If we want to avoid any logic in the config part, we could add a comment in ForkBlockNumbers which explain that every BigInt there must be a fork block number.

What do you think ?

@lukasz-golebiewski lukasz-golebiewski force-pushed the feature/etcm-354/forkid branch 5 times, most recently from e74e555 to 6b2d9d9 Compare June 21, 2021 11:40
}
case default => None
})
.filterNot(v => v == 0 || v == noFork)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get why we filter out noFork. It does not seem to be used somewhere else

Copy link
Contributor Author

@lukasz-golebiewski lukasz-golebiewski Jun 22, 2021

Choose a reason for hiding this comment

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

The same configuration structure BlockchainConfig is re-used for multiple chains. Forks which shouldn't occur in a given chain are configured to happen at block height "1000000000000000000" which is equivalent to "never". We don't want those fork numbers on our fork id list


def gatherForks(config: BlockchainConfig): List[BigInt] =
(config.daoForkConfig.map(_.forkBlockNumber).toList ++
config.forkBlockNumbers.productIterator.toList.flatMap {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put that part with the productIterator inside ForkBlockNumbers directly. Even though it seem reasonable that every BigInt there will be a fork block number we never really know. If we put this function inside ForkBlockNumbers we make this assumption more explicit for devs modifying the case class.

If we want to avoid any logic in the config part, we could add a comment in ForkBlockNumbers which explain that every BigInt there must be a fork block number.

What do you think ?

@lukasz-golebiewski lukasz-golebiewski merged commit 176884a into develop Jun 22, 2021
@lukasz-golebiewski lukasz-golebiewski deleted the feature/etcm-354/forkid branch June 22, 2021 09:04
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