Skip to content

Commit 2d67bb5

Browse files
committed
Creating PendingDeposit container
1 parent 234f711 commit 2d67bb5

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/ssz_static/SszTestExecutor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ public class SszTestExecutor<T extends SszData> implements TestExecutor {
210210
new SszTestExecutor<>(
211211
schemas ->
212212
SchemaDefinitionsElectra.required(schemas).getPendingBalanceDepositSchema()))
213+
.put(
214+
"ssz_static/PendingDeposit",
215+
new SszTestExecutor<>(
216+
schemas -> SchemaDefinitionsElectra.required(schemas).getPendingDepositSchema()))
213217
.put(
214218
"ssz_static/PendingConsolidation",
215219
new SszTestExecutor<>(
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.spec.datastructures.state.versions.electra;
15+
16+
import tech.pegasys.teku.infrastructure.ssz.containers.Container5;
17+
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema5;
18+
import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32;
19+
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64;
20+
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
21+
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
22+
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
23+
import tech.pegasys.teku.spec.datastructures.type.SszPublicKey;
24+
import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema;
25+
import tech.pegasys.teku.spec.datastructures.type.SszSignature;
26+
import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema;
27+
28+
public class PendingDeposit
29+
extends Container5<
30+
PendingDeposit, SszPublicKey, SszBytes32, SszUInt64, SszSignature, SszUInt64> {
31+
32+
public static class PendingDepositSchema
33+
extends ContainerSchema5<
34+
PendingDeposit, SszPublicKey, SszBytes32, SszUInt64, SszSignature, SszUInt64> {
35+
36+
public PendingDepositSchema() {
37+
super(
38+
"PendingDeposit",
39+
namedSchema("pubkey", SszPublicKeySchema.INSTANCE),
40+
namedSchema("withdrawal_credentials", SszPrimitiveSchemas.BYTES32_SCHEMA),
41+
namedSchema("amount", SszPrimitiveSchemas.UINT64_SCHEMA),
42+
namedSchema("signature", SszSignatureSchema.INSTANCE),
43+
namedSchema("slot", SszPrimitiveSchemas.UINT64_SCHEMA));
44+
}
45+
46+
@Override
47+
public PendingDeposit createFromBackingNode(final TreeNode node) {
48+
return new PendingDeposit(this, node);
49+
}
50+
51+
public PendingDeposit create(
52+
final SszPublicKey publicKey,
53+
final SszBytes32 withdrawalCredentials,
54+
final SszUInt64 amount,
55+
final SszSignature signature,
56+
final SszUInt64 slot) {
57+
return new PendingDeposit(this, publicKey, withdrawalCredentials, amount, signature, slot);
58+
}
59+
60+
public SszPublicKey getPublicKeySchema() {
61+
return (SszPublicKey) getFieldSchema0();
62+
}
63+
64+
public SszBytes32 getWithdrawalCredentialsSchema() {
65+
return (SszBytes32) getFieldSchema1();
66+
}
67+
68+
public SszUInt64 getAmountSchema() {
69+
return (SszUInt64) getFieldSchema2();
70+
}
71+
72+
public SszSignatureSchema getSignatureSchema() {
73+
return (SszSignatureSchema) getFieldSchema3();
74+
}
75+
76+
public SszUInt64 getSlotSchema() {
77+
return (SszUInt64) getFieldSchema4();
78+
}
79+
}
80+
81+
private PendingDeposit(final PendingDepositSchema type, final TreeNode backingNode) {
82+
super(type, backingNode);
83+
}
84+
85+
private PendingDeposit(
86+
final PendingDepositSchema type,
87+
final SszPublicKey publicKey,
88+
final SszBytes32 withdrawalCredentials,
89+
final SszUInt64 amount,
90+
final SszSignature signature,
91+
final SszUInt64 slot) {
92+
super(type, publicKey, withdrawalCredentials, amount, signature, slot);
93+
}
94+
95+
public int getIndex() {
96+
return ((SszUInt64) get(0)).get().intValue();
97+
}
98+
99+
public UInt64 getAmount() {
100+
return ((SszUInt64) get(1)).get();
101+
}
102+
}

ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.MutableBeaconStateElectra;
6363
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit;
6464
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation;
65+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingDeposit;
6566
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;
6667
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry;
6768

@@ -97,6 +98,7 @@ public class SchemaDefinitionsElectra extends SchemaDefinitionsDeneb {
9798
private final ConsolidationRequestSchema consolidationRequestSchema;
9899

99100
private final PendingBalanceDeposit.PendingBalanceDepositSchema pendingBalanceDepositSchema;
101+
private final PendingDeposit.PendingDepositSchema pendingDepositSchema;
100102

101103
private final PendingPartialWithdrawal.PendingPartialWithdrawalSchema
102104
pendingPartialWithdrawalSchema;
@@ -170,6 +172,7 @@ public SchemaDefinitionsElectra(final SchemaRegistry schemaRegistry) {
170172
this.withdrawalRequestSchema = WithdrawalRequest.SSZ_SCHEMA;
171173
this.consolidationRequestSchema = ConsolidationRequest.SSZ_SCHEMA;
172174
this.pendingBalanceDepositSchema = new PendingBalanceDeposit.PendingBalanceDepositSchema();
175+
this.pendingDepositSchema = new PendingDeposit.PendingDepositSchema();
173176
this.pendingPartialWithdrawalSchema =
174177
new PendingPartialWithdrawal.PendingPartialWithdrawalSchema();
175178
this.pendingConsolidationSchema = new PendingConsolidation.PendingConsolidationSchema();
@@ -321,6 +324,10 @@ public PendingBalanceDeposit.PendingBalanceDepositSchema getPendingBalanceDeposi
321324
return pendingBalanceDepositSchema;
322325
}
323326

327+
public PendingDeposit.PendingDepositSchema getPendingDepositSchema() {
328+
return pendingDepositSchema;
329+
}
330+
324331
public SszListSchema<PendingBalanceDeposit, ?> getPendingBalanceDepositsSchema() {
325332
return beaconStateSchema.getPendingBalanceDepositsSchema();
326333
}

0 commit comments

Comments
 (0)