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.
Added Consolidation Request containers (Consensys#8392)
- Loading branch information
1 parent
0480cde
commit 8b256c0
Showing
42 changed files
with
1,751 additions
and
270 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...on-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/ConsolidationRequest.json
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,25 @@ | ||
{ | ||
"title" : "ConsolidationRequest", | ||
"type" : "object", | ||
"required" : [ "source_address", "source_pubkey", "target_pubkey" ], | ||
"properties" : { | ||
"source_address" : { | ||
"type" : "string", | ||
"pattern" : "^0x[a-fA-F0-9]{2,}$", | ||
"description" : "SSZ hexadecimal", | ||
"format" : "bytes" | ||
}, | ||
"source_pubkey" : { | ||
"type" : "string", | ||
"pattern" : "^0x[a-fA-F0-9]{2,}$", | ||
"description" : "Bytes48 hexadecimal", | ||
"format" : "bytes" | ||
}, | ||
"target_pubkey" : { | ||
"type" : "string", | ||
"pattern" : "^0x[a-fA-F0-9]{2,}$", | ||
"description" : "Bytes48 hexadecimal", | ||
"format" : "bytes" | ||
} | ||
} | ||
} |
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
139 changes: 70 additions & 69 deletions
139
...integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlindedBlockELECTRA.json
Large diffs are not rendered by default.
Oops, something went wrong.
160 changes: 82 additions & 78 deletions
160
...ntegration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlockContentsELECTRA.json
Large diffs are not rendered by default.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/ConsolidationRequest.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,54 @@ | ||
/* | ||
* 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.api.schema.electra; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import tech.pegasys.teku.bls.BLSPublicKey; | ||
import tech.pegasys.teku.ethereum.execution.types.Eth1Address; | ||
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequestSchema; | ||
|
||
public class ConsolidationRequest { | ||
|
||
@JsonProperty("source_address") | ||
private final Eth1Address sourceAddress; | ||
|
||
@JsonProperty("source_pubkey") | ||
private final BLSPublicKey sourcePubkey; | ||
|
||
@JsonProperty("target_pubkey") | ||
private final BLSPublicKey targetPubkey; | ||
|
||
public ConsolidationRequest( | ||
@JsonProperty("source_address") final Eth1Address sourceAddress, | ||
@JsonProperty("source_pubkey") final BLSPublicKey sourcePubkey, | ||
@JsonProperty("target_pubkey") final BLSPublicKey targetPubkey) { | ||
this.sourceAddress = sourceAddress; | ||
this.sourcePubkey = sourcePubkey; | ||
this.targetPubkey = targetPubkey; | ||
} | ||
|
||
public ConsolidationRequest( | ||
final tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest | ||
consolidationRequest) { | ||
this.sourceAddress = | ||
Eth1Address.fromBytes(consolidationRequest.getSourceAddress().getWrappedBytes()); | ||
this.sourcePubkey = consolidationRequest.getSourcePubkey(); | ||
this.targetPubkey = consolidationRequest.getTargetPubkey(); | ||
} | ||
|
||
public final tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest | ||
asInternalConsolidationRequest(final ConsolidationRequestSchema schema) { | ||
return schema.create(sourceAddress, sourcePubkey, targetPubkey); | ||
} | ||
} |
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
82 changes: 82 additions & 0 deletions
82
...c/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ConsolidationRequestV1.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,82 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2024 | ||
* | ||
* 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.ethereum.executionclient.schema; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.google.common.base.MoreObjects; | ||
import java.util.Objects; | ||
import org.apache.tuweni.bytes.Bytes48; | ||
import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes20Deserializer; | ||
import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes20Serializer; | ||
import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes48Deserializer; | ||
import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; | ||
import tech.pegasys.teku.infrastructure.bytes.Bytes20; | ||
|
||
public class ConsolidationRequestV1 { | ||
@JsonSerialize(using = Bytes20Serializer.class) | ||
@JsonDeserialize(using = Bytes20Deserializer.class) | ||
public final Bytes20 sourceAddress; | ||
|
||
@JsonSerialize(using = BytesSerializer.class) | ||
@JsonDeserialize(using = Bytes48Deserializer.class) | ||
public final Bytes48 sourcePubkey; | ||
|
||
@JsonSerialize(using = BytesSerializer.class) | ||
@JsonDeserialize(using = Bytes48Deserializer.class) | ||
public final Bytes48 targetPubkey; | ||
|
||
public ConsolidationRequestV1( | ||
@JsonProperty("sourceAddress") final Bytes20 sourceAddress, | ||
@JsonProperty("sourcePubkey") final Bytes48 sourcePubkey, | ||
@JsonProperty("targetPubkey") final Bytes48 targetPubkey) { | ||
checkNotNull(sourceAddress, "sourceAddress"); | ||
checkNotNull(sourcePubkey, "sourcePubkey"); | ||
checkNotNull(targetPubkey, "targetPubkey"); | ||
this.sourceAddress = sourceAddress; | ||
this.sourcePubkey = sourcePubkey; | ||
this.targetPubkey = targetPubkey; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
final ConsolidationRequestV1 that = (ConsolidationRequestV1) o; | ||
return Objects.equals(sourceAddress, that.sourceAddress) | ||
&& Objects.equals(sourcePubkey, that.sourcePubkey) | ||
&& Objects.equals(targetPubkey, that.targetPubkey); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(sourceAddress, sourceAddress, targetPubkey); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("sourceAddress", sourceAddress) | ||
.add("sourcePubkey", sourcePubkey) | ||
.add("targetPubkey", targetPubkey) | ||
.toString(); | ||
} | ||
} |
Oops, something went wrong.