From 69f48a29c949d9ea9eebc659cea2c22bf61e1910 Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Fri, 18 Nov 2022 19:05:37 +0400 Subject: [PATCH 1/8] Create MiscHelpersEip4844 and stub for MiscHelpersCapella --- .../versions/eip4844/AccessTuple.java | 61 ++++++++++++ .../versions/eip4844/BlobTransaction.java | 81 +++++++++++++++ .../eip4844/BlobTransactionSchema.java | 79 +++++++++++++++ .../versions/eip4844/ECDSASignature.java | 48 +++++++++ .../eip4844/SignedBlobTransaction.java | 49 ++++++++++ .../versions/capella/SpecLogicCapella.java | 6 +- .../capella/helpers/MiscHelpersCapella.java | 24 +++++ .../versions/eip4844/SpecLogicEip4844.java | 6 +- .../eip4844/helpers/MiscHelpersEip4844.java | 98 +++++++++++++++++++ .../versions/eip4844/util/KZGUtilEip4844.java | 29 ++++++ 10 files changed, 475 insertions(+), 6 deletions(-) create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java create mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/util/KZGUtilEip4844.java diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java new file mode 100644 index 00000000000..83e116b6bde --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java @@ -0,0 +1,61 @@ +/* + * 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.bytes.Bytes20; +import tech.pegasys.teku.infrastructure.ssz.SszList; +import tech.pegasys.teku.infrastructure.ssz.collections.SszByteVector; +import tech.pegasys.teku.infrastructure.ssz.containers.Container2; +import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; +import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; +import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; +import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszByteVectorSchema; +import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; + +public class AccessTuple extends Container2> { + + private static final long MAX_ACCESS_LIST_STORAGE_KEYS = 16777216; // 2**24 + + public static class AccessTupleSchema + extends ContainerSchema2> { + + public AccessTupleSchema() { + super( + "AccessTuple", + namedSchema("address", SszByteVectorSchema.create(Bytes20.SIZE)), + namedSchema( + "storage_keys", + SszListSchema.create( + SszPrimitiveSchemas.BYTES32_SCHEMA, MAX_ACCESS_LIST_STORAGE_KEYS))); + } + + @SuppressWarnings("unchecked") + public SszListSchema getStorageKeysSchema() { + return (SszListSchema) getFieldSchema1(); + } + + @Override + public AccessTuple createFromBackingNode(TreeNode node) { + return new AccessTuple(this, node); + } + } + + public static final AccessTuple.AccessTupleSchema SSZ_SCHEMA = + new AccessTuple.AccessTupleSchema(); + + AccessTuple(final AccessTupleSchema type, final TreeNode backingNode) { + super(type, backingNode); + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java new file mode 100644 index 00000000000..667b1fe1587 --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java @@ -0,0 +1,81 @@ +/* + * 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 java.util.List; +import java.util.stream.Collectors; +import org.apache.tuweni.bytes.Bytes32; +import tech.pegasys.teku.infrastructure.ssz.SszList; +import tech.pegasys.teku.infrastructure.ssz.SszUnion; +import tech.pegasys.teku.infrastructure.ssz.collections.SszByteList; +import tech.pegasys.teku.infrastructure.ssz.containers.Container11; +import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; +import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; + +public class BlobTransaction + extends Container11< + BlobTransaction, + SszUInt256, + SszUInt64, + SszUInt256, + SszUInt256, + SszUInt64, + SszUnion, + SszUInt256, + SszByteList, + SszList, + SszUInt256, + SszList> { + + BlobTransaction(final BlobTransactionSchema type, final TreeNode backingNode) { + super(type, backingNode); + } + + public BlobTransaction( + final BlobTransactionSchema schema, + final SszUInt256 chainId, + final SszUInt64 nonce, + final SszUInt256 maxPriorityFeePerGas, + final SszUInt256 maxFeePerGas, + final SszUInt64 gas, + final SszUnion to, + final SszUInt256 value, + final SszByteList data, + final SszList accessList, + final SszUInt256 maxFeePerDataGas, + final SszList blobVersionedHashes) { + super( + schema, + chainId, + nonce, + maxPriorityFeePerGas, + maxFeePerGas, + gas, + to, + value, + data, + accessList, + maxFeePerDataGas, + blobVersionedHashes); + } + + public static final BlobTransactionSchema SSZ_SCHEMA = new BlobTransactionSchema(); + + public List getBlobVersionedHashes() { + return getField10().stream().map(AbstractSszPrimitive::get).collect(Collectors.toList()); + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java new file mode 100644 index 00000000000..ff0051a6e89 --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java @@ -0,0 +1,79 @@ +/* + * 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 java.util.List; +import tech.pegasys.teku.infrastructure.bytes.Bytes20; +import tech.pegasys.teku.infrastructure.ssz.SszList; +import tech.pegasys.teku.infrastructure.ssz.SszUnion; +import tech.pegasys.teku.infrastructure.ssz.collections.SszByteList; +import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema11; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; +import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; +import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; +import tech.pegasys.teku.infrastructure.ssz.schema.SszUnionSchema; +import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszByteListSchema; +import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszByteVectorSchema; +import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; + +public class BlobTransactionSchema + extends ContainerSchema11< + BlobTransaction, + SszUInt256, + SszUInt64, + SszUInt256, + SszUInt256, + SszUInt64, + SszUnion, + SszUInt256, + SszByteList, + SszList, + SszUInt256, + SszList> { + + private static final long MAX_VERSIONED_HASHES_LIST_SIZE = 16777216; // 2**24 + private static final long MAX_CALLDATA_SIZE = 16777216; // 2**24 + private static final long MAX_ACCESS_LIST_SIZE = 16777216; // 2**24 + + BlobTransactionSchema() { + super( + "BlobTransaction", + namedSchema("chain_id", SszPrimitiveSchemas.UINT256_SCHEMA), + namedSchema("nonce", SszPrimitiveSchemas.UINT64_SCHEMA), + namedSchema("max_priority_fee_per_gas", SszPrimitiveSchemas.UINT256_SCHEMA), + namedSchema("max_fee_per_gas", SszPrimitiveSchemas.UINT256_SCHEMA), + namedSchema("gas", SszPrimitiveSchemas.UINT64_SCHEMA), + namedSchema( + "to", + SszUnionSchema.create( + List.of( + SszPrimitiveSchemas.NONE_SCHEMA, SszByteVectorSchema.create(Bytes20.SIZE)))), + namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA), + namedSchema("data", SszByteListSchema.create(MAX_CALLDATA_SIZE)), + namedSchema( + "access_list", SszListSchema.create(AccessTuple.SSZ_SCHEMA, MAX_ACCESS_LIST_SIZE)), + namedSchema("max_fee_per_data_gas", SszPrimitiveSchemas.UINT256_SCHEMA), + namedSchema( + "blob_versioned_hashes", + SszListSchema.create( + SszPrimitiveSchemas.BYTES32_SCHEMA, MAX_VERSIONED_HASHES_LIST_SIZE))); + } + + @Override + public BlobTransaction createFromBackingNode(final TreeNode node) { + return new BlobTransaction(this, node); + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java new file mode 100644 index 00000000000..e8034e3b4e7 --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java @@ -0,0 +1,48 @@ +/* + * 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.containers.Container3; +import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema3; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszBit; +import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256; +import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; +import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; + +public class ECDSASignature extends Container3 { + + public static class ECDSASignatureSchema + extends ContainerSchema3 { + + public ECDSASignatureSchema() { + super( + "ECDSASignature", + namedSchema("y_parity", SszPrimitiveSchemas.BIT_SCHEMA), + namedSchema("r", SszPrimitiveSchemas.UINT256_SCHEMA), + namedSchema("s", SszPrimitiveSchemas.UINT256_SCHEMA)); + } + + @Override + public ECDSASignature createFromBackingNode(TreeNode node) { + return new ECDSASignature(this, node); + } + } + + public static final ECDSASignature.ECDSASignatureSchema SSZ_SCHEMA = + new ECDSASignature.ECDSASignatureSchema(); + + ECDSASignature(final ECDSASignatureSchema type, final TreeNode backingNode) { + super(type, backingNode); + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java new file mode 100644 index 00000000000..198f71b937e --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java @@ -0,0 +1,49 @@ +/* + * 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.containers.Container2; +import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; +import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; + +public class SignedBlobTransaction + extends Container2 { + + public static class SignedBlobTransactionSchema + extends ContainerSchema2 { + + public SignedBlobTransactionSchema() { + super( + "SignedBlobTransaction", + namedSchema("message", BlobTransaction.SSZ_SCHEMA), + namedSchema("signature", ECDSASignature.SSZ_SCHEMA)); + } + + @Override + public SignedBlobTransaction createFromBackingNode(TreeNode node) { + return new SignedBlobTransaction(this, node); + } + } + + public BlobTransaction getBlobTransaction() { + return getField0(); + } + + public static final SignedBlobTransaction.SignedBlobTransactionSchema SSZ_SCHEMA = + new SignedBlobTransaction.SignedBlobTransactionSchema(); + + SignedBlobTransaction(final SignedBlobTransactionSchema type, final TreeNode backingNode) { + super(type, backingNode); + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java index ad92556b040..eb83826945b 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java @@ -31,11 +31,11 @@ import tech.pegasys.teku.spec.logic.versions.altair.util.AttestationUtilAltair; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BeaconStateMutatorsBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BellatrixTransitionHelpers; -import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.MiscHelpersBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.statetransition.epoch.EpochProcessorBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.util.BlindBlockUtilBellatrix; import tech.pegasys.teku.spec.logic.versions.capella.block.BlockProcessorCapella; import tech.pegasys.teku.spec.logic.versions.capella.forktransition.CapellaStateUpgrade; +import tech.pegasys.teku.spec.logic.versions.capella.helpers.MiscHelpersCapella; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsCapella; public class SpecLogicCapella extends AbstractSpecLogic { @@ -44,7 +44,7 @@ public class SpecLogicCapella extends AbstractSpecLogic { private SpecLogicCapella( final Predicates predicates, - final MiscHelpersBellatrix miscHelpers, + final MiscHelpersCapella miscHelpers, final BeaconStateAccessorsAltair beaconStateAccessors, final BeaconStateMutatorsBellatrix beaconStateMutators, final OperationSignatureVerifier operationSignatureVerifier, @@ -86,7 +86,7 @@ public static SpecLogicCapella create( final SpecConfigCapella config, final SchemaDefinitionsCapella schemaDefinitions) { // Helpers final Predicates predicates = new Predicates(config); - final MiscHelpersBellatrix miscHelpers = new MiscHelpersBellatrix(config); + final MiscHelpersCapella miscHelpers = new MiscHelpersCapella(config); final BeaconStateAccessorsAltair beaconStateAccessors = new BeaconStateAccessorsAltair(config, predicates, miscHelpers); final BeaconStateMutatorsBellatrix beaconStateMutators = diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java new file mode 100644 index 00000000000..61c8af7d365 --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java @@ -0,0 +1,24 @@ +/* + * 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.logic.versions.capella.helpers; + +import tech.pegasys.teku.spec.config.SpecConfig; +import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.MiscHelpersBellatrix; + +public class MiscHelpersCapella extends MiscHelpersBellatrix { + + public MiscHelpersCapella(final SpecConfig specConfig) { + super(specConfig); + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/SpecLogicEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/SpecLogicEip4844.java index f441e0b44ed..1626708a938 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/SpecLogicEip4844.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/SpecLogicEip4844.java @@ -31,11 +31,11 @@ import tech.pegasys.teku.spec.logic.versions.altair.util.AttestationUtilAltair; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BeaconStateMutatorsBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BellatrixTransitionHelpers; -import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.MiscHelpersBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.statetransition.epoch.EpochProcessorBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.util.BlindBlockUtilBellatrix; import tech.pegasys.teku.spec.logic.versions.capella.block.BlockProcessorCapella; import tech.pegasys.teku.spec.logic.versions.eip4844.forktransition.Eip4844StateUpgrade; +import tech.pegasys.teku.spec.logic.versions.eip4844.helpers.MiscHelpersEip4844; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsEip4844; public class SpecLogicEip4844 extends AbstractSpecLogic { @@ -43,7 +43,7 @@ public class SpecLogicEip4844 extends AbstractSpecLogic { private SpecLogicEip4844( final Predicates predicates, - final MiscHelpersBellatrix miscHelpers, + final MiscHelpersEip4844 miscHelpers, final BeaconStateAccessorsAltair beaconStateAccessors, final BeaconStateMutatorsBellatrix beaconStateMutators, final OperationSignatureVerifier operationSignatureVerifier, @@ -83,7 +83,7 @@ public static SpecLogicEip4844 create( final SpecConfigEip4844 config, final SchemaDefinitionsEip4844 schemaDefinitions) { // Helpers final Predicates predicates = new Predicates(config); - final MiscHelpersBellatrix miscHelpers = new MiscHelpersBellatrix(config); + final MiscHelpersEip4844 miscHelpers = new MiscHelpersEip4844(config); final BeaconStateAccessorsAltair beaconStateAccessors = new BeaconStateAccessorsAltair(config, predicates, miscHelpers); final BeaconStateMutatorsBellatrix beaconStateMutators = diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java new file mode 100644 index 00000000000..5b2b179b83c --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java @@ -0,0 +1,98 @@ +/* + * 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.logic.versions.eip4844.helpers; + +import static com.google.common.base.Preconditions.checkArgument; +import static tech.pegasys.teku.spec.config.SpecConfigEip4844.BLOB_TX_TYPE; +import static tech.pegasys.teku.spec.config.SpecConfigEip4844.VERSIONED_HASH_VERSION_KZG; + +import java.util.List; +import java.util.stream.Collectors; +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; +import tech.pegasys.teku.infrastructure.crypto.Hash; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.kzg.KZGCommitment; +import tech.pegasys.teku.spec.config.SpecConfig; +import tech.pegasys.teku.spec.datastructures.execution.Transaction; +import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.BlobsSidecar; +import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.SignedBlobTransaction; +import tech.pegasys.teku.spec.logic.versions.capella.helpers.MiscHelpersCapella; +import tech.pegasys.teku.spec.logic.versions.eip4844.util.KZGUtilEip4844; + +public class MiscHelpersEip4844 extends MiscHelpersCapella { + + public MiscHelpersEip4844(final SpecConfig specConfig) { + super(specConfig); + } + + public void validateBlobSidecar( + final UInt64 slot, + final Bytes32 beaconBlockRoot, + final List kzgCommitments, + final BlobsSidecar blobsSidecar) { + checkArgument( + slot.equals(blobsSidecar.getBeaconBlockSlot()), + "Block slot should match blobsSidecar slot"); + checkArgument( + beaconBlockRoot.equals(blobsSidecar.getBeaconBlockRoot()), + "Block root should match blobsSidecar beacon block root"); + checkArgument( + kzgCommitments.size() == blobsSidecar.getBlobs().size(), + "Number of kzgCommitments should match number of blobs"); + KZGUtilEip4844.verifyAggregateKZGProof( + blobsSidecar.getBlobs(), kzgCommitments, blobsSidecar.getKZGAggregatedProof()); + } + + public boolean isDataAvailable( + final UInt64 slot, + final Bytes32 beaconBlockRoot, + final List kzgCommitments, + final BlobsSidecar blobsSidecar) { + validateBlobSidecar(slot, beaconBlockRoot, kzgCommitments, blobsSidecar); + return true; + } + + private Bytes32 kzgCommitmentToVersionedHash(final KZGCommitment kzgCommitment) { + return Bytes32.wrap( + Bytes.wrap( + VERSIONED_HASH_VERSION_KZG, Hash.sha256(kzgCommitment.getBytesCompressed()).slice(1))); + } + + private List txPeekBlobVersionedHashes(final Transaction transaction) { + checkArgument(isBlobTransaction(transaction), "Transaction should be of BLOB type"); + final SignedBlobTransaction signedBlobTransaction = + SignedBlobTransaction.SSZ_SCHEMA.sszDeserialize(transaction.getBytes().slice(1)); + return signedBlobTransaction.getBlobTransaction().getBlobVersionedHashes(); + } + + private boolean isBlobTransaction(final Transaction transaction) { + return transaction.getBytes().get(0) == BLOB_TX_TYPE.get(0); + } + + public boolean verifyKZGCommitmentsAgainstTransactions( + final List transactions, final List kzgCommitments) { + final List transactionsVersionedHashes = + transactions.stream() + .filter(this::isBlobTransaction) + .map(this::txPeekBlobVersionedHashes) + .flatMap(List::stream) + .collect(Collectors.toList()); + final List commitmentsVersionedHashes = + kzgCommitments.stream() + .map(this::kzgCommitmentToVersionedHash) + .collect(Collectors.toList()); + return transactionsVersionedHashes.equals(commitmentsVersionedHashes); + } +} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/util/KZGUtilEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/util/KZGUtilEip4844.java new file mode 100644 index 00000000000..805ef3c67af --- /dev/null +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/util/KZGUtilEip4844.java @@ -0,0 +1,29 @@ +/* + * 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.logic.versions.eip4844.util; + +import java.util.List; +import tech.pegasys.teku.kzg.KZGCommitment; +import tech.pegasys.teku.kzg.KZGProof; +import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.Blob; + +public class KZGUtilEip4844 { + + public static void verifyAggregateKZGProof( + final List blobs, + final List expectedKZGCommitments, + final KZGProof kzgProof) { + // TODO: implement + } +} From b825a7fdd02666f052fb53bd10e90351d93751e9 Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Sun, 20 Nov 2022 15:27:43 +0400 Subject: [PATCH 2/8] Add VersionedHash --- .../eip4844/helpers/MiscHelpersEip4844.java | 19 +++--- infrastructure/crypto/build.gradle | 2 +- .../infrastructure/crypto/VersionedHash.java | 61 +++++++++++++++++++ 3 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto/VersionedHash.java diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java index 5b2b179b83c..73df426230f 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java @@ -19,9 +19,9 @@ import java.util.List; import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.infrastructure.crypto.Hash; +import tech.pegasys.teku.infrastructure.crypto.VersionedHash; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.kzg.KZGCommitment; import tech.pegasys.teku.spec.config.SpecConfig; @@ -64,17 +64,18 @@ public boolean isDataAvailable( return true; } - private Bytes32 kzgCommitmentToVersionedHash(final KZGCommitment kzgCommitment) { - return Bytes32.wrap( - Bytes.wrap( - VERSIONED_HASH_VERSION_KZG, Hash.sha256(kzgCommitment.getBytesCompressed()).slice(1))); + private VersionedHash kzgCommitmentToVersionedHash(final KZGCommitment kzgCommitment) { + return VersionedHash.create( + VERSIONED_HASH_VERSION_KZG, Hash.sha256(kzgCommitment.getBytesCompressed())); } - private List txPeekBlobVersionedHashes(final Transaction transaction) { + private List txPeekBlobVersionedHashes(final Transaction transaction) { checkArgument(isBlobTransaction(transaction), "Transaction should be of BLOB type"); final SignedBlobTransaction signedBlobTransaction = SignedBlobTransaction.SSZ_SCHEMA.sszDeserialize(transaction.getBytes().slice(1)); - return signedBlobTransaction.getBlobTransaction().getBlobVersionedHashes(); + return signedBlobTransaction.getBlobTransaction().getBlobVersionedHashes().stream() + .map(VersionedHash::new) + .collect(Collectors.toList()); } private boolean isBlobTransaction(final Transaction transaction) { @@ -83,13 +84,13 @@ private boolean isBlobTransaction(final Transaction transaction) { public boolean verifyKZGCommitmentsAgainstTransactions( final List transactions, final List kzgCommitments) { - final List transactionsVersionedHashes = + final List transactionsVersionedHashes = transactions.stream() .filter(this::isBlobTransaction) .map(this::txPeekBlobVersionedHashes) .flatMap(List::stream) .collect(Collectors.toList()); - final List commitmentsVersionedHashes = + final List commitmentsVersionedHashes = kzgCommitments.stream() .map(this::kzgCommitmentToVersionedHash) .collect(Collectors.toList()); diff --git a/infrastructure/crypto/build.gradle b/infrastructure/crypto/build.gradle index 76e65a238a7..c09292f8721 100644 --- a/infrastructure/crypto/build.gradle +++ b/infrastructure/crypto/build.gradle @@ -1,7 +1,7 @@ dependencies { api 'org.bouncycastle:bcprov-jdk15on' api 'org.apache.tuweni:tuweni-bytes' - + implementation 'commons-io:commons-io' jmhImplementation 'org.bouncycastle:bcprov-jdk15on' jmhImplementation project(':infrastructure:crypto') diff --git a/infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto/VersionedHash.java b/infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto/VersionedHash.java new file mode 100644 index 00000000000..9e25f5dbf70 --- /dev/null +++ b/infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto/VersionedHash.java @@ -0,0 +1,61 @@ +/* + * 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.infrastructure.crypto; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.util.Objects; +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; + +public class VersionedHash { + final Bytes version; + final Bytes value; + + private VersionedHash(Bytes version, Bytes value) { + this.version = version; + this.value = value; + } + + public VersionedHash(final Bytes32 value) { + this.version = value.slice(0, 1); + this.value = value.slice(1); + } + + public static VersionedHash create(final Bytes version, final Bytes32 hash) { + checkArgument(version.size() == 1, "Version is 1-byte flag"); + return new VersionedHash(version, hash.slice(1)); + } + + public boolean isVersion(final Bytes version) { + return this.version.equals(version); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VersionedHash that = (VersionedHash) o; + return Objects.equals(version, that.version) && Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return Objects.hash(version, value); + } +} From 380c728d535e3702e833aa25a5418ff7fcc1ea4d Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Sun, 20 Nov 2022 15:40:07 +0400 Subject: [PATCH 3/8] Move VersionedHash to a better place --- .../spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java | 2 +- .../teku/spec/logic/versions/eip4844/types}/VersionedHash.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename {infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto => ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types}/VersionedHash.java (96%) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java index 73df426230f..415dfaf2aee 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java @@ -21,7 +21,6 @@ import java.util.stream.Collectors; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.infrastructure.crypto.Hash; -import tech.pegasys.teku.infrastructure.crypto.VersionedHash; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.kzg.KZGCommitment; import tech.pegasys.teku.spec.config.SpecConfig; @@ -29,6 +28,7 @@ import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.BlobsSidecar; import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.SignedBlobTransaction; import tech.pegasys.teku.spec.logic.versions.capella.helpers.MiscHelpersCapella; +import tech.pegasys.teku.spec.logic.versions.eip4844.types.VersionedHash; import tech.pegasys.teku.spec.logic.versions.eip4844.util.KZGUtilEip4844; public class MiscHelpersEip4844 extends MiscHelpersCapella { diff --git a/infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto/VersionedHash.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types/VersionedHash.java similarity index 96% rename from infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto/VersionedHash.java rename to ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types/VersionedHash.java index 9e25f5dbf70..f14017bdf34 100644 --- a/infrastructure/crypto/src/main/java/tech/pegasys/teku/infrastructure/crypto/VersionedHash.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types/VersionedHash.java @@ -11,7 +11,7 @@ * specific language governing permissions and limitations under the License. */ -package tech.pegasys.teku.infrastructure.crypto; +package tech.pegasys.teku.spec.logic.versions.eip4844.types; import static com.google.common.base.Preconditions.checkArgument; From 588ff7fd5e76efff1a38d275a6d9c3c39b787f3f Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Mon, 21 Nov 2022 23:40:56 +0400 Subject: [PATCH 4/8] Add MiscHelpersEip4844 tests --- .../eip4844/helpers/MiscHelpersEip4844.java | 7 +- .../helpers/MiscHelpersEip4844Test.java | 75 ++++++++++++++++++ .../helpers/signed_blob_transaction.ssz | Bin 0 -> 423 bytes 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java create mode 100644 ethereum/spec/src/test/resources/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/signed_blob_transaction.ssz diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java index 415dfaf2aee..abd75f4ef53 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java @@ -17,6 +17,7 @@ import static tech.pegasys.teku.spec.config.SpecConfigEip4844.BLOB_TX_TYPE; import static tech.pegasys.teku.spec.config.SpecConfigEip4844.VERSIONED_HASH_VERSION_KZG; +import com.google.common.annotations.VisibleForTesting; import java.util.List; import java.util.stream.Collectors; import org.apache.tuweni.bytes.Bytes32; @@ -64,12 +65,14 @@ public boolean isDataAvailable( return true; } - private VersionedHash kzgCommitmentToVersionedHash(final KZGCommitment kzgCommitment) { + @VisibleForTesting + public VersionedHash kzgCommitmentToVersionedHash(final KZGCommitment kzgCommitment) { return VersionedHash.create( VERSIONED_HASH_VERSION_KZG, Hash.sha256(kzgCommitment.getBytesCompressed())); } - private List txPeekBlobVersionedHashes(final Transaction transaction) { + @VisibleForTesting + public List txPeekBlobVersionedHashes(final Transaction transaction) { checkArgument(isBlobTransaction(transaction), "Transaction should be of BLOB type"); final SignedBlobTransaction signedBlobTransaction = SignedBlobTransaction.SSZ_SCHEMA.sszDeserialize(transaction.getBytes().slice(1)); diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java new file mode 100644 index 00000000000..59d0fc53175 --- /dev/null +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java @@ -0,0 +1,75 @@ +/* + * 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.logic.versions.eip4844.helpers; + +import static org.assertj.core.api.Assertions.assertThat; +import static tech.pegasys.teku.spec.config.SpecConfigEip4844.BLOB_TX_TYPE; +import static tech.pegasys.teku.spec.config.SpecConfigEip4844.VERSIONED_HASH_VERSION_KZG; + +import com.google.common.io.ByteSource; +import com.google.common.io.Resources; +import java.io.IOException; +import java.util.List; +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; +import org.junit.jupiter.api.Test; +import tech.pegasys.teku.kzg.KZGCommitment; +import tech.pegasys.teku.spec.Spec; +import tech.pegasys.teku.spec.TestSpecFactory; +import tech.pegasys.teku.spec.datastructures.execution.Transaction; +import tech.pegasys.teku.spec.datastructures.execution.TransactionSchema; +import tech.pegasys.teku.spec.logic.versions.eip4844.types.VersionedHash; + +class MiscHelpersEip4844Test { + + private static final String SIGNED_BLOB_TX_LOCATION = "signed_blob_transaction.ssz"; + private static final VersionedHash VERSIONED_HASH = + VersionedHash.create( + VERSIONED_HASH_VERSION_KZG, + Bytes32.fromHexString( + "0x391610cf24e7c540192b80ddcfea77b0d3912d94e922682f3b286eee041e6f76")); + + private final Spec spec = TestSpecFactory.createMinimalEip4844(); + private final MiscHelpersEip4844 miscHelpersEip4844 = new MiscHelpersEip4844(spec.getGenesisSpecConfig()); + + @Test + public void versionedHash() { + final VersionedHash actual = + miscHelpersEip4844.kzgCommitmentToVersionedHash( + KZGCommitment.fromHexString( + "0x85d1edf1ee88f68260e750abb2c766398ad1125d4e94e1de04034075ccbd2bb79c5689b952ef15374fd03ca2b2475371")); + assertThat(actual).isEqualTo(VERSIONED_HASH); + } + + @Test + public void txPeekBlobVersionedHashes() throws IOException { + final Bytes sszTx = loadData(SIGNED_BLOB_TX_LOCATION); + assertThat(sszTx.get(0)).isEqualTo(BLOB_TX_TYPE.get(0)); + final TransactionSchema transactionSchema = + new TransactionSchema(spec.getGenesisSpecConfig().toVersionEip4844().orElseThrow()); + final Transaction blobTx = transactionSchema.sszDeserialize(sszTx); + List versionedHashes = miscHelpersEip4844.txPeekBlobVersionedHashes(blobTx); + assertThat(versionedHashes.size()).isEqualTo(5); + assertThat( + versionedHashes.stream().allMatch(hash -> hash.isVersion(VERSIONED_HASH_VERSION_KZG))) + .isTrue(); + assertThat(versionedHashes.stream().allMatch(hash -> hash.equals(VERSIONED_HASH))).isTrue(); + } + + private Bytes loadData(final String location) throws IOException { + final ByteSource binaryData = + Resources.asByteSource(Resources.getResource(MiscHelpersEip4844Test.class, location)); + return Bytes.wrap(binaryData.read()); + } +} diff --git a/ethereum/spec/src/test/resources/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/signed_blob_transaction.ssz b/ethereum/spec/src/test/resources/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/signed_blob_transaction.ssz new file mode 100644 index 0000000000000000000000000000000000000000..05a5575523d856d36c0d1d2513509ca7b54ce2ea GIT binary patch literal 423 zcmZQ|Wf+3s01<9J2vh^YgaB9#qnN;XmFGttB()pvo_|%o;qpY?DKC{W^sP1W-m%E# ImkqQ$00*u~vH$=8 literal 0 HcmV?d00001 From a5bcf7defd7240246e40169c10f0aeda31946e0b Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Mon, 21 Nov 2022 23:46:25 +0400 Subject: [PATCH 5/8] Fix spotless --- .../logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java index 59d0fc53175..ceaa9a314de 100644 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844Test.java @@ -41,7 +41,8 @@ class MiscHelpersEip4844Test { "0x391610cf24e7c540192b80ddcfea77b0d3912d94e922682f3b286eee041e6f76")); private final Spec spec = TestSpecFactory.createMinimalEip4844(); - private final MiscHelpersEip4844 miscHelpersEip4844 = new MiscHelpersEip4844(spec.getGenesisSpecConfig()); + private final MiscHelpersEip4844 miscHelpersEip4844 = + new MiscHelpersEip4844(spec.getGenesisSpecConfig()); @Test public void versionedHash() { From 0c10ce4dc392e1618a86f13de873a4450fe07d3f Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Tue, 22 Nov 2022 17:23:12 +0400 Subject: [PATCH 6/8] Remove BlobTransaction container and switch txPeekBlobVersionedHashes to magic offsets --- .../versions/eip4844/AccessTuple.java | 61 -------------- .../versions/eip4844/BlobTransaction.java | 81 ------------------- .../eip4844/BlobTransactionSchema.java | 79 ------------------ .../versions/eip4844/ECDSASignature.java | 48 ----------- .../eip4844/SignedBlobTransaction.java | 49 ----------- .../eip4844/helpers/MiscHelpersEip4844.java | 30 +++++-- .../versions/eip4844/types/VersionedHash.java | 3 + 7 files changed, 27 insertions(+), 324 deletions(-) delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java deleted file mode 100644 index 83e116b6bde..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/AccessTuple.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.bytes.Bytes20; -import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.collections.SszByteVector; -import tech.pegasys.teku.infrastructure.ssz.containers.Container2; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; -import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; -import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; -import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszByteVectorSchema; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; - -public class AccessTuple extends Container2> { - - private static final long MAX_ACCESS_LIST_STORAGE_KEYS = 16777216; // 2**24 - - public static class AccessTupleSchema - extends ContainerSchema2> { - - public AccessTupleSchema() { - super( - "AccessTuple", - namedSchema("address", SszByteVectorSchema.create(Bytes20.SIZE)), - namedSchema( - "storage_keys", - SszListSchema.create( - SszPrimitiveSchemas.BYTES32_SCHEMA, MAX_ACCESS_LIST_STORAGE_KEYS))); - } - - @SuppressWarnings("unchecked") - public SszListSchema getStorageKeysSchema() { - return (SszListSchema) getFieldSchema1(); - } - - @Override - public AccessTuple createFromBackingNode(TreeNode node) { - return new AccessTuple(this, node); - } - } - - public static final AccessTuple.AccessTupleSchema SSZ_SCHEMA = - new AccessTuple.AccessTupleSchema(); - - AccessTuple(final AccessTupleSchema type, final TreeNode backingNode) { - super(type, backingNode); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java deleted file mode 100644 index 667b1fe1587..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransaction.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 java.util.List; -import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.SszUnion; -import tech.pegasys.teku.infrastructure.ssz.collections.SszByteList; -import tech.pegasys.teku.infrastructure.ssz.containers.Container11; -import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; - -public class BlobTransaction - extends Container11< - BlobTransaction, - SszUInt256, - SszUInt64, - SszUInt256, - SszUInt256, - SszUInt64, - SszUnion, - SszUInt256, - SszByteList, - SszList, - SszUInt256, - SszList> { - - BlobTransaction(final BlobTransactionSchema type, final TreeNode backingNode) { - super(type, backingNode); - } - - public BlobTransaction( - final BlobTransactionSchema schema, - final SszUInt256 chainId, - final SszUInt64 nonce, - final SszUInt256 maxPriorityFeePerGas, - final SszUInt256 maxFeePerGas, - final SszUInt64 gas, - final SszUnion to, - final SszUInt256 value, - final SszByteList data, - final SszList accessList, - final SszUInt256 maxFeePerDataGas, - final SszList blobVersionedHashes) { - super( - schema, - chainId, - nonce, - maxPriorityFeePerGas, - maxFeePerGas, - gas, - to, - value, - data, - accessList, - maxFeePerDataGas, - blobVersionedHashes); - } - - public static final BlobTransactionSchema SSZ_SCHEMA = new BlobTransactionSchema(); - - public List getBlobVersionedHashes() { - return getField10().stream().map(AbstractSszPrimitive::get).collect(Collectors.toList()); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java deleted file mode 100644 index ff0051a6e89..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/BlobTransactionSchema.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 java.util.List; -import tech.pegasys.teku.infrastructure.bytes.Bytes20; -import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.SszUnion; -import tech.pegasys.teku.infrastructure.ssz.collections.SszByteList; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema11; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; -import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; -import tech.pegasys.teku.infrastructure.ssz.schema.SszUnionSchema; -import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszByteListSchema; -import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszByteVectorSchema; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; - -public class BlobTransactionSchema - extends ContainerSchema11< - BlobTransaction, - SszUInt256, - SszUInt64, - SszUInt256, - SszUInt256, - SszUInt64, - SszUnion, - SszUInt256, - SszByteList, - SszList, - SszUInt256, - SszList> { - - private static final long MAX_VERSIONED_HASHES_LIST_SIZE = 16777216; // 2**24 - private static final long MAX_CALLDATA_SIZE = 16777216; // 2**24 - private static final long MAX_ACCESS_LIST_SIZE = 16777216; // 2**24 - - BlobTransactionSchema() { - super( - "BlobTransaction", - namedSchema("chain_id", SszPrimitiveSchemas.UINT256_SCHEMA), - namedSchema("nonce", SszPrimitiveSchemas.UINT64_SCHEMA), - namedSchema("max_priority_fee_per_gas", SszPrimitiveSchemas.UINT256_SCHEMA), - namedSchema("max_fee_per_gas", SszPrimitiveSchemas.UINT256_SCHEMA), - namedSchema("gas", SszPrimitiveSchemas.UINT64_SCHEMA), - namedSchema( - "to", - SszUnionSchema.create( - List.of( - SszPrimitiveSchemas.NONE_SCHEMA, SszByteVectorSchema.create(Bytes20.SIZE)))), - namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA), - namedSchema("data", SszByteListSchema.create(MAX_CALLDATA_SIZE)), - namedSchema( - "access_list", SszListSchema.create(AccessTuple.SSZ_SCHEMA, MAX_ACCESS_LIST_SIZE)), - namedSchema("max_fee_per_data_gas", SszPrimitiveSchemas.UINT256_SCHEMA), - namedSchema( - "blob_versioned_hashes", - SszListSchema.create( - SszPrimitiveSchemas.BYTES32_SCHEMA, MAX_VERSIONED_HASHES_LIST_SIZE))); - } - - @Override - public BlobTransaction createFromBackingNode(final TreeNode node) { - return new BlobTransaction(this, node); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java deleted file mode 100644 index e8034e3b4e7..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/ECDSASignature.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.containers.Container3; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema3; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszBit; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256; -import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; - -public class ECDSASignature extends Container3 { - - public static class ECDSASignatureSchema - extends ContainerSchema3 { - - public ECDSASignatureSchema() { - super( - "ECDSASignature", - namedSchema("y_parity", SszPrimitiveSchemas.BIT_SCHEMA), - namedSchema("r", SszPrimitiveSchemas.UINT256_SCHEMA), - namedSchema("s", SszPrimitiveSchemas.UINT256_SCHEMA)); - } - - @Override - public ECDSASignature createFromBackingNode(TreeNode node) { - return new ECDSASignature(this, node); - } - } - - public static final ECDSASignature.ECDSASignatureSchema SSZ_SCHEMA = - new ECDSASignature.ECDSASignatureSchema(); - - ECDSASignature(final ECDSASignatureSchema type, final TreeNode backingNode) { - super(type, backingNode); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java deleted file mode 100644 index 198f71b937e..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/eip4844/SignedBlobTransaction.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.containers.Container2; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; - -public class SignedBlobTransaction - extends Container2 { - - public static class SignedBlobTransactionSchema - extends ContainerSchema2 { - - public SignedBlobTransactionSchema() { - super( - "SignedBlobTransaction", - namedSchema("message", BlobTransaction.SSZ_SCHEMA), - namedSchema("signature", ECDSASignature.SSZ_SCHEMA)); - } - - @Override - public SignedBlobTransaction createFromBackingNode(TreeNode node) { - return new SignedBlobTransaction(this, node); - } - } - - public BlobTransaction getBlobTransaction() { - return getField0(); - } - - public static final SignedBlobTransaction.SignedBlobTransactionSchema SSZ_SCHEMA = - new SignedBlobTransaction.SignedBlobTransactionSchema(); - - SignedBlobTransaction(final SignedBlobTransactionSchema type, final TreeNode backingNode) { - super(type, backingNode); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java index abd75f4ef53..e7dda6f894d 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java @@ -18,16 +18,19 @@ import static tech.pegasys.teku.spec.config.SpecConfigEip4844.VERSIONED_HASH_VERSION_KZG; import com.google.common.annotations.VisibleForTesting; +import java.nio.ByteOrder; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.apache.tuweni.units.bigints.UInt32; import tech.pegasys.teku.infrastructure.crypto.Hash; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.kzg.KZGCommitment; import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.datastructures.execution.Transaction; import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.BlobsSidecar; -import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.SignedBlobTransaction; import tech.pegasys.teku.spec.logic.versions.capella.helpers.MiscHelpersCapella; import tech.pegasys.teku.spec.logic.versions.eip4844.types.VersionedHash; import tech.pegasys.teku.spec.logic.versions.eip4844.util.KZGUtilEip4844; @@ -74,11 +77,26 @@ public VersionedHash kzgCommitmentToVersionedHash(final KZGCommitment kzgCommitm @VisibleForTesting public List txPeekBlobVersionedHashes(final Transaction transaction) { checkArgument(isBlobTransaction(transaction), "Transaction should be of BLOB type"); - final SignedBlobTransaction signedBlobTransaction = - SignedBlobTransaction.SSZ_SCHEMA.sszDeserialize(transaction.getBytes().slice(1)); - return signedBlobTransaction.getBlobTransaction().getBlobVersionedHashes().stream() - .map(VersionedHash::new) - .collect(Collectors.toList()); + final Bytes txData = transaction.getBytes(); + // 1st byte is transaction type, next goes ssz encoded SignedBlobTransaction + // Getting variable length BlobTransaction offset, which is the message of signed tx + final int messageOffset = + UInt32.fromBytes(txData.slice(1, 4), ByteOrder.LITTLE_ENDIAN).add(1).intValue(); + // Getting blobVersionedHashes field offset in BlobTransaction + // field offset: 32 + 8 + 32 + 32 + 8 + 4 + 32 + 4 + 4 + 32 = 188 + final int blobVersionedHashesOffset = + messageOffset + + UInt32.fromBytes(txData.slice(messageOffset + 188, 4), ByteOrder.LITTLE_ENDIAN) + .intValue(); + final List versionedHashes = new ArrayList<>(); + for (int hashStartOffset = blobVersionedHashesOffset; + hashStartOffset < txData.size(); + hashStartOffset += VersionedHash.SIZE) { + versionedHashes.add( + new VersionedHash(Bytes32.wrap(txData.slice(hashStartOffset, VersionedHash.SIZE)))); + } + + return versionedHashes; } private boolean isBlobTransaction(final Transaction transaction) { diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types/VersionedHash.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types/VersionedHash.java index f14017bdf34..fe3ab9c0437 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types/VersionedHash.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/types/VersionedHash.java @@ -20,6 +20,9 @@ import org.apache.tuweni.bytes.Bytes32; public class VersionedHash { + + public static final int SIZE = 32; + final Bytes version; final Bytes value; From ee5cca82139f91ecaf4f60af1c2ed20d54ff9bcc Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Tue, 22 Nov 2022 22:45:17 +0400 Subject: [PATCH 7/8] Remove unused dependency trace --- infrastructure/crypto/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/crypto/build.gradle b/infrastructure/crypto/build.gradle index c09292f8721..76e65a238a7 100644 --- a/infrastructure/crypto/build.gradle +++ b/infrastructure/crypto/build.gradle @@ -1,7 +1,7 @@ dependencies { api 'org.bouncycastle:bcprov-jdk15on' api 'org.apache.tuweni:tuweni-bytes' - implementation 'commons-io:commons-io' + jmhImplementation 'org.bouncycastle:bcprov-jdk15on' jmhImplementation project(':infrastructure:crypto') From b8274b107431371dd522dfc8bfecbc50416e32f0 Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Tue, 22 Nov 2022 22:47:17 +0400 Subject: [PATCH 8/8] Remove MiscHelpersCapella stub --- .../versions/capella/SpecLogicCapella.java | 6 ++--- .../capella/helpers/MiscHelpersCapella.java | 24 ------------------- .../eip4844/helpers/MiscHelpersEip4844.java | 4 ++-- 3 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java index eb83826945b..ad92556b040 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/SpecLogicCapella.java @@ -31,11 +31,11 @@ import tech.pegasys.teku.spec.logic.versions.altair.util.AttestationUtilAltair; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BeaconStateMutatorsBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BellatrixTransitionHelpers; +import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.MiscHelpersBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.statetransition.epoch.EpochProcessorBellatrix; import tech.pegasys.teku.spec.logic.versions.bellatrix.util.BlindBlockUtilBellatrix; import tech.pegasys.teku.spec.logic.versions.capella.block.BlockProcessorCapella; import tech.pegasys.teku.spec.logic.versions.capella.forktransition.CapellaStateUpgrade; -import tech.pegasys.teku.spec.logic.versions.capella.helpers.MiscHelpersCapella; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsCapella; public class SpecLogicCapella extends AbstractSpecLogic { @@ -44,7 +44,7 @@ public class SpecLogicCapella extends AbstractSpecLogic { private SpecLogicCapella( final Predicates predicates, - final MiscHelpersCapella miscHelpers, + final MiscHelpersBellatrix miscHelpers, final BeaconStateAccessorsAltair beaconStateAccessors, final BeaconStateMutatorsBellatrix beaconStateMutators, final OperationSignatureVerifier operationSignatureVerifier, @@ -86,7 +86,7 @@ public static SpecLogicCapella create( final SpecConfigCapella config, final SchemaDefinitionsCapella schemaDefinitions) { // Helpers final Predicates predicates = new Predicates(config); - final MiscHelpersCapella miscHelpers = new MiscHelpersCapella(config); + final MiscHelpersBellatrix miscHelpers = new MiscHelpersBellatrix(config); final BeaconStateAccessorsAltair beaconStateAccessors = new BeaconStateAccessorsAltair(config, predicates, miscHelpers); final BeaconStateMutatorsBellatrix beaconStateMutators = diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java deleted file mode 100644 index 61c8af7d365..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/helpers/MiscHelpersCapella.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.logic.versions.capella.helpers; - -import tech.pegasys.teku.spec.config.SpecConfig; -import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.MiscHelpersBellatrix; - -public class MiscHelpersCapella extends MiscHelpersBellatrix { - - public MiscHelpersCapella(final SpecConfig specConfig) { - super(specConfig); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java index e7dda6f894d..eb250bb22e1 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip4844/helpers/MiscHelpersEip4844.java @@ -31,11 +31,11 @@ import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.datastructures.execution.Transaction; import tech.pegasys.teku.spec.datastructures.execution.versions.eip4844.BlobsSidecar; -import tech.pegasys.teku.spec.logic.versions.capella.helpers.MiscHelpersCapella; +import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.MiscHelpersBellatrix; import tech.pegasys.teku.spec.logic.versions.eip4844.types.VersionedHash; import tech.pegasys.teku.spec.logic.versions.eip4844.util.KZGUtilEip4844; -public class MiscHelpersEip4844 extends MiscHelpersCapella { +public class MiscHelpersEip4844 extends MiscHelpersBellatrix { public MiscHelpersEip4844(final SpecConfig specConfig) { super(specConfig);