-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix duplicate of ExecutionPayload in toString() for Capella * Fix BeaconBlockBody creation for Capella * Add EIP-4844 schema definitions * Added Blob, BlobsSidecar, SignedBeaconBlockAndBlobsSidecar schema getters from EIP-4844 schema definitions
- Loading branch information
Showing
16 changed files
with
656 additions
and
71 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
45 changes: 45 additions & 0 deletions
45
...astructures/blocks/blockbody/versions/eip4844/SignedBeaconBlockAndBlobsSidecarSchema.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,45 @@ | ||
/* | ||
* 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.blocks.blockbody.versions.eip4844; | ||
|
||
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; | ||
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; | ||
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; | ||
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema; | ||
import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.BlobsSidecar; | ||
import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.BlobsSidecarSchema; | ||
|
||
public class SignedBeaconBlockAndBlobsSidecarSchema | ||
extends ContainerSchema2<SignedBeaconBlockAndBlobsSidecar, SignedBeaconBlock, BlobsSidecar> { | ||
|
||
SignedBeaconBlockAndBlobsSidecarSchema( | ||
final SignedBeaconBlockSchema signedBeaconBlockSchema, | ||
final BlobsSidecarSchema blobsSidecarSchema) { | ||
super( | ||
"SignedBeaconBlockAndBlobsSidecar", | ||
namedSchema("beacon_block", signedBeaconBlockSchema), | ||
namedSchema("blobs_sidecar", blobsSidecarSchema)); | ||
} | ||
|
||
public static SignedBeaconBlockAndBlobsSidecarSchema create( | ||
final SignedBeaconBlockSchema signedBeaconBlockSchema, | ||
final BlobsSidecarSchema blobsSidecarSchema) { | ||
return new SignedBeaconBlockAndBlobsSidecarSchema(signedBeaconBlockSchema, blobsSidecarSchema); | ||
} | ||
|
||
@Override | ||
public SignedBeaconBlockAndBlobsSidecar createFromBackingNode(final TreeNode node) { | ||
return new SignedBeaconBlockAndBlobsSidecar(this, node); | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
.../tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobsSidecarSchema.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,57 @@ | ||
/* | ||
* 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.execution.versions.eip4844; | ||
|
||
import tech.pegasys.teku.infrastructure.ssz.SszList; | ||
import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema4; | ||
import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; | ||
import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.SszFieldName; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; | ||
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; | ||
import tech.pegasys.teku.spec.config.SpecConfigEip4844; | ||
import tech.pegasys.teku.spec.datastructures.type.SszKZGProof; | ||
import tech.pegasys.teku.spec.datastructures.type.SszKZGProofSchema; | ||
|
||
public class BlobsSidecarSchema | ||
extends ContainerSchema4<BlobsSidecar, SszBytes32, SszUInt64, SszList<Blob>, SszKZGProof> { | ||
|
||
static final SszFieldName FIELD_BLOBS = () -> "blobs"; | ||
|
||
BlobsSidecarSchema(final SpecConfigEip4844 specConfig, final BlobSchema blobSchema) { | ||
super( | ||
"BlobsSidecar", | ||
namedSchema("beacon_block_root", SszPrimitiveSchemas.BYTES32_SCHEMA), | ||
namedSchema("beacon_block_slot", SszPrimitiveSchemas.UINT64_SCHEMA), | ||
namedSchema( | ||
FIELD_BLOBS, SszListSchema.create(blobSchema, specConfig.getMaxBlobsPerBlock())), | ||
namedSchema("kzg_aggregated_proof", SszKZGProofSchema.INSTANCE)); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public SszListSchema<Blob, ?> getBlobsSchema() { | ||
return (SszListSchema<Blob, ?>) getChildSchema(getFieldIndex(FIELD_BLOBS)); | ||
} | ||
|
||
public static BlobsSidecarSchema create( | ||
final SpecConfigEip4844 specConfig, final BlobSchema blobSchema) { | ||
return new BlobsSidecarSchema(specConfig, blobSchema); | ||
} | ||
|
||
@Override | ||
public BlobsSidecar createFromBackingNode(final TreeNode node) { | ||
return new BlobsSidecar(this, node); | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
...gasys/teku/spec/datastructures/state/beaconstate/versions/eip4844/BeaconStateEip4844.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,52 @@ | ||
/* | ||
* 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.state.beaconstate.versions.eip4844; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import java.util.Optional; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.capella.BeaconStateCapella; | ||
|
||
public interface BeaconStateEip4844 extends BeaconStateCapella { | ||
static BeaconStateEip4844 required(final BeaconState state) { | ||
return state | ||
.toVersionEip4844() | ||
.orElseThrow( | ||
() -> | ||
new IllegalArgumentException( | ||
"Expected a EIP-4844 state but got: " + state.getClass().getSimpleName())); | ||
} | ||
|
||
static void describeCustomEip4844Fields( | ||
MoreObjects.ToStringHelper stringBuilder, BeaconStateCapella state) { | ||
BeaconStateCapella.describeCustomCapellaFields(stringBuilder, state); | ||
// no new fields | ||
} | ||
|
||
@Override | ||
MutableBeaconStateEip4844 createWritableCopy(); | ||
|
||
default <E1 extends Exception, E2 extends Exception, E3 extends Exception> | ||
BeaconStateEip4844 updatedEip4844( | ||
final Mutator<MutableBeaconStateEip4844, E1, E2, E3> mutator) throws E1, E2, E3 { | ||
MutableBeaconStateEip4844 writableCopy = createWritableCopy(); | ||
mutator.mutate(writableCopy); | ||
return writableCopy.commitChanges(); | ||
} | ||
|
||
@Override | ||
default Optional<BeaconStateEip4844> toVersionEip4844() { | ||
return Optional.of(this); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...s/teku/spec/datastructures/state/beaconstate/versions/eip4844/BeaconStateEip4844Impl.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,64 @@ | ||
/* | ||
* 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.state.beaconstate.versions.eip4844; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import tech.pegasys.teku.infrastructure.ssz.SszContainer; | ||
import tech.pegasys.teku.infrastructure.ssz.SszData; | ||
import tech.pegasys.teku.infrastructure.ssz.cache.IntCache; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.SszCompositeSchema; | ||
import tech.pegasys.teku.infrastructure.ssz.schema.impl.AbstractSszContainerSchema; | ||
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateCache; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateSchema; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.common.AbstractBeaconState; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.common.TransitionCaches; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.ValidatorStatsAltair; | ||
|
||
public class BeaconStateEip4844Impl extends AbstractBeaconState<MutableBeaconStateEip4844> | ||
implements BeaconStateEip4844, BeaconStateCache, ValidatorStatsAltair { | ||
|
||
BeaconStateEip4844Impl( | ||
final BeaconStateSchema<BeaconStateEip4844, MutableBeaconStateEip4844> schema) { | ||
super(schema); | ||
} | ||
|
||
BeaconStateEip4844Impl( | ||
final SszCompositeSchema<?> type, | ||
final TreeNode backingNode, | ||
final IntCache<SszData> cache, | ||
final TransitionCaches transitionCaches) { | ||
super(type, backingNode, cache, transitionCaches); | ||
} | ||
|
||
BeaconStateEip4844Impl( | ||
final AbstractSszContainerSchema<? extends SszContainer> type, final TreeNode backingNode) { | ||
super(type, backingNode); | ||
} | ||
|
||
@Override | ||
public BeaconStateSchemaEip4844 getBeaconStateSchema() { | ||
return (BeaconStateSchemaEip4844) getSchema(); | ||
} | ||
|
||
@Override | ||
public MutableBeaconStateEip4844 createWritableCopy() { | ||
return new MutableBeaconStateEip4844Impl(this); | ||
} | ||
|
||
@Override | ||
protected void describeCustomFields(final MoreObjects.ToStringHelper stringBuilder) { | ||
BeaconStateEip4844.describeCustomEip4844Fields(stringBuilder, this); | ||
} | ||
} |
Oops, something went wrong.