mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 04:24:05 +00:00
fix regression in remote signing REST schema (#5294)
This commit is contained in:
parent
025b0e3f04
commit
c3584a9ea7
@ -218,22 +218,23 @@ proc installApiHandlers*(node: SigningNodeRef) =
|
|||||||
if node.config.expectedFeeRecipient.isNone():
|
if node.config.expectedFeeRecipient.isNone():
|
||||||
let
|
let
|
||||||
forkInfo = request.forkInfo.get()
|
forkInfo = request.forkInfo.get()
|
||||||
blockRoot = hash_tree_root(request.beaconBlock)
|
blockRoot = hash_tree_root(request.beaconBlockHeader)
|
||||||
signature = get_block_signature(forkInfo.fork,
|
signature = get_block_signature(
|
||||||
forkInfo.genesis_validators_root, request.beaconBlock.data.slot,
|
forkInfo.fork, forkInfo.genesis_validators_root,
|
||||||
blockRoot, validator.data.privateKey).toValidatorSig().toHex()
|
request.beaconBlockHeader.data.slot, blockRoot,
|
||||||
|
validator.data.privateKey).toValidatorSig().toHex()
|
||||||
return signatureResponse(Http200, signature)
|
return signatureResponse(Http200, signature)
|
||||||
|
|
||||||
let (feeRecipientIndex, blockHeader) =
|
let (feeRecipientIndex, blockHeader) =
|
||||||
case request.beaconBlock.kind
|
case request.beaconBlockHeader.kind
|
||||||
of ConsensusFork.Phase0, ConsensusFork.Altair:
|
of ConsensusFork.Phase0, ConsensusFork.Altair:
|
||||||
# `phase0` and `altair` blocks do not have `fee_recipient`, so
|
# `phase0` and `altair` blocks do not have `fee_recipient`, so
|
||||||
# we return an error.
|
# we return an error.
|
||||||
return errorResponse(Http400, BlockIncorrectFork)
|
return errorResponse(Http400, BlockIncorrectFork)
|
||||||
of ConsensusFork.Bellatrix, ConsensusFork.Capella:
|
of ConsensusFork.Bellatrix, ConsensusFork.Capella:
|
||||||
(GeneralizedIndex(401), request.beaconBlock.data)
|
(GeneralizedIndex(401), request.beaconBlockHeader.data)
|
||||||
of ConsensusFork.Deneb:
|
of ConsensusFork.Deneb:
|
||||||
(GeneralizedIndex(801), request.beaconBlock.data)
|
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
||||||
|
|
||||||
if request.proofs.isNone() or len(request.proofs.get()) == 0:
|
if request.proofs.isNone() or len(request.proofs.get()) == 0:
|
||||||
return errorResponse(Http400, MissingMerkleProofError)
|
return errorResponse(Http400, MissingMerkleProofError)
|
||||||
@ -254,10 +255,11 @@ proc installApiHandlers*(node: SigningNodeRef) =
|
|||||||
|
|
||||||
let
|
let
|
||||||
forkInfo = request.forkInfo.get()
|
forkInfo = request.forkInfo.get()
|
||||||
blockRoot = hash_tree_root(request.beaconBlock)
|
blockRoot = hash_tree_root(request.beaconBlockHeader)
|
||||||
signature = get_block_signature(forkInfo.fork,
|
signature = get_block_signature(forkInfo.fork,
|
||||||
forkInfo.genesis_validators_root, request.beaconBlock.data.slot,
|
forkInfo.genesis_validators_root,
|
||||||
blockRoot, validator.data.privateKey).toValidatorSig().toHex()
|
request.beaconBlockHeader.data.slot, blockRoot,
|
||||||
|
validator.data.privateKey).toValidatorSig().toHex()
|
||||||
signatureResponse(Http200, signature)
|
signatureResponse(Http200, signature)
|
||||||
of Web3SignerRequestKind.Deposit:
|
of Web3SignerRequestKind.Deposit:
|
||||||
let
|
let
|
||||||
|
@ -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
|
# 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.beginRecord()
|
||||||
writer.writeField("version", value.kind.toString.toUpperAscii)
|
writer.writeField("version", value.kind.toString.toUpperAscii)
|
||||||
writer.writeField("block", value.data)
|
writer.writeField("block_header", value.data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
proc writeValue*[
|
proc writeValue*[
|
||||||
@ -2109,8 +2109,8 @@ proc writeValue*(writer: var JsonWriter[RestJson],
|
|||||||
if isSome(value.signingRoot):
|
if isSome(value.signingRoot):
|
||||||
writer.writeField("signingRoot", 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
|
# https://github.com/Consensys/web3signer/blob/2d956c019663ac70f60640d23196d1d321c1b1fa/core/src/main/resources/openapi-specs/eth2/signing/schemas.yaml#L483-L500
|
||||||
writer.writeField("beacon_block", value.beaconBlock)
|
writer.writeField("beacon_block", value.beaconBlockHeader)
|
||||||
|
|
||||||
if isSome(value.proofs):
|
if isSome(value.proofs):
|
||||||
writer.writeField("proofs", value.proofs.get())
|
writer.writeField("proofs", value.proofs.get())
|
||||||
@ -2312,13 +2312,13 @@ proc readValue*(reader: var JsonReader[RestJson],
|
|||||||
if len(proofs) > 0:
|
if len(proofs) > 0:
|
||||||
Web3SignerRequest(
|
Web3SignerRequest(
|
||||||
kind: Web3SignerRequestKind.BlockV2,
|
kind: Web3SignerRequestKind.BlockV2,
|
||||||
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlock: data,
|
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlockHeader: data,
|
||||||
proofs: Opt.some(proofs)
|
proofs: Opt.some(proofs)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
Web3SignerRequest(
|
Web3SignerRequest(
|
||||||
kind: Web3SignerRequestKind.BlockV2,
|
kind: Web3SignerRequestKind.BlockV2,
|
||||||
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlock: data
|
forkInfo: forkInfo, signingRoot: signingRoot, beaconBlockHeader: data
|
||||||
)
|
)
|
||||||
of Web3SignerRequestKind.Deposit:
|
of Web3SignerRequestKind.Deposit:
|
||||||
if dataName != "deposit":
|
if dataName != "deposit":
|
||||||
|
@ -594,7 +594,9 @@ type
|
|||||||
of Web3SignerRequestKind.Attestation:
|
of Web3SignerRequestKind.Attestation:
|
||||||
attestation*: AttestationData
|
attestation*: AttestationData
|
||||||
of Web3SignerRequestKind.BlockV2:
|
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
|
serializedFieldName: "beacon_block".}: Web3SignerForkedBeaconBlock
|
||||||
proofs*: Opt[seq[Web3SignerMerkleProof]]
|
proofs*: Opt[seq[Web3SignerMerkleProof]]
|
||||||
of Web3SignerRequestKind.Deposit:
|
of Web3SignerRequestKind.Deposit:
|
||||||
@ -823,7 +825,7 @@ func init*(t: typedesc[Web3SignerRequest], fork: Fork,
|
|||||||
fork: fork, genesis_validators_root: genesis_validators_root
|
fork: fork, genesis_validators_root: genesis_validators_root
|
||||||
)),
|
)),
|
||||||
signingRoot: signingRoot,
|
signingRoot: signingRoot,
|
||||||
beaconBlock: data
|
beaconBlockHeader: data
|
||||||
)
|
)
|
||||||
|
|
||||||
func init*(t: typedesc[Web3SignerRequest], fork: Fork,
|
func init*(t: typedesc[Web3SignerRequest], fork: Fork,
|
||||||
@ -839,7 +841,7 @@ func init*(t: typedesc[Web3SignerRequest], fork: Fork,
|
|||||||
)),
|
)),
|
||||||
signingRoot: signingRoot,
|
signingRoot: signingRoot,
|
||||||
proofs: Opt.some(@proofs),
|
proofs: Opt.some(@proofs),
|
||||||
beaconBlock: data
|
beaconBlockHeader: data
|
||||||
)
|
)
|
||||||
|
|
||||||
func init*(t: typedesc[Web3SignerRequest], genesisForkVersion: Version,
|
func init*(t: typedesc[Web3SignerRequest], genesisForkVersion: Version,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user