Skip to content

Commit 7eaff5e

Browse files
committed
add Fulu signing node test
1 parent dab86d7 commit 7eaff5e

File tree

3 files changed

+95
-4
lines changed

3 files changed

+95
-4
lines changed

AllTests-mainnet.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ AllTests-mainnet
789789
+ Public keys enumeration (/api/v1/eth2/publicKeys) test OK
790790
+ Public keys reload (/reload) test OK
791791
+ Signing BeaconBlock (getBlockSignature(electra)) OK
792+
+ Signing BeaconBlock (getBlockSignature(fulu)) OK
792793
+ Signing SC contribution and proof (getContributionAndProofSignature()) OK
793794
+ Signing SC message (getSyncCommitteeMessage()) OK
794795
+ Signing SC selection proof (getSyncCommitteeSelectionProof()) OK

beacon_chain/spec/datatypes/base.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,5 +980,4 @@ func ofLen*[T, N](ListType: type List[T, N], n: int): ListType =
980980
else:
981981
raise newException(SszSizeMismatchError)
982982

983-
template debugFuluComment*(s: string) = discard
984983
template debugGloasComment*(s: string) = discard

tests/test_signing_node.nim

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const
6565

6666
ElectraBlockContents = "{\"signed_block\":{\"message\":{\"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\":[],\"execution_requests\":{\"deposits\":[],\"withdrawals\":[],\"consolidations\":[]}}},\"signature\":\"$2\"},\"kzg_proofs\":[],\"blobs\":[]}"
6767

68+
FuluBlockContents = "{\"signed_block\":{\"message\":{\"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\":[],\"execution_requests\":{\"deposits\":[],\"withdrawals\":[],\"consolidations\":[]}}},\"signature\":\"$2\"},\"kzg_proofs\":[],\"blobs\":[]}"
69+
6870
SigningNodeAddress = "127.0.0.1"
6971
defaultSigningNodePort = 35333
7072

@@ -98,10 +100,11 @@ proc getBlock(
98100
ElectraBlockContents % [feeRecipient, SomeSignature],
99101
ElectraSignedBlockContents).signed_block.message)
100102
of ConsensusFork.Fulu:
101-
debugFuluComment "fulu test signing node getblock"
102-
raiseAssert "fulu unsupported"
103+
ForkedBeaconBlock.init(RestJson.decode(
104+
FuluBlockContents % [feeRecipient, SomeSignature],
105+
FuluSignedBlockContents).signed_block.message)
103106
of ConsensusFork.Gloas:
104-
debugFuluComment "gloas test signing node getblock"
107+
debugGloasComment "gloas test signing node getblock"
105108
raiseAssert "gloas unsupported"
106109
except ValueError:
107110
# https://github.com/nim-lang/Nim/pull/23356
@@ -923,6 +926,94 @@ block:
923926
finally:
924927
await client.closeWait()
925928

929+
asyncTest "Signing BeaconBlock (getBlockSignature(fulu))":
930+
let
931+
forked = getBlock(ConsensusFork.Fulu)
932+
blockRoot = withBlck(forked): hash_tree_root(forkyBlck)
933+
934+
sres1 =
935+
await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot,
936+
blockRoot, forked)
937+
sres2 =
938+
await validator2.getBlockSignature(SigningFork, GenesisValidatorsRoot,
939+
blockRoot, forked)
940+
sres3 =
941+
await validator3.getBlockSignature(SigningFork, GenesisValidatorsRoot,
942+
blockRoot, forked)
943+
rres1 =
944+
await validator4.getBlockSignature(SigningFork, GenesisValidatorsRoot,
945+
blockRoot, forked)
946+
rres2 =
947+
await validator5.getBlockSignature(SigningFork, GenesisValidatorsRoot,
948+
blockRoot, forked)
949+
rres3 =
950+
await validator6.getBlockSignature(SigningFork, GenesisValidatorsRoot,
951+
blockRoot, forked)
952+
953+
check:
954+
sres1.isOk()
955+
sres2.isOk()
956+
sres3.isOk()
957+
rres1.isOk()
958+
rres2.isOk()
959+
rres3.isOk()
960+
sres1.get() == rres1.get()
961+
sres2.get() == rres2.get()
962+
sres3.get() == rres3.get()
963+
964+
asyncTest "Connection timeout test":
965+
let
966+
request = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot,
967+
Epoch(10))
968+
deadline = newFuture[void]()
969+
(client, info) = validator4.clients[0]
970+
971+
deadline.complete()
972+
let res = await client.signData(info.pubkey, deadline, 1, request)
973+
check:
974+
res.isErr()
975+
res.error.kind == Web3SignerErrorKind.TimeoutError
976+
977+
asyncTest "Public keys reload (/reload) test":
978+
let
979+
res = createAdditionalKeystore(RemoteSignerType.Web3Signer)
980+
remoteUrl = "http://" & SigningNodeAddress & ":" &
981+
$getNodePort(basePort, RemoteSignerType.Web3Signer)
982+
prestoFlags = {RestClientFlag.CommaSeparatedArray}
983+
rclient = RestClientRef.new(remoteUrl, prestoFlags, {})
984+
985+
check:
986+
res.isOk()
987+
rclient.isOk()
988+
989+
let client = rclient.get()
990+
check res.isOk()
991+
try:
992+
block:
993+
let response = await client.reload()
994+
check response.status == 200
995+
block:
996+
let response = await client.getKeys()
997+
check:
998+
response.status == 200
999+
len(response.data) == 4
1000+
let
1001+
received = sorted([
1002+
"0x" & response.data[0].toHex(),
1003+
"0x" & response.data[1].toHex(),
1004+
"0x" & response.data[2].toHex(),
1005+
"0x" & response.data[3].toHex()
1006+
])
1007+
expected = sorted([
1008+
ValidatorPubKey1,
1009+
ValidatorPubKey2,
1010+
ValidatorPubKey3,
1011+
ValidatorPubKey4
1012+
])
1013+
check received == expected
1014+
finally:
1015+
await client.closeWait()
1016+
9261017
waitFor(shutdownSigningNodeProcess(process))
9271018
removeTestDir(RemoteSignerType.Web3Signer)
9281019

0 commit comments

Comments
 (0)