forked from Consensys/teku
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
360 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...atastructures/networking/libp2p/rpc/metadata/versions/eip7594/MetadataMessageEip7594.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2022 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.versions.eip7594; | ||
|
||
import java.util.Optional; | ||
import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector; | ||
import tech.pegasys.teku.infrastructure.ssz.containers.Container4; | ||
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; | ||
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessage; | ||
|
||
public class MetadataMessageEip7594 | ||
extends Container4<MetadataMessageEip7594, SszUInt64, SszBitvector, SszBitvector, SszUInt64> | ||
implements MetadataMessage { | ||
|
||
MetadataMessageEip7594(final MetadataMessageSchemaEip7594 schema) { | ||
super(schema); | ||
} | ||
|
||
MetadataMessageEip7594(final MetadataMessageSchemaEip7594 schema, final TreeNode backingNode) { | ||
super(schema, backingNode); | ||
} | ||
|
||
MetadataMessageEip7594( | ||
final MetadataMessageSchemaEip7594 schema, | ||
final UInt64 seqNumber, | ||
final SszBitvector attNets, | ||
final SszBitvector syncNets, | ||
final UInt64 custodySubnetCount) { | ||
super(schema, SszUInt64.of(seqNumber), attNets, syncNets, SszUInt64.of(custodySubnetCount)); | ||
} | ||
|
||
@Override | ||
public UInt64 getSeqNumber() { | ||
return getField0().get(); | ||
} | ||
|
||
@Override | ||
public SszBitvector getAttnets() { | ||
return getField1(); | ||
} | ||
|
||
public SszBitvector getSyncnets() { | ||
return getField2(); | ||
} | ||
|
||
public UInt64 getCustodySubnetCount() { | ||
return getField3().get(); | ||
} | ||
|
||
@Override | ||
public Optional<SszBitvector> getOptionalSyncnets() { | ||
return Optional.of(getSyncnets()); | ||
} | ||
|
||
@Override | ||
public Optional<UInt64> getOptionalCustodySubnetCount() { | ||
return Optional.of(getCustodySubnetCount()); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...uctures/networking/libp2p/rpc/metadata/versions/eip7594/MetadataMessageSchemaEip7594.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2022 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.versions.eip7594; | ||
|
||
import java.util.Optional; | ||
import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector; | ||
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema4; | ||
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszBitvectorSchema; | ||
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
import tech.pegasys.teku.spec.config.NetworkingSpecConfig; | ||
import tech.pegasys.teku.spec.constants.NetworkConstants; | ||
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessageSchema; | ||
|
||
public class MetadataMessageSchemaEip7594 | ||
extends ContainerSchema4< | ||
MetadataMessageEip7594, SszUInt64, SszBitvector, SszBitvector, SszUInt64> | ||
implements MetadataMessageSchema<MetadataMessageEip7594> { | ||
public MetadataMessageSchemaEip7594(final NetworkingSpecConfig networkingSpecConfig) { | ||
super( | ||
"MetadataMessage", | ||
namedSchema("seq_number", SszPrimitiveSchemas.UINT64_SCHEMA), | ||
namedSchema( | ||
"attnets", SszBitvectorSchema.create(networkingSpecConfig.getAttestationSubnetCount())), | ||
namedSchema( | ||
"syncnets", SszBitvectorSchema.create(NetworkConstants.SYNC_COMMITTEE_SUBNET_COUNT)), | ||
namedSchema("custody_subnet_count", SszPrimitiveSchemas.UINT64_SCHEMA)); | ||
} | ||
|
||
@Override | ||
public MetadataMessageEip7594 create( | ||
final UInt64 seqNumber, | ||
final Iterable<Integer> attnets, | ||
final Iterable<Integer> syncnets, | ||
final Optional<UInt64> custodySubnetCount) { | ||
return new MetadataMessageEip7594( | ||
this, | ||
seqNumber, | ||
getAttnestSchema().ofBits(attnets), | ||
getSyncnetsSchema().ofBits(syncnets), | ||
custodySubnetCount.orElse(UInt64.ZERO)); | ||
} | ||
|
||
@Override | ||
public MetadataMessageEip7594 createDefault() { | ||
return new MetadataMessageEip7594(this); | ||
} | ||
|
||
@Override | ||
public MetadataMessageEip7594 createFromBackingNode(final TreeNode node) { | ||
return new MetadataMessageEip7594(this, node); | ||
} | ||
|
||
private SszBitvectorSchema<SszBitvector> getAttnestSchema() { | ||
return (SszBitvectorSchema<SszBitvector>) getFieldSchema1(); | ||
} | ||
|
||
private SszBitvectorSchema<SszBitvector> getSyncnetsSchema() { | ||
return (SszBitvectorSchema<SszBitvector>) getFieldSchema2(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.