fix regression in remote signing REST schema (#5294)

This commit is contained in:
tersec 2023-08-15 22:39:12 +00:00 committed by GitHub
parent 025b0e3f04
commit c3584a9ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 18 deletions

View File

@ -218,22 +218,23 @@ proc installApiHandlers*(node: SigningNodeRef) =
if node.config.expectedFeeRecipient.isNone():
let
forkInfo = request.forkInfo.get()
blockRoot = hash_tree_root(request.beaconBlock)
signature = get_block_signature(forkInfo.fork,
forkInfo.genesis_validators_root, request.beaconBlock.data.slot,
blockRoot, validator.data.privateKey).toValidatorSig().toHex()
blockRoot = hash_tree_root(request.beaconBlockHeader)
signature = get_block_signature(
forkInfo.fork, forkInfo.genesis_validators_root,
request.beaconBlockHeader.data.slot, blockRoot,
validator.data.privateKey).toValidatorSig().toHex()
return signatureResponse(Http200, signature)
let (feeRecipientIndex, blockHeader) =
case request.beaconBlock.kind
case request.beaconBlockHeader.kind
of ConsensusFork.Phase0, ConsensusFork.Altair:
# `phase0` and `altair` blocks do not have `fee_recipient`, so
# we return an error.
return errorResponse(Http400, BlockIncorrectFork)
of ConsensusFork.Bellatrix, ConsensusFork.Capella:
(GeneralizedIndex(401), request.beaconBlock.data)
(GeneralizedIndex(401), request.beaconBlockHeader.data)
of ConsensusFork.Deneb:
(GeneralizedIndex(801), request.beaconBlock.data)
(GeneralizedIndex(801), request.beaconBlockHeader.data)
if request.proofs.isNone() or len(request.proofs.get()) == 0:
return errorResponse(Http400, MissingMerkleProofError)
@ -254,10 +255,11 @@ proc installApiHandlers*(node: SigningNodeRef) =
let
forkInfo = request.forkInfo.get()
blockRoot = hash_tree_root(request.beaconBlock)
blockRoot = hash_tree_root(request.beaconBlockHeader)
signature = get_block_signature(forkInfo.fork,
forkInfo.genesis_validators_root, request.beaconBlock.data.slot,
blockRoot, validator.data.privateKey).toValidatorSig().toHex()
forkInfo.genesis_validators_root,
request.beaconBlockHeader.data.slot, blockRoot,
validator.data.privateKey).toValidatorSig().toHex()
signatureResponse(Http200, signature)
of Web3SignerRequestKind.Deposit:
let

View File

@ -1212,7 +1212,7 @@ proc writeValue*[
# https://github.com/ConsenSys/web3signer/blob/d51337e96ba5ce410222943556bed7c4856b8e57/core/src/main/java/tech/pegasys/web3signer/core/service/http/handlers/signing/eth2/json/BlockRequestDeserializer.java#L42-L58
writer.beginRecord()
writer.writeField("version", value.kind.toString.toUpperAscii)
writer.writeField("block", value.data)
writer.writeField("block_header", value.data)
writer.endRecord()
proc writeValue*[
@ -2109,8 +2109,8 @@ proc writeValue*(writer: var JsonWriter[RestJson],
if isSome(value.signingRoot):
writer.writeField("signingRoot", value.signingRoot)
# https://github.com/ConsenSys/web3signer/blob/41c0cbfabcb1fca9587b59e058b7eb29f152c60c/core/src/main/resources/openapi-specs/eth2/signing/schemas.yaml#L418-L497
writer.writeField("beacon_block", value.beaconBlock)
# https://github.com/Consensys/web3signer/blob/2d956c019663ac70f60640d23196d1d321c1b1fa/core/src/main/resources/openapi-specs/eth2/signing/schemas.yaml#L483-L500
writer.writeField("beacon_block", value.beaconBlockHeader)
if isSome(value.proofs):
writer.writeField("proofs", value.proofs.get())
@ -2312,13 +2312,13 @@ proc readValue*(reader: var JsonReader[RestJson],
if len(proofs) > 0:
Web3SignerRequest(
kind: Web3SignerRequestKind.BlockV2,
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlock: data,
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlockHeader: data,
proofs: Opt.some(proofs)
)
else:
Web3SignerRequest(
kind: Web3SignerRequestKind.BlockV2,
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlock: data
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlockHeader: data
)
of Web3SignerRequestKind.Deposit:
if dataName != "deposit":

View File

@ -594,7 +594,9 @@ type
of Web3SignerRequestKind.Attestation:
attestation*: AttestationData
of Web3SignerRequestKind.BlockV2:
beaconBlock* {.
# https://consensys.github.io/web3signer/web3signer-eth2.html#tag/Signing/operation/ETH2_SIGN
# https://github.com/Consensys/web3signer/blob/2d956c019663ac70f60640d23196d1d321c1b1fa/core/src/main/resources/openapi-specs/eth2/signing/schemas.yaml#L483-L500
beaconBlockHeader* {.
serializedFieldName: "beacon_block".}: Web3SignerForkedBeaconBlock
proofs*: Opt[seq[Web3SignerMerkleProof]]
of Web3SignerRequestKind.Deposit:
@ -823,7 +825,7 @@ func init*(t: typedesc[Web3SignerRequest], fork: Fork,
fork: fork, genesis_validators_root: genesis_validators_root
)),
signingRoot: signingRoot,
beaconBlock: data
beaconBlockHeader: data
)
func init*(t: typedesc[Web3SignerRequest], fork: Fork,
@ -839,7 +841,7 @@ func init*(t: typedesc[Web3SignerRequest], fork: Fork,
)),
signingRoot: signingRoot,
proofs: Opt.some(@proofs),
beaconBlock: data
beaconBlockHeader: data
)
func init*(t: typedesc[Web3SignerRequest], genesisForkVersion: Version,