diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java index ecf1da973f3..898b5cc117d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.encoding.CodeDelegationTransactionEncoder; +import org.hyperledger.besu.ethereum.core.json.ChainIdDeserializer; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import java.math.BigInteger; @@ -28,10 +29,13 @@ import java.util.function.Supplier; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.common.base.Suppliers; import org.apache.tuweni.bytes.Bytes; +@JsonIgnoreProperties(ignoreUnknown = true) public class CodeDelegation implements org.hyperledger.besu.datatypes.CodeDelegation { private static final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); @@ -77,14 +81,23 @@ public CodeDelegation( */ @JsonCreator public static org.hyperledger.besu.datatypes.CodeDelegation createCodeDelegation( - @JsonProperty("chainId") final BigInteger chainId, + @JsonProperty("chainId") @JsonDeserialize(using = ChainIdDeserializer.class) + final BigInteger chainId, @JsonProperty("address") final Address address, - @JsonProperty("nonce") final long nonce, - @JsonProperty("v") final byte v, - @JsonProperty("r") final BigInteger r, - @JsonProperty("s") final BigInteger s) { + @JsonProperty("nonce") final String nonce, + @JsonProperty("v") final String v, + @JsonProperty("r") final String r, + @JsonProperty("s") final String s) { return new CodeDelegation( - chainId, address, nonce, SIGNATURE_ALGORITHM.get().createSignature(r, s, v)); + chainId, + address, + Bytes.fromHexStringLenient(nonce).toLong(), + SIGNATURE_ALGORITHM + .get() + .createSignature( + Bytes.fromHexStringLenient(r).toUnsignedBigInteger(), + Bytes.fromHexStringLenient(s).toUnsignedBigInteger(), + Bytes.fromHexStringLenient(v).get(0))); } @JsonProperty("chainId") diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java index a36d3804323..5d1a6078715 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java @@ -75,6 +75,9 @@ public class StateTestVersionedTransaction { // String instead of VersionedHash because reference tests intentionally use bad hashes. private final List blobVersionedHashes; + @JsonDeserialize(contentAs = org.hyperledger.besu.ethereum.core.CodeDelegation.class) + private final List authorizationList; + /** * Constructor for populating a mock transaction with json data. * @@ -103,7 +106,9 @@ public StateTestVersionedTransaction( @JsonDeserialize(using = StateTestAccessListDeserializer.class) @JsonProperty("accessLists") final List> maybeAccessLists, @JsonProperty("maxFeePerBlobGas") final String maxFeePerBlobGas, - @JsonProperty("blobVersionedHashes") final List blobVersionedHashes) { + @JsonProperty("blobVersionedHashes") final List blobVersionedHashes, + @JsonProperty("authorizationList") + final List authorizationList) { this.nonce = Bytes.fromHexStringLenient(nonce).toLong(); this.gasPrice = Optional.ofNullable(gasPrice).map(Wei::fromHexString).orElse(null); @@ -124,6 +129,7 @@ public StateTestVersionedTransaction( this.maxFeePerBlobGas = Optional.ofNullable(maxFeePerBlobGas).map(Wei::fromHexString).orElse(null); this.blobVersionedHashes = blobVersionedHashes; + this.authorizationList = authorizationList; } private static List parseArray(final String[] array, final Function parseFct) { @@ -170,6 +176,7 @@ public Transaction get(final GeneralStateTestCaseSpec.Indexes indexes) { // versioned hash string was bad, so this is an invalid transaction return null; } + Optional.ofNullable(authorizationList).ifPresent(transactionBuilder::codeDelegations); transactionBuilder.guessType(); if (transactionBuilder.getTransactionType().requiresChainId()) {