Skip to content

Commit

Permalink
Added MAX_EXECUTION_LAYER_EXITS preset (EIP-7002) (Consensys#8109)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucassaldanha authored Mar 19, 2024
1 parent a261625 commit 5221963
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static SpecConfigElectra required(final SpecConfig specConfig) {

int getMaxDepositReceiptsPerPayload();

int getMaxExecutionLayerExits();

@Override
Optional<SpecConfigElectra> toVersionElectra();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ public class SpecConfigElectraImpl extends DelegatingSpecConfigDeneb implements
private final UInt64 electraForkEpoch;

private final int maxDepositReceiptsPerPayload;
private final int maxExecutionLayerExits;

public SpecConfigElectraImpl(
final SpecConfigDeneb specConfig,
final Bytes4 electraForkVersion,
final UInt64 electraForkEpoch,
final int maxDepositReceiptsPerPayload) {
final int maxDepositReceiptsPerPayload,
final int maxExecutionLayerExits) {
super(specConfig);
this.electraForkVersion = electraForkVersion;
this.electraForkEpoch = electraForkEpoch;
this.maxDepositReceiptsPerPayload = maxDepositReceiptsPerPayload;
this.maxExecutionLayerExits = maxExecutionLayerExits;
}

@Override
Expand All @@ -51,6 +54,11 @@ public int getMaxDepositReceiptsPerPayload() {
return maxDepositReceiptsPerPayload;
}

@Override
public int getMaxExecutionLayerExits() {
return maxExecutionLayerExits;
}

@Override
public Optional<SpecConfigElectra> toVersionElectra() {
return Optional.of(this);
Expand All @@ -68,12 +76,17 @@ public boolean equals(final Object o) {
return Objects.equals(specConfig, that.specConfig)
&& Objects.equals(electraForkVersion, that.electraForkVersion)
&& Objects.equals(electraForkEpoch, that.electraForkEpoch)
&& maxDepositReceiptsPerPayload == that.maxDepositReceiptsPerPayload;
&& maxDepositReceiptsPerPayload == that.maxDepositReceiptsPerPayload
&& maxExecutionLayerExits == that.maxExecutionLayerExits;
}

@Override
public int hashCode() {
return Objects.hash(
specConfig, electraForkVersion, electraForkEpoch, maxDepositReceiptsPerPayload);
specConfig,
electraForkVersion,
electraForkEpoch,
maxDepositReceiptsPerPayload,
maxExecutionLayerExits);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ public class ElectraBuilder implements ForkConfigBuilder<SpecConfigDeneb, SpecCo

private Bytes4 electraForkVersion;
private UInt64 electraForkEpoch;

private Integer maxDepositReceiptsPerPayload;
private Integer maxExecutionLayerExits;

ElectraBuilder() {}

@Override
public SpecConfigElectra build(final SpecConfigDeneb specConfig) {
return new SpecConfigElectraImpl(
specConfig, electraForkVersion, electraForkEpoch, maxDepositReceiptsPerPayload);
specConfig,
electraForkVersion,
electraForkEpoch,
maxDepositReceiptsPerPayload,
maxExecutionLayerExits);
}

public ElectraBuilder electraForkEpoch(final UInt64 electraForkEpoch) {
Expand All @@ -59,6 +63,12 @@ public ElectraBuilder maxDepositReceiptsPerPayload(final Integer maxDepositRecei
return this;
}

public ElectraBuilder maxExecutionLayerExits(final Integer maxExecutionLayerExits) {
checkNotNull(maxExecutionLayerExits);
this.maxExecutionLayerExits = maxExecutionLayerExits;
return this;
}

@Override
public void validate() {
if (electraForkEpoch == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Mainnet preset - Electra

# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16)
MAX_EXECUTION_LAYER_EXITS: 16

# Execution
# ---------------------------------------------------------------
# 2**13 (= 8192) receipts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Minimal preset - Electra

# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16)
MAX_EXECUTION_LAYER_EXITS: 16

# Execution
# ---------------------------------------------------------------
# [customized]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Minimal preset - Electra

# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16)
MAX_EXECUTION_LAYER_EXITS: 16

# Execution
# ---------------------------------------------------------------
# [customized]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private SpecConfigElectra createRandomElectraConfig(
return new SpecConfigElectraImpl(
denebConfig,
dataStructureUtil.randomBytes4(),
dataStructureUtil.randomUInt64(),
dataStructureUtil.randomPositiveInt()) {};
dataStructureUtil.randomUInt64(999_999),
dataStructureUtil.randomPositiveInt(16),
dataStructureUtil.randomPositiveInt(16)) {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ public int randomPositiveInt() {
return randomInt(Integer.MAX_VALUE);
}

public int randomPositiveInt(final int bound) {
return new Random(nextSeed()).ints(0, bound).findFirst().orElse(0);
}

public byte randomByte() {
final byte[] bytes = new byte[1];
new Random(nextSeed()).nextBytes(bytes);
Expand Down

0 comments on commit 5221963

Please sign in to comment.