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

Monorepo: Removal all TTD Logic from Libraries #3518

Merged
merged 28 commits into from
Aug 5, 2024

Conversation

holgerd77
Copy link
Member

@holgerd77 holgerd77 commented Jul 18, 2024

Too radical? 😂

Could anyone already give this a first look, removed all TTD stuff from Commoon, lots of tests falling off the roof, but I would say: so what?

(so Common would be just a first step, this would go up the libraries then)

Copy link

codecov bot commented Jul 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (fb50628) to head (394ae31).
Report is 17 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (fb50628) and HEAD (394ae31). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (fb50628) HEAD (394ae31)
tx 1 0
client 1 0
Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
client ?
tx ?
wallet 0.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Comment on lines 107 to 109
if (typeof vm.blockchain.getTotalDifficulty !== 'function') {
throw new Error('cannot get iterator head: blockchain has no getTotalDifficulty function')
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this check?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would find it nice if we are still able to at least run ethash blockchains, and this check might be necessary for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are probably right. On a related note: should this still work npm run client:start:ts -- --dev=pow?
image

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea about this dev flags

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

Some small-ish comments.

The mergeForkIdTransition: should we remove this? This is a special fork id, which specifically has to do with the PoW -> PoS transition logic which we essentially have removed here (see: https://eips.ethereum.org/EIPS/eip-3675#eip-2124-fork-identifier). Should we remove this hardfork as well? It has lead numerous times to confusion 😅 Since we don't support PoW -> PoS transition I think it is fine to remove it as well (can be done in a new PR)

Also side note: we will now thus fail any tests which have to do with PoW -> PoS transitions (there likely are not many, but there likely will be some in the ethereum/tests and in hive)

}),
'A base fee',
undefined,
'throws when RLP serialized block with no base fee on default hardfork (london) and setHardfork left undefined',
Copy link
Member

Choose a reason for hiding this comment

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

This test is removed but I don't think this has anything to do with TTD, so we should likely keep this in?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I interpret this test correctly, this is testing some weird half-defined case for the more-complex TD including setHardfork option (which we now removed).

So, now, with the surrounding test setup, both when we set setHardfork to true as well as false we are going the normal ways to a minimally-London common (common provided is initialized with London) and so this test setup should not throw in both cases (also re-tested this now).

That's why I removed the test case, should be not testing anything meaningful now.

packages/client/test/integration/merge.spec.backup.ts Outdated Show resolved Hide resolved
packages/common/src/common.ts Outdated Show resolved Hide resolved
packages/common/src/constructors.ts Outdated Show resolved Hide resolved
@@ -57,122 +55,24 @@ describe('[Utils/Parse]', () => {
assert.equal(params.genesis.timestamp, '0x10', 'timestamp parsed correctly')
})

it('should successfully parse kiln genesis and set forkhash', async () => {
const common = createCommonFromGethGenesis(gethGenesisKilnJSON, {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this one should be removed as well? Correctly setting the hardfork order? Maybe the mergeForkIdTransition should be removed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to re-add the two tests you mentioned, but I am getting a "Error parsing parameters file: nonzero terminal total difficulty is not supported" error now when trying to re-add the Kiln config file, so I guess this is not so easy to re-create in this setup.

I would generally pledge that there are more simple test setups for HF order as well as getHardforkBy() functionality and this is sufficiently tested in other places and we therefore shouldn't stick to this super-outdated Kiln setup (I was somewhat happy to throw the Kiln config out) and just throw it out here.

(side mention: guess nothing urgent to ad hoc re-add, but I do wonder if we would rather want to keep the "Geth config with post-Merge transition but a dedicated Merge HF block included" case (so this would also match what we keep in other places) instead of fully throwing this out. Guess THAT case also should not produce significant overhead and still migth be useful. Again, but in doubt we can "re-add on demand" I guess).


assert.equal(common.getHardforkBy({ blockNumber: 0n }), Hardfork.London, 'london at genesis')
assert.equal(
common.getHardforkBy({ blockNumber: 1n, td: 2n }),
Copy link
Member

Choose a reason for hiding this comment

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

Same for this test, we can remove all checks with have to do with td checks, but the getHardforkBy via either block or timestamp should still work.

Copy link
Member Author

Choose a reason for hiding this comment

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

See comment above

@holgerd77
Copy link
Member Author

holgerd77 commented Aug 5, 2024

Some small-ish comments.

The mergeForkIdTransition: should we remove this? This is a special fork id, which specifically has to do with the PoW -> PoS transition logic which we essentially have removed here (see: https://eips.ethereum.org/EIPS/eip-3675#eip-2124-fork-identifier). Should we remove this hardfork as well? It has lead numerous times to confusion 😅 Since we don't support PoW -> PoS transition I think it is fine to remove it as well (can be done in a new PR)

Let's be semantically precise here: we are only removing the Live transition from PoW -> PoS (at least that's my understanding from the basis of what we are doing and that's also what I would be suggesting), so that is this first-time transition where the fork block is not yet known and needs to be determined by TTD in a complicated manner.

We still do support a static transition (post Merge PIT, merge block known), and I personally would strongly pledge to keep it this way, since the remaining logic is easy to handle and not a substantial overhead and otherwise we would e.g. finally loose on a theoretical/practical mainnet full sync capability (still dreaming of this 😂).

For a static transition the mergeForkId HF is also needed, otherwise one would branch off with a missing mergeForkId HF during sync.

Ah, and while writing about it: the subsequent fork hashes would also be wrong, so we would loose the correct fork hash calculation (since in-between HFs are calculated in into newer ones). So we should definitely keep "as is" and live with some mild technical debt here (can remember a somewhat longer discussion/thread from Martin Holst Swende where he also complained about this, that this forkk would now be "in forever", but that's just how it is now. 🙂 )

Also side note: we will now thus fail any tests which have to do with PoW -> PoS transitions (there likely are not many, but there likely will be some in the ethereum/tests and in hive)

So, since ethereum/tests are passing here, this does not seem to be a problem at least for ethereum/tests (?).

Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

LGTM. Lets fix that bracket later.

@holgerd77 holgerd77 merged commit 3810f1d into master Aug 5, 2024
34 checks passed
@holgerd77 holgerd77 deleted the monorepo-remove-ttd-logic branch August 5, 2024 13:35
@jochem-brouwer
Copy link
Member

So, since ethereum/tests are passing here, this does not seem to be a problem at least for ethereum/tests (?).

@holgerd77 This is because we do not run certain forks on the CI, in this case that would be the fork which actually has the Merge transition. (Just like we don't run ethereum/tests for Chainstart for instance on the CI)

@holgerd77
Copy link
Member Author

@jochem-brouwer ah, ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants