rm Web3Signer Bellatrix block support (#6061)

This commit is contained in:
tersec 2024-03-11 22:09:31 +00:00 committed by GitHub
parent 7d06edb7c9
commit fd8429da74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 14 additions and 188 deletions

View File

@ -649,18 +649,16 @@ OK: 8/8 Fail: 0/8 Skip: 0/8
OK: 3/3 Fail: 0/3 Skip: 0/3 OK: 3/3 Fail: 0/3 Skip: 0/3
## Nimbus remote signer/signing test (verifying-web3signer) ## Nimbus remote signer/signing test (verifying-web3signer)
```diff ```diff
+ Signing BeaconBlock (getBlockSignature(bellatrix)) OK
+ Signing BeaconBlock (getBlockSignature(capella)) OK + Signing BeaconBlock (getBlockSignature(capella)) OK
+ Signing BeaconBlock (getBlockSignature(deneb)) OK + Signing BeaconBlock (getBlockSignature(deneb)) OK
+ Waiting for signing node (/upcheck) test OK + Waiting for signing node (/upcheck) test OK
``` ```
OK: 4/4 Fail: 0/4 Skip: 0/4 OK: 3/3 Fail: 0/3 Skip: 0/3
## Nimbus remote signer/signing test (web3signer) ## Nimbus remote signer/signing test (web3signer)
```diff ```diff
+ Connection timeout test OK + Connection timeout test OK
+ Public keys enumeration (/api/v1/eth2/publicKeys) test OK + Public keys enumeration (/api/v1/eth2/publicKeys) test OK
+ Public keys reload (/reload) test OK + Public keys reload (/reload) test OK
+ Signing BeaconBlock (getBlockSignature(bellatrix)) OK
+ Signing BeaconBlock (getBlockSignature(capella)) OK + Signing BeaconBlock (getBlockSignature(capella)) OK
+ Signing BeaconBlock (getBlockSignature(deneb)) OK + Signing BeaconBlock (getBlockSignature(deneb)) OK
+ Signing SC contribution and proof (getContributionAndProofSignature()) OK + Signing SC contribution and proof (getContributionAndProofSignature()) OK
@ -675,7 +673,7 @@ OK: 4/4 Fail: 0/4 Skip: 0/4
+ Signing voluntary exit (getValidatorExitSignature()) OK + Signing voluntary exit (getValidatorExitSignature()) OK
+ Waiting for signing node (/upcheck) test OK + Waiting for signing node (/upcheck) test OK
``` ```
OK: 17/17 Fail: 0/17 Skip: 0/17 OK: 16/16 Fail: 0/16 Skip: 0/16
## Old database versions [Preset: mainnet] ## Old database versions [Preset: mainnet]
```diff ```diff
+ pre-1.1.0 OK + pre-1.1.0 OK
@ -1008,4 +1006,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9 OK: 9/9 Fail: 0/9 Skip: 0/9
---TOTAL--- ---TOTAL---
OK: 677/682 Fail: 0/682 Skip: 5/682 OK: 675/680 Fail: 0/680 Skip: 5/680

View File

@ -229,11 +229,11 @@ proc installApiHandlers*(node: SigningNodeRef) =
let (feeRecipientIndex, blockHeader) = let (feeRecipientIndex, blockHeader) =
case request.beaconBlockHeader.kind case request.beaconBlockHeader.kind
of ConsensusFork.Phase0, ConsensusFork.Altair: of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix:
# `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.Capella:
(GeneralizedIndex(401), request.beaconBlockHeader.data) (GeneralizedIndex(401), request.beaconBlockHeader.data)
of ConsensusFork.Deneb: of ConsensusFork.Deneb:
(GeneralizedIndex(801), request.beaconBlockHeader.data) (GeneralizedIndex(801), request.beaconBlockHeader.data)

View File

@ -150,7 +150,6 @@ type
ProvenProperty* = object ProvenProperty* = object
path*: string path*: string
description*: Option[string] description*: Option[string]
bellatrixIndex*: Option[GeneralizedIndex]
capellaIndex*: Option[GeneralizedIndex] capellaIndex*: Option[GeneralizedIndex]
denebIndex*: Option[GeneralizedIndex] denebIndex*: Option[GeneralizedIndex]
@ -728,7 +727,6 @@ func parseProvenBlockProperty*(propertyPath: string): Result[ProvenProperty, str
if propertyPath == ".execution_payload.fee_recipient": if propertyPath == ".execution_payload.fee_recipient":
ok ProvenProperty( ok ProvenProperty(
path: propertyPath, path: propertyPath,
bellatrixIndex: some GeneralizedIndex(401),
capellaIndex: some GeneralizedIndex(401), capellaIndex: some GeneralizedIndex(401),
denebIndex: some GeneralizedIndex(801)) denebIndex: some GeneralizedIndex(801))
elif propertyPath == ".graffiti": elif propertyPath == ".graffiti":
@ -736,7 +734,6 @@ func parseProvenBlockProperty*(propertyPath: string): Result[ProvenProperty, str
path: propertyPath, path: propertyPath,
# TODO: graffiti is present since genesis, so the correct index in the early # TODO: graffiti is present since genesis, so the correct index in the early
# forks can be supplied here # forks can be supplied here
bellatrixIndex: some GeneralizedIndex(18),
capellaIndex: some GeneralizedIndex(18), capellaIndex: some GeneralizedIndex(18),
denebIndex: some GeneralizedIndex(18)) denebIndex: some GeneralizedIndex(18))
else: else:
@ -845,13 +842,11 @@ proc readValue*(reader: var JsonReader, value: var RemoteKeystore)
var provenProperties = reader.readValue(seq[ProvenProperty]) var provenProperties = reader.readValue(seq[ProvenProperty])
for prop in provenProperties.mitems: for prop in provenProperties.mitems:
if prop.path == ".execution_payload.fee_recipient": if prop.path == ".execution_payload.fee_recipient":
prop.bellatrixIndex = some GeneralizedIndex(401)
prop.capellaIndex = some GeneralizedIndex(401) prop.capellaIndex = some GeneralizedIndex(401)
prop.denebIndex = some GeneralizedIndex(801) prop.denebIndex = some GeneralizedIndex(801)
elif prop.path == ".graffiti": elif prop.path == ".graffiti":
# TODO: graffiti is present since genesis, so the correct index in the early # TODO: graffiti is present since genesis, so the correct index in the early
# forks can be supplied here # forks can be supplied here
prop.bellatrixIndex = some GeneralizedIndex(18)
prop.capellaIndex = some GeneralizedIndex(18) prop.capellaIndex = some GeneralizedIndex(18)
prop.denebIndex = some GeneralizedIndex(18) prop.denebIndex = some GeneralizedIndex(18)
else: else:

View File

@ -506,7 +506,6 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
): Future[SignatureResult] ): Future[SignatureResult]
{.async: (raises: [CancelledError]).} = {.async: (raises: [CancelledError]).} =
type SomeBlockBody = type SomeBlockBody =
bellatrix.BeaconBlockBody |
capella.BeaconBlockBody | capella.BeaconBlockBody |
deneb.BeaconBlockBody | deneb.BeaconBlockBody |
deneb_mev.BlindedBeaconBlockBody deneb_mev.BlindedBeaconBlockBody
@ -567,24 +566,8 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
elif blck is ForkedMaybeBlindedBeaconBlock: elif blck is ForkedMaybeBlindedBeaconBlock:
withForkyMaybeBlindedBlck(blck): withForkyMaybeBlindedBlck(blck):
# TODO why isn't this a case statement # TODO why isn't this a case statement
when consensusFork < ConsensusFork.Bellatrix: when consensusFork < ConsensusFork.Capella:
return SignatureResult.err("Invalid beacon block fork") return SignatureResult.err("Invalid beacon block fork")
elif consensusFork == ConsensusFork.Bellatrix:
when isBlinded:
return SignatureResult.err("Invalid blinded beacon block fork")
else:
case v.data.remoteType
of RemoteSignerType.Web3Signer:
Web3SignerRequest.init(fork, genesis_validators_root,
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Bellatrix,
data: forkyMaybeBlindedBlck.toBeaconBlockHeader))
of RemoteSignerType.VerifyingWeb3Signer:
let proofs = blockPropertiesProofs(
blck.bellatrixData.body, bellatrixIndex)
Web3SignerRequest.init(fork, genesis_validators_root,
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Bellatrix,
data: forkyMaybeBlindedBlck.toBeaconBlockHeader),
proofs)
elif consensusFork == ConsensusFork.Capella: elif consensusFork == ConsensusFork.Capella:
when isBlinded: when isBlinded:
return SignatureResult.err("Invalid blinded beacon block fork") return SignatureResult.err("Invalid blinded beacon block fork")
@ -632,21 +615,8 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
proofs) proofs)
else: else:
case blck.kind case blck.kind
of ConsensusFork.Phase0, ConsensusFork.Altair: of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix:
return SignatureResult.err("Invalid beacon block fork") return SignatureResult.err("Invalid beacon block fork")
of ConsensusFork.Bellatrix:
case v.data.remoteType
of RemoteSignerType.Web3Signer:
Web3SignerRequest.init(fork, genesis_validators_root,
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Bellatrix,
data: blck.bellatrixData.toBeaconBlockHeader))
of RemoteSignerType.VerifyingWeb3Signer:
let proofs = blockPropertiesProofs(
blck.bellatrixData.body, bellatrixIndex)
Web3SignerRequest.init(fork, genesis_validators_root,
Web3SignerForkedBeaconBlock(kind: ConsensusFork.Bellatrix,
data: blck.bellatrixData.toBeaconBlockHeader),
proofs)
of ConsensusFork.Capella: of ConsensusFork.Capella:
case v.data.remoteType case v.data.remoteType
of RemoteSignerType.Web3Signer: of RemoteSignerType.Web3Signer:

View File

@ -135,7 +135,6 @@ suite "Remove keystore testing suite":
check keystore.remotes[0].id == 0 check keystore.remotes[0].id == 0
check keystore.remotes[0].pubkey.toHex == "8b9c875fbe539c6429c4fc304675062579ce47fb6b2ac6b6a1ba1188ca123a80affbfe381dbbc8e7f2437709a4c3325c" check keystore.remotes[0].pubkey.toHex == "8b9c875fbe539c6429c4fc304675062579ce47fb6b2ac6b6a1ba1188ca123a80affbfe381dbbc8e7f2437709a4c3325c"
check keystore.provenBlockProperties.len == 1 check keystore.provenBlockProperties.len == 1
check keystore.provenBlockProperties[0].bellatrixIndex == some GeneralizedIndex(401)
check keystore.provenBlockProperties[0].capellaIndex == some GeneralizedIndex(401) check keystore.provenBlockProperties[0].capellaIndex == some GeneralizedIndex(401)
check keystore.provenBlockProperties[0].denebIndex == some GeneralizedIndex(801) check keystore.provenBlockProperties[0].denebIndex == some GeneralizedIndex(801)
@ -184,6 +183,5 @@ suite "Remove keystore testing suite":
check keystore.remotes[2].pubkey.toHex == "8f5f9e305e7fcbde94182747f5ecec573d1786e8320a920347a74c0ff5e70f12ca22607c98fdc8dbe71161db59e0ac9d" check keystore.remotes[2].pubkey.toHex == "8f5f9e305e7fcbde94182747f5ecec573d1786e8320a920347a74c0ff5e70f12ca22607c98fdc8dbe71161db59e0ac9d"
check keystore.threshold == 2 check keystore.threshold == 2
check keystore.provenBlockProperties.len == 1 check keystore.provenBlockProperties.len == 1
check keystore.provenBlockProperties[0].bellatrixIndex == some GeneralizedIndex(401)
check keystore.provenBlockProperties[0].capellaIndex == some GeneralizedIndex(401) check keystore.provenBlockProperties[0].capellaIndex == some GeneralizedIndex(401)
check keystore.provenBlockProperties[0].denebIndex == some GeneralizedIndex(801) check keystore.provenBlockProperties[0].denebIndex == some GeneralizedIndex(801)

View File

@ -63,7 +63,6 @@ const
AgAttestation = "{\"data\":{\"aggregation_bits\":\"0x01\",\"signature\":\"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505\",\"data\":{\"slot\":\"1\",\"index\":\"1\",\"beacon_block_root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\",\"source\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"},\"target\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"}}}}" AgAttestation = "{\"data\":{\"aggregation_bits\":\"0x01\",\"signature\":\"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505\",\"data\":{\"slot\":\"1\",\"index\":\"1\",\"beacon_block_root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\",\"source\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"},\"target\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"}}}}"
BellatrixBlock = "{\"version\":\"bellatrix\",\"data\":{\"slot\":\"5297696\",\"proposer_index\":\"153094\",\"parent_root\":\"0xe6106533af9be918120ead7440a8006c7f123cc3cb7daf1f11d951864abea014\",\"state_root\":\"0xf86196d34500ca25d1f4e7431d4d52f6f85540bcaf97dd0d2ad9ecdb3eebcdf0\",\"body\":{\"randao_reveal\":\"0xa7efee3d5ddceb60810b23e3b5d39734696418f41dfd13a0851c7be7a72acbdceaa61e1db27513801917d72519d1c1040ccfed829faf06abe06d9964949554bf4369134b66de715ea49eb4fecf3e2b7e646f1764a1993e31e53dbc6557929c12\",\"eth1_data\":{\"deposit_root\":\"0x8ec87d7219a3c873fff3bfe206b4f923d1b471ce4ff9d6d6ecc162ef07825e14\",\"deposit_count\":\"259476\",\"block_hash\":\"0x877b6f8332c7397251ff3f0c5cecec105ff7d4cb78251b47f91fd15a86a565ab\"},\"graffiti\":\"\",\"proposer_slashings\":[],\"attester_slashings\":[],\"attestations\":[],\"deposits\":[],\"voluntary_exits\":[],\"sync_aggregate\":{\"sync_committee_bits\":\"0x733dfda7f5ffde5ade73367fcbf7fffeef7fe43777ffdffab9dbad6f7eed5fff9bfec4affdefbfaddf35bf5efbff9ffff9dfd7dbf97fbfcdfaddfeffbf95f75f\",\"sync_committee_signature\":\"0x81fdf76e797f81b0116a1c1ae5200b613c8041115223cd89e8bd5477aab13de6097a9ebf42b130c59527bbb4c96811b809353a17c717549f82d4bd336068ef0b99b1feebd4d2432a69fa77fac12b78f1fcc9d7b59edbeb381adf10b15bc4a520\"},\"execution_payload\":{\"parent_hash\":\"0x14c2242a8cfbce559e84c391f5f16d10d7719751b8558873012dc88ae5a193e8\",\"fee_recipient\":\"$1\",\"state_root\":\"0xdf8d96b2c292736d39e72e25802c2744d34d3d3c616de5b362425cab01f72fa5\",\"receipts_root\":\"0x4938a2bf640846d213b156a1a853548b369cd02917fa63d8766ab665d7930bac\",\"logs_bloom\":\"0x298610600038408c201080013832408850a00bc8f801920121840030a015310010e2a0e0108628110552062811441c84802f43825c4fc82140b036c58025a28800054c80a44025c052090a0f2c209a0400058040019ea0008e589084078048050880930113a2894082e0112408b088382402a851621042212aa40018a408d07e178c68691486411aa9a2809043b000a04c040000065a030028018540b04b1820271d00821b00c29059095022322c10a530060223240416140190056608200063c82248274ba8f0098e402041cd9f451031481a1010b8220824833520490221071898802d206348449116812280014a10a2d1c210100a30010802490f0a221849\",\"prev_randao\":\"0xc061711e135cd40531ec3ee29d17d3824c0e5f80d07f721e792ab83240aa0ab5\",\"block_number\":\"8737497\",\"gas_limit\":\"30000000\",\"gas_used\":\"16367052\",\"timestamp\":\"1680080352\",\"extra_data\":\"0xd883010b05846765746888676f312e32302e32856c696e7578\",\"base_fee_per_gas\":\"231613172261\",\"block_hash\":\"0x5aa9fd22a9238925adb2b038fd6eafc77adabf554051db5bc16ae5168a52eff6\",\"transactions\":[],\"withdrawals\":[]}}}}"
CapellaBlock = "{\"version\":\"capella\",\"data\":{\"slot\":\"5297696\",\"proposer_index\":\"153094\",\"parent_root\":\"0xe6106533af9be918120ead7440a8006c7f123cc3cb7daf1f11d951864abea014\",\"state_root\":\"0xf86196d34500ca25d1f4e7431d4d52f6f85540bcaf97dd0d2ad9ecdb3eebcdf0\",\"body\":{\"randao_reveal\":\"0xa7efee3d5ddceb60810b23e3b5d39734696418f41dfd13a0851c7be7a72acbdceaa61e1db27513801917d72519d1c1040ccfed829faf06abe06d9964949554bf4369134b66de715ea49eb4fecf3e2b7e646f1764a1993e31e53dbc6557929c12\",\"eth1_data\":{\"deposit_root\":\"0x8ec87d7219a3c873fff3bfe206b4f923d1b471ce4ff9d6d6ecc162ef07825e14\",\"deposit_count\":\"259476\",\"block_hash\":\"0x877b6f8332c7397251ff3f0c5cecec105ff7d4cb78251b47f91fd15a86a565ab\"},\"graffiti\":\"\",\"proposer_slashings\":[],\"attester_slashings\":[],\"attestations\":[],\"deposits\":[],\"voluntary_exits\":[],\"sync_aggregate\":{\"sync_committee_bits\":\"0x733dfda7f5ffde5ade73367fcbf7fffeef7fe43777ffdffab9dbad6f7eed5fff9bfec4affdefbfaddf35bf5efbff9ffff9dfd7dbf97fbfcdfaddfeffbf95f75f\",\"sync_committee_signature\":\"0x81fdf76e797f81b0116a1c1ae5200b613c8041115223cd89e8bd5477aab13de6097a9ebf42b130c59527bbb4c96811b809353a17c717549f82d4bd336068ef0b99b1feebd4d2432a69fa77fac12b78f1fcc9d7b59edbeb381adf10b15bc4a520\"},\"execution_payload\":{\"parent_hash\":\"0x14c2242a8cfbce559e84c391f5f16d10d7719751b8558873012dc88ae5a193e8\",\"fee_recipient\":\"$1\",\"state_root\":\"0xdf8d96b2c292736d39e72e25802c2744d34d3d3c616de5b362425cab01f72fa5\",\"receipts_root\":\"0x4938a2bf640846d213b156a1a853548b369cd02917fa63d8766ab665d7930bac\",\"logs_bloom\":\"0x298610600038408c201080013832408850a00bc8f801920121840030a015310010e2a0e0108628110552062811441c84802f43825c4fc82140b036c58025a28800054c80a44025c052090a0f2c209a0400058040019ea0008e589084078048050880930113a2894082e0112408b088382402a851621042212aa40018a408d07e178c68691486411aa9a2809043b000a04c040000065a030028018540b04b1820271d00821b00c29059095022322c10a530060223240416140190056608200063c82248274ba8f0098e402041cd9f451031481a1010b8220824833520490221071898802d206348449116812280014a10a2d1c210100a30010802490f0a221849\",\"prev_randao\":\"0xc061711e135cd40531ec3ee29d17d3824c0e5f80d07f721e792ab83240aa0ab5\",\"block_number\":\"8737497\",\"gas_limit\":\"30000000\",\"gas_used\":\"16367052\",\"timestamp\":\"1680080352\",\"extra_data\":\"0xd883010b05846765746888676f312e32302e32856c696e7578\",\"base_fee_per_gas\":\"231613172261\",\"block_hash\":\"0x5aa9fd22a9238925adb2b038fd6eafc77adabf554051db5bc16ae5168a52eff6\",\"transactions\":[],\"withdrawals\":[]},\"bls_to_execution_changes\":[]}}}" CapellaBlock = "{\"version\":\"capella\",\"data\":{\"slot\":\"5297696\",\"proposer_index\":\"153094\",\"parent_root\":\"0xe6106533af9be918120ead7440a8006c7f123cc3cb7daf1f11d951864abea014\",\"state_root\":\"0xf86196d34500ca25d1f4e7431d4d52f6f85540bcaf97dd0d2ad9ecdb3eebcdf0\",\"body\":{\"randao_reveal\":\"0xa7efee3d5ddceb60810b23e3b5d39734696418f41dfd13a0851c7be7a72acbdceaa61e1db27513801917d72519d1c1040ccfed829faf06abe06d9964949554bf4369134b66de715ea49eb4fecf3e2b7e646f1764a1993e31e53dbc6557929c12\",\"eth1_data\":{\"deposit_root\":\"0x8ec87d7219a3c873fff3bfe206b4f923d1b471ce4ff9d6d6ecc162ef07825e14\",\"deposit_count\":\"259476\",\"block_hash\":\"0x877b6f8332c7397251ff3f0c5cecec105ff7d4cb78251b47f91fd15a86a565ab\"},\"graffiti\":\"\",\"proposer_slashings\":[],\"attester_slashings\":[],\"attestations\":[],\"deposits\":[],\"voluntary_exits\":[],\"sync_aggregate\":{\"sync_committee_bits\":\"0x733dfda7f5ffde5ade73367fcbf7fffeef7fe43777ffdffab9dbad6f7eed5fff9bfec4affdefbfaddf35bf5efbff9ffff9dfd7dbf97fbfcdfaddfeffbf95f75f\",\"sync_committee_signature\":\"0x81fdf76e797f81b0116a1c1ae5200b613c8041115223cd89e8bd5477aab13de6097a9ebf42b130c59527bbb4c96811b809353a17c717549f82d4bd336068ef0b99b1feebd4d2432a69fa77fac12b78f1fcc9d7b59edbeb381adf10b15bc4a520\"},\"execution_payload\":{\"parent_hash\":\"0x14c2242a8cfbce559e84c391f5f16d10d7719751b8558873012dc88ae5a193e8\",\"fee_recipient\":\"$1\",\"state_root\":\"0xdf8d96b2c292736d39e72e25802c2744d34d3d3c616de5b362425cab01f72fa5\",\"receipts_root\":\"0x4938a2bf640846d213b156a1a853548b369cd02917fa63d8766ab665d7930bac\",\"logs_bloom\":\"0x298610600038408c201080013832408850a00bc8f801920121840030a015310010e2a0e0108628110552062811441c84802f43825c4fc82140b036c58025a28800054c80a44025c052090a0f2c209a0400058040019ea0008e589084078048050880930113a2894082e0112408b088382402a851621042212aa40018a408d07e178c68691486411aa9a2809043b000a04c040000065a030028018540b04b1820271d00821b00c29059095022322c10a530060223240416140190056608200063c82248274ba8f0098e402041cd9f451031481a1010b8220824833520490221071898802d206348449116812280014a10a2d1c210100a30010802490f0a221849\",\"prev_randao\":\"0xc061711e135cd40531ec3ee29d17d3824c0e5f80d07f721e792ab83240aa0ab5\",\"block_number\":\"8737497\",\"gas_limit\":\"30000000\",\"gas_used\":\"16367052\",\"timestamp\":\"1680080352\",\"extra_data\":\"0xd883010b05846765746888676f312e32302e32856c696e7578\",\"base_fee_per_gas\":\"231613172261\",\"block_hash\":\"0x5aa9fd22a9238925adb2b038fd6eafc77adabf554051db5bc16ae5168a52eff6\",\"transactions\":[],\"withdrawals\":[]},\"bls_to_execution_changes\":[]}}}"
DenebBlockContents = "{\"version\":\"deneb\",\"data\":{\"block\":{\"slot\":\"5297696\",\"proposer_index\":\"153094\",\"parent_root\":\"0xe6106533af9be918120ead7440a8006c7f123cc3cb7daf1f11d951864abea014\",\"state_root\":\"0xf86196d34500ca25d1f4e7431d4d52f6f85540bcaf97dd0d2ad9ecdb3eebcdf0\",\"body\":{\"randao_reveal\":\"0xa7efee3d5ddceb60810b23e3b5d39734696418f41dfd13a0851c7be7a72acbdceaa61e1db27513801917d72519d1c1040ccfed829faf06abe06d9964949554bf4369134b66de715ea49eb4fecf3e2b7e646f1764a1993e31e53dbc6557929c12\",\"eth1_data\":{\"deposit_root\":\"0x8ec87d7219a3c873fff3bfe206b4f923d1b471ce4ff9d6d6ecc162ef07825e14\",\"deposit_count\":\"259476\",\"block_hash\":\"0x877b6f8332c7397251ff3f0c5cecec105ff7d4cb78251b47f91fd15a86a565ab\"},\"graffiti\":\"\",\"proposer_slashings\":[],\"attester_slashings\":[],\"attestations\":[],\"deposits\":[],\"voluntary_exits\":[],\"sync_aggregate\":{\"sync_committee_bits\":\"0x733dfda7f5ffde5ade73367fcbf7fffeef7fe43777ffdffab9dbad6f7eed5fff9bfec4affdefbfaddf35bf5efbff9ffff9dfd7dbf97fbfcdfaddfeffbf95f75f\",\"sync_committee_signature\":\"0x81fdf76e797f81b0116a1c1ae5200b613c8041115223cd89e8bd5477aab13de6097a9ebf42b130c59527bbb4c96811b809353a17c717549f82d4bd336068ef0b99b1feebd4d2432a69fa77fac12b78f1fcc9d7b59edbeb381adf10b15bc4a520\"},\"execution_payload\":{\"parent_hash\":\"0x14c2242a8cfbce559e84c391f5f16d10d7719751b8558873012dc88ae5a193e8\",\"fee_recipient\":\"$1\",\"state_root\":\"0xdf8d96b2c292736d39e72e25802c2744d34d3d3c616de5b362425cab01f72fa5\",\"receipts_root\":\"0x4938a2bf640846d213b156a1a853548b369cd02917fa63d8766ab665d7930bac\",\"logs_bloom\":\"0x298610600038408c201080013832408850a00bc8f801920121840030a015310010e2a0e0108628110552062811441c84802f43825c4fc82140b036c58025a28800054c80a44025c052090a0f2c209a0400058040019ea0008e589084078048050880930113a2894082e0112408b088382402a851621042212aa40018a408d07e178c68691486411aa9a2809043b000a04c040000065a030028018540b04b1820271d00821b00c29059095022322c10a530060223240416140190056608200063c82248274ba8f0098e402041cd9f451031481a1010b8220824833520490221071898802d206348449116812280014a10a2d1c210100a30010802490f0a221849\",\"prev_randao\":\"0xc061711e135cd40531ec3ee29d17d3824c0e5f80d07f721e792ab83240aa0ab5\",\"block_number\":\"8737497\",\"gas_limit\":\"30000000\",\"gas_used\":\"16367052\",\"timestamp\":\"1680080352\",\"extra_data\":\"0xd883010b05846765746888676f312e32302e32856c696e7578\",\"base_fee_per_gas\":\"231613172261\",\"block_hash\":\"0x5aa9fd22a9238925adb2b038fd6eafc77adabf554051db5bc16ae5168a52eff6\",\"transactions\":[],\"withdrawals\":[],\"blob_gas_used\":\"2316131761\",\"excess_blob_gas\":\"231613172261\"},\"bls_to_execution_changes\":[],\"blob_kzg_commitments\":[]}},\"kzg_proofs\":[],\"blobs\":[]}}" DenebBlockContents = "{\"version\":\"deneb\",\"data\":{\"block\":{\"slot\":\"5297696\",\"proposer_index\":\"153094\",\"parent_root\":\"0xe6106533af9be918120ead7440a8006c7f123cc3cb7daf1f11d951864abea014\",\"state_root\":\"0xf86196d34500ca25d1f4e7431d4d52f6f85540bcaf97dd0d2ad9ecdb3eebcdf0\",\"body\":{\"randao_reveal\":\"0xa7efee3d5ddceb60810b23e3b5d39734696418f41dfd13a0851c7be7a72acbdceaa61e1db27513801917d72519d1c1040ccfed829faf06abe06d9964949554bf4369134b66de715ea49eb4fecf3e2b7e646f1764a1993e31e53dbc6557929c12\",\"eth1_data\":{\"deposit_root\":\"0x8ec87d7219a3c873fff3bfe206b4f923d1b471ce4ff9d6d6ecc162ef07825e14\",\"deposit_count\":\"259476\",\"block_hash\":\"0x877b6f8332c7397251ff3f0c5cecec105ff7d4cb78251b47f91fd15a86a565ab\"},\"graffiti\":\"\",\"proposer_slashings\":[],\"attester_slashings\":[],\"attestations\":[],\"deposits\":[],\"voluntary_exits\":[],\"sync_aggregate\":{\"sync_committee_bits\":\"0x733dfda7f5ffde5ade73367fcbf7fffeef7fe43777ffdffab9dbad6f7eed5fff9bfec4affdefbfaddf35bf5efbff9ffff9dfd7dbf97fbfcdfaddfeffbf95f75f\",\"sync_committee_signature\":\"0x81fdf76e797f81b0116a1c1ae5200b613c8041115223cd89e8bd5477aab13de6097a9ebf42b130c59527bbb4c96811b809353a17c717549f82d4bd336068ef0b99b1feebd4d2432a69fa77fac12b78f1fcc9d7b59edbeb381adf10b15bc4a520\"},\"execution_payload\":{\"parent_hash\":\"0x14c2242a8cfbce559e84c391f5f16d10d7719751b8558873012dc88ae5a193e8\",\"fee_recipient\":\"$1\",\"state_root\":\"0xdf8d96b2c292736d39e72e25802c2744d34d3d3c616de5b362425cab01f72fa5\",\"receipts_root\":\"0x4938a2bf640846d213b156a1a853548b369cd02917fa63d8766ab665d7930bac\",\"logs_bloom\":\"0x298610600038408c201080013832408850a00bc8f801920121840030a015310010e2a0e0108628110552062811441c84802f43825c4fc82140b036c58025a28800054c80a44025c052090a0f2c209a0400058040019ea0008e589084078048050880930113a2894082e0112408b088382402a851621042212aa40018a408d07e178c68691486411aa9a2809043b000a04c040000065a030028018540b04b1820271d00821b00c29059095022322c10a530060223240416140190056608200063c82248274ba8f0098e402041cd9f451031481a1010b8220824833520490221071898802d206348449116812280014a10a2d1c210100a30010802490f0a221849\",\"prev_randao\":\"0xc061711e135cd40531ec3ee29d17d3824c0e5f80d07f721e792ab83240aa0ab5\",\"block_number\":\"8737497\",\"gas_limit\":\"30000000\",\"gas_used\":\"16367052\",\"timestamp\":\"1680080352\",\"extra_data\":\"0xd883010b05846765746888676f312e32302e32856c696e7578\",\"base_fee_per_gas\":\"231613172261\",\"block_hash\":\"0x5aa9fd22a9238925adb2b038fd6eafc77adabf554051db5bc16ae5168a52eff6\",\"transactions\":[],\"withdrawals\":[],\"blob_gas_used\":\"2316131761\",\"excess_blob_gas\":\"231613172261\"},\"bls_to_execution_changes\":[],\"blob_kzg_commitments\":[]}},\"kzg_proofs\":[],\"blobs\":[]}}"
@ -87,12 +86,8 @@ func getNodePort(basePort: int, rt: RemoteSignerType): int =
func init(T: type ForkedBeaconBlock, contents: ProduceBlockResponseV2): T = func init(T: type ForkedBeaconBlock, contents: ProduceBlockResponseV2): T =
case contents.kind case contents.kind
of ConsensusFork.Phase0: of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix:
return ForkedBeaconBlock.init(contents.phase0Data) raiseAssert "Unsupported fork"
of ConsensusFork.Altair:
return ForkedBeaconBlock.init(contents.altairData)
of ConsensusFork.Bellatrix:
return ForkedBeaconBlock.init(contents.bellatrixData)
of ConsensusFork.Capella: of ConsensusFork.Capella:
return ForkedBeaconBlock.init(contents.capellaData) return ForkedBeaconBlock.init(contents.capellaData)
of ConsensusFork.Deneb: of ConsensusFork.Deneb:
@ -106,8 +101,7 @@ proc getBlock(
blckData = blckData =
try: try:
case fork case fork
of ConsensusFork.Phase0 .. ConsensusFork.Altair: raiseAssert "Unsupported fork" of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix: raiseAssert "Unsupported fork"
of ConsensusFork.Bellatrix: BellatrixBlock % [feeRecipient]
of ConsensusFork.Capella: CapellaBlock % [feeRecipient] of ConsensusFork.Capella: CapellaBlock % [feeRecipient]
of ConsensusFork.Deneb: DenebBlockContents % [feeRecipient] of ConsensusFork.Deneb: DenebBlockContents % [feeRecipient]
except ValueError: except ValueError:
@ -125,12 +119,8 @@ proc getBlock(
func init(t: typedesc[Web3SignerForkedBeaconBlock], func init(t: typedesc[Web3SignerForkedBeaconBlock],
forked: ForkedBeaconBlock): Web3SignerForkedBeaconBlock = forked: ForkedBeaconBlock): Web3SignerForkedBeaconBlock =
case forked.kind case forked.kind
of ConsensusFork.Phase0, ConsensusFork.Altair: of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix:
raiseAssert "supports Bellatrix and later forks" raiseAssert "supports Capella and later forks"
of ConsensusFork.Bellatrix:
Web3SignerForkedBeaconBlock(
kind: ConsensusFork.Bellatrix,
data: forked.bellatrixData.toBeaconBlockHeader)
of ConsensusFork.Capella: of ConsensusFork.Capella:
Web3SignerForkedBeaconBlock( Web3SignerForkedBeaconBlock(
kind: ConsensusFork.Capella, kind: ConsensusFork.Capella,
@ -271,8 +261,7 @@ func getRemoteKeystoreData(data: string, basePort: int,
ProvenProperty( ProvenProperty(
path: ".execution_payload.fee_recipient", path: ".execution_payload.fee_recipient",
denebIndex: some GeneralizedIndex(801), denebIndex: some GeneralizedIndex(801),
capellaIndex: some GeneralizedIndex(401), capellaIndex: some GeneralizedIndex(401)
bellatrixIndex: some GeneralizedIndex(401)
) )
], ],
version: uint64(4), version: uint64(4),
@ -798,41 +787,6 @@ block:
sres2.get() == rres2.get() sres2.get() == rres2.get()
sres3.get() == rres3.get() sres3.get() == rres3.get()
asyncTest "Signing BeaconBlock (getBlockSignature(bellatrix))":
let
forked = getBlock(ConsensusFork.Bellatrix)
blockRoot = withBlck(forked): hash_tree_root(forkyBlck)
sres1 =
await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot, forked)
sres2 =
await validator2.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot, forked)
sres3 =
await validator3.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot, forked)
rres1 =
await validator4.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot, forked)
rres2 =
await validator5.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot, forked)
rres3 =
await validator6.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot, forked)
check:
sres1.isOk()
sres2.isOk()
sres3.isOk()
rres1.isOk()
rres2.isOk()
rres3.isOk()
sres1.get() == rres1.get()
sres2.get() == rres2.get()
sres3.get() == rres3.get()
asyncTest "Signing BeaconBlock (getBlockSignature(capella))": asyncTest "Signing BeaconBlock (getBlockSignature(capella))":
let let
forked = getBlock(ConsensusFork.Capella) forked = getBlock(ConsensusFork.Capella)
@ -1035,95 +989,6 @@ block:
await client.closeWait() await client.closeWait()
asyncTest "Signing BeaconBlock (getBlockSignature(bellatrix))":
let
fork = ConsensusFork.Bellatrix
forked1 = getBlock(fork)
blockRoot1 = withBlck(forked1): hash_tree_root(forkyBlck)
forked2 = getBlock(fork, SigningOtherFeeRecipient)
blockRoot2 = withBlck(forked2): hash_tree_root(forkyBlck)
request1 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot,
Web3SignerForkedBeaconBlock.init(forked1))
request2 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot,
Web3SignerForkedBeaconBlock.init(forked1), @[])
remoteUrl = "http://" & SigningNodeAddress & ":" &
$getNodePort(basePort, RemoteSignerType.VerifyingWeb3Signer)
prestoFlags = {RestClientFlag.CommaSeparatedArray}
rclient = RestClientRef.new(remoteUrl, prestoFlags, {})
publicKey1 = ValidatorPubKey.fromHex(ValidatorPubKey1).get()
publicKey2 = ValidatorPubKey.fromHex(ValidatorPubKey2).get()
publicKey3 = ValidatorPubKey.fromHex(ValidatorPubKey3).get()
check rclient.isOk()
let
client = rclient.get()
sres1 =
await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot1, forked1)
sres2 =
await validator2.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot1, forked1)
sres3 =
await validator3.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot1, forked1)
rres1 =
await validator4.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot1, forked1)
rres2 =
await validator5.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot1, forked1)
rres3 =
await validator6.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot1, forked1)
bres1 =
await validator4.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot2, forked2)
bres2 =
await validator5.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot2, forked2)
bres3 =
await validator6.getBlockSignature(SigningFork, GenesisValidatorsRoot,
Slot(1), blockRoot2, forked2)
check:
# Local requests
sres1.isOk()
sres2.isOk()
sres3.isOk()
# Remote requests with proper Merkle proof of proper FeeRecipent field
rres1.isOk()
rres2.isOk()
rres3.isOk()
# Signature comparison
sres1.get() == rres1.get()
sres2.get() == rres2.get()
sres3.get() == rres3.get()
# Remote requests with changed FeeRecipient field
bres1.isErr()
bres2.isErr()
bres3.isErr()
try:
let
# `proofs` array is not present.
response1 = await client.signDataPlain(publicKey1, request1)
response2 = await client.signDataPlain(publicKey2, request1)
response3 = await client.signDataPlain(publicKey3, request1)
# `proofs` array is empty.
response4 = await client.signDataPlain(publicKey1, request2)
response5 = await client.signDataPlain(publicKey2, request2)
response6 = await client.signDataPlain(publicKey3, request2)
check:
response1.status == 400
response2.status == 400
response3.status == 400
response4.status == 400
response5.status == 400
response6.status == 400
finally:
await client.closeWait()
asyncTest "Signing BeaconBlock (getBlockSignature(capella))": asyncTest "Signing BeaconBlock (getBlockSignature(capella))":
let let
fork = ConsensusFork.Capella fork = ConsensusFork.Capella