Skip to content

Commit

Permalink
fix more and more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Sep 10, 2024
1 parent 992eb29 commit 305ec72
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import tech.pegasys.teku.spec.schemas.SchemaDefinitions;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsDeneb;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsEip7732;
import tech.pegasys.teku.statetransition.OperationPool;
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
import tech.pegasys.teku.statetransition.attestation.AttestationForkChecker;
Expand Down Expand Up @@ -236,7 +237,18 @@ private SafeFuture<Void> setExecutionData(

// pre-Merge Execution Payload / Execution Payload Header
if (executionPayloadContext.isEmpty()) {
bodyBuilder.executionPayload(schemaDefinitions.getExecutionPayloadSchema().getDefault());
if (bodyBuilder.supportsSignedExecutionPayloadHeader()) {
// ePBS
final ExecutionPayloadHeader header =
schemaDefinitions.getExecutionPayloadHeaderSchema().getHeaderOfDefaultPayload();
final SignedExecutionPayloadHeader bid =
SchemaDefinitionsEip7732.required(schemaDefinitions)
.getSignedExecutionPayloadHeaderSchema()
.create(header, BLSSignature.empty());
bodyBuilder.signedExecutionPayloadHeader(bid);
} else {
bodyBuilder.executionPayload(schemaDefinitions.getExecutionPayloadSchema().getDefault());
}
return SafeFuture.COMPLETE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.api.AbstractSelectorFactory;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.SlotAndBlockRoot;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodyDeneb;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.eip7732.BeaconBlockBodyEip7732;
import tech.pegasys.teku.spec.datastructures.metadata.BlobSidecarsAndMetaData;
import tech.pegasys.teku.storage.client.ChainHead;
import tech.pegasys.teku.storage.client.CombinedChainDataClient;
Expand Down Expand Up @@ -170,10 +170,8 @@ private SafeFuture<Optional<List<BlobSidecar>>> getBlobSidecarsForBlock(
if (maybeDenebBlock.isEmpty()) {
return SafeFuture.completedFuture(Optional.empty());
}
final Optional<BeaconBlockBodyEip7732> maybeEip7732Block =
maybeBlock.get().getMessage().getBody().toVersionEip7732();
// no blob kzg commitments in EIP-7732 blocks
if (maybeEip7732Block.isEmpty() && maybeDenebBlock.get().getBlobKzgCommitments().isEmpty()) {
if (maybeDenebBlock.get().getOptionalBlobKzgCommitments().map(SszList::isEmpty).orElse(true)) {
return SafeFuture.completedFuture(Optional.of(Collections.emptyList()));
}
final SignedBeaconBlock block = maybeBlock.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import tech.pegasys.teku.api.schema.capella.SignedBeaconBlockCapella;
import tech.pegasys.teku.api.schema.deneb.BeaconStateDeneb;
import tech.pegasys.teku.api.schema.deneb.SignedBeaconBlockDeneb;
import tech.pegasys.teku.api.schema.eip7732.BeaconStateEip7732;
import tech.pegasys.teku.api.schema.eip7732.SignedBeaconBlockEip7732;
import tech.pegasys.teku.api.schema.electra.BeaconStateElectra;
import tech.pegasys.teku.api.schema.electra.SignedBeaconBlockElectra;
import tech.pegasys.teku.api.schema.phase0.BeaconStatePhase0;
Expand Down Expand Up @@ -92,7 +94,9 @@ public class JsonProviderPropertyTest {
SpecMilestone.DENEB,
SignedBeaconBlockDeneb.class,
SpecMilestone.ELECTRA,
SignedBeaconBlockElectra.class);
SignedBeaconBlockElectra.class,
SpecMilestone.EIP7732,
SignedBeaconBlockEip7732.class);

private static final Map<SpecMilestone, Class<? extends BeaconState>> BEACON_STATE_CLASS_MAP =
Map.of(
Expand All @@ -107,7 +111,9 @@ public class JsonProviderPropertyTest {
SpecMilestone.DENEB,
BeaconStateDeneb.class,
SpecMilestone.ELECTRA,
BeaconStateElectra.class);
BeaconStateElectra.class,
SpecMilestone.EIP7732,
BeaconStateEip7732.class);

@Property
void roundTripBytes32(@ForAll @Size(32) final byte[] value) throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Gnosis preset - EIP7732

# Execution
# ---------------------------------------------------------------
# 2**9 (= 512)
PTC_SIZE: 512
# 2**2 (= 4)
MAX_PAYLOAD_ATTESTATIONS: 4
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH_EIP7732: 13
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Gnosis preset - Electra

# Gwei values
# ---------------------------------------------------------------
# 2**5 * 10**9 (= 32,000,000,000) Gwei
MIN_ACTIVATION_BALANCE: 32000000000
# 2**11 * 10**9 (= 2,048,000,000,000) Gwei
MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000

# State list lengths
# ---------------------------------------------------------------
# `uint64(2**27)` (= 134,217,728)
PENDING_BALANCE_DEPOSITS_LIMIT: 134217728
# `uint64(2**27)` (= 134,217,728)
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 134217728
# `uint64(2**18)` (= 262,144)
PENDING_CONSOLIDATIONS_LIMIT: 262144

# Reward and penalty quotients
# ---------------------------------------------------------------
# `uint64(2**12)` (= 4,096)
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096
# `uint64(2**12)` (= 4,096)
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096

# # Max operations per block
# ---------------------------------------------------------------
# `uint64(2**0)` (= 1)
MAX_ATTESTER_SLASHINGS_ELECTRA: 1
# `uint64(2**3)` (= 8)
MAX_ATTESTATIONS_ELECTRA: 8
# `uint64(2**0)` (= 1)
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1

# Execution
# ---------------------------------------------------------------
# 2**13 (= 8192) receipts
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD: 8192
# 2**4 (= 16) withdrawal requests
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 16

# Withdrawals processing
# ---------------------------------------------------------------
# 2**3 ( = 8) pending withdrawals
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8
Original file line number Diff line number Diff line change
Expand Up @@ -2504,9 +2504,16 @@ public BlobSidecar build() {
}

public List<Bytes32> randomKzgCommitmentInclusionProof() {
final int depth =
SpecConfigDeneb.required(spec.forMilestone(SpecMilestone.DENEB).getConfig())
.getKzgCommitmentInclusionProofDepth();
final int depth;
if (spec.getGenesisSpec().getMilestone().isGreaterThanOrEqualTo(SpecMilestone.EIP7732)) {
depth =
SpecConfigEip7732.required(spec.forMilestone(SpecMilestone.EIP7732).getConfig())
.getKzgCommitmentInclusionProofDepthEip7732();
} else {
depth =
SpecConfigDeneb.required(spec.forMilestone(SpecMilestone.DENEB).getConfig())
.getKzgCommitmentInclusionProofDepth();
}
return IntStream.range(0, depth).mapToObj(__ -> randomBytes32()).toList();
}

Expand Down

0 comments on commit 305ec72

Please sign in to comment.