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 - 4844 #5536

Closed
wants to merge 149 commits into from
Closed

EIP - 4844 #5536

wants to merge 149 commits into from

Conversation

jflo
Copy link
Contributor

@jflo jflo commented Jun 5, 2023

Implements EIP-4844.

  • introduces a Hardfork class to the protocol schedule system
  • new Engine APIs required for CL to work on 4844
  • new DataGas type for tracking block cost for 4844 data
  • new VersionedHash type to reflect that a versioned hash is not quite a pure sha256
  • incorporates wrapped jc-kzg library for KZG point evaluations
  • New transaction type, and domain objects for constituent parts to represent the Blobs, KZGCommitments, and Proofs used for 4844
  • RLP encoders and decoders to support new transaction type
  • gas pricing calculators for the new type of gas
  • plugin-api version was changed

@github-actions
Copy link

github-actions bot commented Jun 5, 2023

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.
  • I thought about the changelog and included a changelog update if required.
  • If my PR includes database changes (e.g. KeyValueSegmentIdentifier) I have thought about compatibility and performed forwards and backwards compatibility tests

Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

got 1/3 through! can we remove the ssz tuweni snapshot lib?

ethereum/core/build.gradle Outdated Show resolved Hide resolved
ethereum/core/libs/tuweni-ssz-2.4.0-SNAPSHOT.jar Outdated Show resolved Hide resolved
Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

some more comments :)

@@ -24,7 +24,7 @@

@JsonCreator
public UnsignedLongParameter(final String value) {
this.value = Long.decode(value);
this.value = value != null ? Long.decode(value) : 0;

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
@@ -188,6 +189,7 @@
Hash.fromHexString(mixHash), // mixHash
Bytes.fromHexStringLenient(nonce).toLong(),
withdrawalsRoot != null ? Hash.fromHexString(withdrawalsRoot) : null,
dataGasUsed != null ? Long.parseLong(dataGasUsed) : 0,

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
@jflo jflo force-pushed the 4844-devnet-5b branch 3 times, most recently from 5e2098f to 51d9ae5 Compare June 16, 2023 20:35
@jflo jflo marked this pull request as ready for review June 16, 2023 21:08
Copy link
Contributor

@shemnon shemnon left a comment

Choose a reason for hiding this comment

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

Most of my comments are nits and non blockers, except the bit about VersionedHash I think we need to make it type in the datatypes module and ensure we consistently use it instead of a mix of Hash and Bytes32.

@jflo jflo requested a review from shemnon June 29, 2023 19:51
@shemnon shemnon dismissed their stale review June 29, 2023 21:14

Issues resolved

@shemnon
Copy link
Contributor

shemnon commented Jun 29, 2023

I've reviewed datatypes, evm, plugin, and build code and I am satisfied. However I have not reviewed any of the code in besu, acceptance-tests, consensus, or ethereum directories as I expect other maintainers are better positioned to review those. Ping me next week if I still need to review those directories.

I would tag this as "approved" however that alone would clear it for merge when I feel other areas need different eye, so I'll hold off.

siladu
siladu previously requested changes Jul 4, 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.

Reviewed acceptance-tests, consensus and part of engine API so far.

Requesting changes due to what I believe is a ZeroBaseFeeMarket bug

Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

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

in progress 52/155, please check my comments

jflo and others added 26 commits July 19, 2023 16:08
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…5663)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
* Swap parameters order

* Remove method

* Move blob validation to EngineNewPayloadV3 class

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
* fix for genesis mismatch

Signed-off-by: spencer-tb <spencer@spencertaylorbrown.uk>

* Fix tests and spotless

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

---------

Signed-off-by: spencer-tb <spencer@spencertaylorbrown.uk>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Co-authored-by: spencer-tb <spencer@spencertaylorbrown.uk>
* [4844] Fix Data Gas Price Calculation (#1)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

* Fix spotless

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

* Fix mock unit tests

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

---------

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…adV3 (#5683)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…leContractResult (#5691)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
…ams for invalid versionedHash version (#5690)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

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

another pass


LOG.atTrace()
.setMessage("blockparam: {}")
.addArgument(() -> Json.encodePrettily(blockParam))
.log();

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

is this required? if yes could you add a comment to explain

@@ -172,7 +198,10 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
blockParam.getPrevRandao(),
0,
maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null),
null,
blockParam.getDataGasUsed() == null ? null : blockParam.getDataGasUsed(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
blockParam.getDataGasUsed() == null ? null : blockParam.getDataGasUsed(),
blockParam.getDataGasUsed(),

final EngineCallListener engineCallListener,
final ProtocolSchedule schedule) {
super(vertx, protocolContext, mergeMiningCoordinator, blockResultFactory, engineCallListener);
this.shanghai = schedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("Shanghai"));
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to use enums instead of strings here?

@@ -169,10 +171,10 @@ protected BlockCreationResult createBlock(
createPendingBlockHeader(timestamp, maybePrevRandao, newProtocolSpec);
final Address miningBeneficiary =
miningBeneficiaryCalculator.getMiningBeneficiary(processableBlockHeader.getNumber());
final Wei dataGasPrice =
Wei dataGasPrice =
Copy link
Contributor

Choose a reason for hiding this comment

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

why no more final?

@@ -228,11 +230,11 @@ protected BlockCreationResult createBlock(

throwIfStopped();

final DataGas newExcessDataGas = computeExcessDataGas(transactionResults, newProtocolSpec);
final GasUsage usage = computeExcessDataGas(transactionResults, newProtocolSpec);
Copy link
Contributor

Choose a reason for hiding this comment

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

usage is quire generic here, perhaps rename to dataGasUsage?

@@ -280,8 +285,11 @@ List<Deposit> findDepositsFromReceipts(final TransactionSelectionResults transac
.toList();
}

private DataGas computeExcessDataGas(
TransactionSelectionResults transactionResults, ProtocolSpec newProtocolSpec) {
record GasUsage(DataGas excessDataGas, DataGas used) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to DataGasUsage?

@jflo
Copy link
Contributor Author

jflo commented Jul 26, 2023

this work has been ported to https://github.com/jflo/besu/tree/EIP-4844 and already merged into main via #5724

Thanks to all who contributed comments!

@jflo jflo closed this Jul 26, 2023
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.

9 participants