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

feat: Adding Electra fork support #1020

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Next Release

### Features Added
- Java 21 for build and runtime. [#995](https://github.com/Consensys/web3signer/pull/995)
- Electra fork support. [#1020](https://github.com/Consensys/web3signer/pull/1020)

---
## 24.6.0

### Upcoming Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class SignerConfiguration {
private final Optional<Long> bellatrixForkEpoch;
private final Optional<Long> capellaForkEpoch;
private final Optional<Long> denebForkEpoch;
private final Optional<Long> electraForkEpoch;
private final Optional<String> network;
private final boolean keyManagerApiEnabled;
private Optional<WatermarkRepairParameters> watermarkRepairParameters;
Expand Down Expand Up @@ -119,6 +120,7 @@ public SignerConfiguration(
final Optional<Long> bellatrixForkEpoch,
final Optional<Long> capellaForkEpoch,
final Optional<Long> denebForkEpoch,
final Optional<Long> electraForkEpoch,
final Optional<String> network,
final boolean keyManagerApiEnabled,
final Optional<WatermarkRepairParameters> watermarkRepairParameters,
Expand Down Expand Up @@ -164,6 +166,7 @@ public SignerConfiguration(
this.bellatrixForkEpoch = bellatrixForkEpoch;
this.capellaForkEpoch = capellaForkEpoch;
this.denebForkEpoch = denebForkEpoch;
this.electraForkEpoch = electraForkEpoch;
this.network = network;
this.keyManagerApiEnabled = keyManagerApiEnabled;
this.watermarkRepairParameters = watermarkRepairParameters;
Expand Down Expand Up @@ -322,6 +325,10 @@ public Optional<Long> getDenebForkEpoch() {
return denebForkEpoch;
}

public Optional<Long> getElectraForkEpoch() {
return electraForkEpoch;
}

public Optional<String> getNetwork() {
return network;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class SignerConfigurationBuilder {
private Long bellatrixForkEpoch = null;
private Long capellaForkEpoch = null;
private Long denebForkEpoch = null;
private Long electraForkEpoch = null;
private String network = null;
private boolean keyManagerApiEnabled = false;
private KeystoresParameters keystoresParameters;
Expand Down Expand Up @@ -272,6 +273,11 @@ public SignerConfigurationBuilder withDenebForkEpoch(final long denebForkEpoch)
return this;
}

public SignerConfigurationBuilder withElectraForkEpoch(final long electraForkEpoch) {
this.electraForkEpoch = electraForkEpoch;
return this;
}

public SignerConfigurationBuilder withNetwork(final String network) {
this.network = network;
return this;
Expand Down Expand Up @@ -367,6 +373,7 @@ public SignerConfiguration build() {
Optional.ofNullable(bellatrixForkEpoch),
Optional.ofNullable(capellaForkEpoch),
Optional.ofNullable(denebForkEpoch),
Optional.ofNullable(electraForkEpoch),
Optional.ofNullable(network),
keyManagerApiEnabled,
Optional.ofNullable(watermarkRepairParameters),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,14 @@ private String createEth2SlashingProtectionArgs() {
signerConfig.getDenebForkEpoch().get()));
}

if (signerConfig.getElectraForkEpoch().isPresent()) {
yamlConfig.append(
String.format(
YAML_NUMERIC_FMT,
"eth2.Xnetwork-electra-fork-epoch",
signerConfig.getElectraForkEpoch().get()));
}

if (signerConfig.getNetwork().isPresent()) {
yamlConfig.append(
String.format(YAML_STRING_FMT, "eth2.network", signerConfig.getNetwork().get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ private Collection<String> createEth2Args() {
params.add(Long.toString(signerConfig.getDenebForkEpoch().get()));
}

if (signerConfig.getElectraForkEpoch().isPresent()) {
params.add("--Xnetwork-electra-fork-epoch");
params.add(Long.toString(signerConfig.getElectraForkEpoch().get()));
}

if (signerConfig.getNetwork().isPresent()) {
params.add("--network");
params.add(signerConfig.getNetwork().get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ private ExecutionPayload randomExecutionPayload(final SpecVersion specVersion) {
.transactions(util.randomExecutionPayloadTransactions())
.withdrawals(() -> randomExecutionPayloadWithdrawals(specVersion))
.excessBlobGas(util::randomUInt64)
.blobGasUsed(util::randomUInt64));
.blobGasUsed(util::randomUInt64)
.depositRequests(util::randomExecutionPayloadDepositRequests)
.withdrawalRequests(util::randomWithdrawalRequests)
.consolidationRequests(util::randomConsolidationRequests));
}

private List<Withdrawal> randomExecutionPayloadWithdrawals(final SpecVersion specVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public Eth2SigningRequestBody createBlockV2Request() {
case BELLATRIX:
case CAPELLA:
case DENEB:
case ELECTRA:
return createBlockV2Request(new BlockRequest(specMilestone, getBeaconBlockHeader()));
default:
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void setup() {
@ParameterizedTest(name = "#{index} - Sign and verify BlockV2 Signature for spec {0}")
@EnumSource(
value = SpecMilestone.class,
names = {"PHASE0", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB"})
names = {"PHASE0", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB", "ELECTRA"})
void signAndVerifyBlockV2Signature(final SpecMilestone specMilestone) throws Exception {
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(specMilestone);

Expand Down Expand Up @@ -90,7 +90,7 @@ void signAndVerifyLegacyBlockSignature() throws Exception {
name = "#{index} - Empty block request for spec {0} should return bad request status")
@EnumSource(
value = SpecMilestone.class,
names = {"PHASE0", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB"})
names = {"PHASE0", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB", "ELECTRA"})
void emptyBlockRequestReturnsBadRequestStatus(final SpecMilestone specMilestone)
throws JsonProcessingException {
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(specMilestone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ private void setForkEpochs(
builder.withCapellaForkEpoch(0L);
builder.withDenebForkEpoch(0L);
break;
case ELECTRA:
builder.withAltairForkEpoch(0L);
builder.withBellatrixForkEpoch(0L);
builder.withCapellaForkEpoch(0L);
builder.withDenebForkEpoch(0L);
builder.withElectraForkEpoch(0L);
break;
default:
throw new IllegalStateException(
"Setting manual fork epoch is not yet implemented for " + specMilestone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ private static class NetworkCliCompletionCandidates extends ArrayList<String> {
converter = UInt64Converter.class)
private UInt64 denebForkEpoch;

@CommandLine.Option(
names = {"--Xnetwork-electra-fork-epoch"},
hidden = true,
paramLabel = "<epoch>",
description = "Override the Electra fork activation epoch.",
arity = "1",
converter = UInt64Converter.class)
private UInt64 electraForkEpoch;

@CommandLine.Option(
names = {"--Xtrusted-setup"},
hidden = true,
Expand Down Expand Up @@ -215,6 +224,9 @@ private Eth2NetworkConfiguration createEth2NetworkConfig() {
if (denebForkEpoch != null) {
builder.denebForkEpoch(denebForkEpoch);
}
if (electraForkEpoch != null) {
builder.electraForkEpoch(electraForkEpoch);
}
if (trustedSetup != null) {
builder.trustedSetup(trustedSetup);
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ dependencyManagement {

dependency 'org.xipki.iaik:sunpkcs11-wrapper:1.4.10'

dependencySet(group: 'tech.pegasys.teku.internal', version: '24.6.1') {
dependencySet(group: 'tech.pegasys.teku.internal', version: '24.8.0') {
entry ('bls') {
exclude group: 'org.bouncycastle', name: 'bcprov-jdk15on'
}
Expand Down
Loading