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

EIP-6110: Add deposit validation and apis #5295

Merged
merged 47 commits into from
Jun 21, 2023
Merged

Conversation

ensi321
Copy link
Contributor

@ensi321 ensi321 commented Apr 3, 2023

PR description

This PR is the continuation of #5055. It is the final PR for EIP-6110. The following are the main features introduced:

  • Decode and extract deposit from transaction receipt log
  • Introduce depositContractAddress field in genesis file
  • Validate deposits in a block against the transaction receipt logs
  • Update engine_newPayloadV2 and engine_getPayloadV2 according to the spec. Some of the non-functional components were partially implemented in the previous PR

Fixed Issue(s)

#5004

Testing

  • Local block production pre-V6110
  • Public testnet sync
  • Public mainnet sync

Signed-off-by: Navie Chan <[email protected]>
@github-actions
Copy link

github-actions bot commented Apr 3, 2023

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.
  • I have considered running ./gradlew acceptanceTestNonMainnet locally if my PR affects non-mainnet modules.
  • I thought about the changelog and included a changelog update if required.

Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: navie <[email protected]>
@siladu siladu added TeamGroot GH issues worked on by Groot Team mainnet EIP Ethereum Improvement Proposal labels Apr 5, 2023
Copy link
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

Did a first pass looks pretty straight forward to me. The deposit parsing and validation is simple and easy to understand. Some initial comments, mostly naming.

Next pass I will review against the EIP and execution-api spec in more detail.

@ensi321 ensi321 marked this pull request as ready for review April 11, 2023 10:40
@ahamlat
Copy link
Contributor

ahamlat commented Apr 21, 2023

To accurately gauge the impact of this PR on Besu's performance, particularly regarding block processing, the most effective approach is to deploy it on a dedicated environment with real data. It's preferable to use an environment with many deposits, and then profile the node to observe any impact on performance. In the meantime, I've identified two pertinent methods to assess performance by conducting microbenchmarking with JMH

  • DepositDecoder.decodeFromLog
  • BodyValidation.depositRoots

During block processing, both methods are invoked, with DepositDecoder.decodeFromLog being called iteratively within a loop that depends on the quantity of receipts and logs per receipt present in the block

Block processing

AbstractEngineNewPayload.syncResponse
        BodyValidation.depositsRoot
	MergeCoodinator.rememberBlock
		MergeCoodinator.validateBlock
			MainnetBlockValidator.validateAndProcessBlock
				MainnetBlockValidator.validateAndProcessBlock
					MainnetBlockBodyValidator.validateBodyLight
						AllowedDeposits.validateDeposits
							DepositDecoder.decodeFromLog (called several times)
						AllowedDeposits.validateDepositsRoot
							BodyValidation.depositsRoot	

Block creation

AbstractBlockCreator.createBlock
	BodyValidation.depositsRoot
	DepositDecoder.decodeFromLog (called several times)

The microbenchmarking of both methods (Keccak256 was added to enable a comparison point)

Benchmark                                     Mode  Cnt       Score      Error  Units
DepositDecoder.decodeFromLogBenchmark         avgt  100   12261.105 ±   80.786  ns/op
DepositDecoder.keccakk256Benchmark            avgt  100     306.937 ±    0.377  ns/op
BodyValidation.depositsRootBenchmark          avgt  100  238915.938 ± 4451.589  ns/op

If I'm not wrong, BodyValidation.depositRoots is called twice during block processing, and it takes 1/4 ms to execute, I think we can save one execution but even with both executions, the overhead is acceptable.

DepositDecoder.decodeFromLog overhead will depends on the number of receipts per block and the number of logs per receipt. If there're for example 1000 logs to process, this represents 13 ms overhead for block processing and block creation.

I started also a node on mainnet with PR to test against main on current fork (previous commit of this PR 795b7c4), I don't see any performance regression on block processing or FCU
image

From what I gathered, I don't see a blocker to merge this PR in termes of performance

@siladu
Copy link
Contributor

siladu commented Apr 21, 2023

I've started a regression test, fresh X_CHECKPOINT sync of 3 BONSAI nodes: sepolia, goerli, mainnet.

@siladu
Copy link
Contributor

siladu commented Apr 26, 2023

I've started a regression test, fresh X_CHECKPOINT sync of 3 BONSAI nodes: sepolia, goerli, mainnet.

This has passed regression: all nodes got in sync and have stayed in sync. No errors in the logs.

Copy link
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

Looking very close now!
Couple of minor things, main one is a potentially missing depositContractAddress filter.

Also can you add a changelog entry please :)

Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Navie Chan <[email protected]>
ensi321 and others added 13 commits May 16, 2023 10:56
Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Navie Chan <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
Remove unnecessary Spy annotations that were causing issues with the test setup code.

Tidy up NPE

Signed-off-by: Simon Dudley <[email protected]>
Extract findDepositsFromReceipts for testability

Signed-off-by: Simon Dudley <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
@siladu
Copy link
Contributor

siladu commented Jun 18, 2023

Reran some regression tests (deposits disabled) on latest changes with a local interop and sepolia sync ✅
Think this is ready to merge if @jframe is happy with latest changes.

@jframe
Copy link
Contributor

jframe commented Jun 19, 2023

Reran some regression tests (deposits disabled) on latest changes with a local interop and sepolia sync ✅ Think this is ready to merge if @jframe is happy with latest changes.

Looks fine to me

@siladu
Copy link
Contributor

siladu commented Jun 19, 2023

Thanks @jframe. I will hold off merging until we are sure main branch is clear: there are some issues on main found during the 23.4.2 soak.

@siladu siladu merged commit 0ceeaf3 into hyperledger:main Jun 21, 2023
davidkngo pushed a commit to liquichain/besu that referenced this pull request Jun 28, 2023
Completes the implementation of EIP-6110

* Decode and extract deposit from transaction receipt log
* Introduce depositContractAddress field in genesis file
* Validate deposits in a block against the transaction receipt logs
* Update engine_newPayloadV2 and engine_getPayloadV2 according to the spec. Some of the non-functional components were partially implemented in the previous PR

Signed-off-by: naviechan <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
Co-authored-by: Simon Dudley <[email protected]>
davidkngo pushed a commit to liquichain/besu that referenced this pull request Jul 21, 2023
Completes the implementation of EIP-6110

* Decode and extract deposit from transaction receipt log
* Introduce depositContractAddress field in genesis file
* Validate deposits in a block against the transaction receipt logs
* Update engine_newPayloadV2 and engine_getPayloadV2 according to the spec. Some of the non-functional components were partially implemented in the previous PR

Signed-off-by: naviechan <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
Co-authored-by: Simon Dudley <[email protected]>
davidkngo added a commit to liquichain/besu that referenced this pull request Jul 21, 2023
@ensi321 ensi321 deleted the eip-6110 branch July 28, 2023 03:25
elenduuche pushed a commit to elenduuche/besu that referenced this pull request Aug 16, 2023
Completes the implementation of EIP-6110

* Decode and extract deposit from transaction receipt log
* Introduce depositContractAddress field in genesis file
* Validate deposits in a block against the transaction receipt logs
* Update engine_newPayloadV2 and engine_getPayloadV2 according to the spec. Some of the non-functional components were partially implemented in the previous PR

Signed-off-by: naviechan <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
Co-authored-by: Simon Dudley <[email protected]>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
Completes the implementation of EIP-6110

* Decode and extract deposit from transaction receipt log
* Introduce depositContractAddress field in genesis file
* Validate deposits in a block against the transaction receipt logs
* Update engine_newPayloadV2 and engine_getPayloadV2 according to the spec. Some of the non-functional components were partially implemented in the previous PR

Signed-off-by: naviechan <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
Co-authored-by: Simon Dudley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EIP Ethereum Improvement Proposal mainnet TeamGroot GH issues worked on by Groot Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants