Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove web3signer block signing V1 (phase0 only) support #5014

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,12 @@ OK: 6/6 Fail: 0/6 Skip: 0/6
+ Signing aggregation slot (getSlotSignature()) OK
+ Signing attestation (getAttestationSignature()) OK
+ Signing deposit message (getDepositMessageSignature()) OK
+ Signing phase0 block OK
+ Signing randao reveal (getEpochSignature()) OK
+ Signing validator registration (getBuilderSignature()) OK
+ Signing voluntary exit (getValidatorExitSignature()) OK
+ Waiting for signing node (/upcheck) test OK
```
OK: 22/22 Fail: 0/22 Skip: 0/22
OK: 21/21 Fail: 0/21 Skip: 0/21
## Old database versions [Preset: mainnet]
```diff
+ pre-1.1.0 OK
Expand Down Expand Up @@ -691,4 +690,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9

---TOTAL---
OK: 392/397 Fail: 0/397 Skip: 5/397
OK: 391/396 Fail: 0/396 Skip: 5/396
8 changes: 0 additions & 8 deletions beacon_chain/nimbus_signing_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,6 @@ proc installApiHandlers*(node: SigningNodeRef) =
forkInfo.genesis_validators_root, request.attestation,
validator.data.privateKey).toValidatorSig().toHex()
signatureResponse(Http200, signature)
of Web3SignerRequestKind.Block:
let
forkInfo = request.forkInfo.get()
blck = request.blck
signature = get_block_signature(forkInfo.fork,
forkInfo.genesis_validators_root, blck.slot, hash_tree_root(blck),
validator.data.privateKey).toValidatorSig().toHex()
signatureResponse(Http200, signature)
of Web3SignerRequestKind.BlockV2:
if node.config.expectedFeeRecipient.isNone():
let
Expand Down
26 changes: 0 additions & 26 deletions beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1941,14 +1941,6 @@ proc writeValue*(writer: var JsonWriter[RestJson],
if isSome(value.signingRoot):
writer.writeField("signingRoot", value.signingRoot)
writer.writeField("attestation", value.attestation)
of Web3SignerRequestKind.Block:
doAssert(value.forkInfo.isSome(),
"forkInfo should be set for this type of request")
writer.writeField("type", "BLOCK")
writer.writeField("fork_info", value.forkInfo.get())
if isSome(value.signingRoot):
writer.writeField("signingRoot", value.signingRoot)
writer.writeField("block", value.blck)
of Web3SignerRequestKind.BlockV2:
doAssert(value.forkInfo.isSome(),
"forkInfo should be set for this type of request")
Expand Down Expand Up @@ -2046,8 +2038,6 @@ proc readValue*(reader: var JsonReader[RestJson],
Web3SignerRequestKind.AggregateAndProof
of "ATTESTATION":
Web3SignerRequestKind.Attestation
of "BLOCK":
Web3SignerRequestKind.Block
of "BLOCK_V2":
Web3SignerRequestKind.BlockV2
of "DEPOSIT":
Expand Down Expand Up @@ -2145,22 +2135,6 @@ proc readValue*(reader: var JsonReader[RestJson],
kind: Web3SignerRequestKind.Attestation,
forkInfo: forkInfo, signingRoot: signingRoot, attestation: data
)
of Web3SignerRequestKind.Block:
if dataName != "block":
reader.raiseUnexpectedValue("Field `block` is missing")
if forkInfo.isNone():
reader.raiseUnexpectedValue("Field `fork_info` is missing")
let data =
block:
let res = decodeJsonString(phase0.BeaconBlock, data.get())
if res.isErr():
reader.raiseUnexpectedValue(
"Incorrect field `block` format")
res.get()
Web3SignerRequest(
kind: Web3SignerRequestKind.Block,
forkInfo: forkInfo, signingRoot: signingRoot, blck: data
)
of Web3SignerRequestKind.BlockV2:
# https://github.com/ConsenSys/web3signer/blob/41834a927088f1bde7a097e17d19e954d0058e54/core/src/main/resources/openapi-specs/eth2/signing/schemas.yaml#L421-L425 (branch v22.7.0)
# It's the "beacon_block" field even when it's not a block, but a header
Expand Down
18 changes: 1 addition & 17 deletions beacon_chain/spec/eth2_apis/rest_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ type
proof*: seq[Eth2Digest]

Web3SignerRequestKind* {.pure.} = enum
AggregationSlot, AggregateAndProof, Attestation, Block, BlockV2,
AggregationSlot, AggregateAndProof, Attestation, BlockV2,
Deposit, RandaoReveal, VoluntaryExit, SyncCommitteeMessage,
SyncCommitteeSelectionProof, SyncCommitteeContributionAndProof,
ValidatorRegistration
Expand All @@ -602,9 +602,6 @@ type
serializedFieldName: "aggregate_and_proof".}: AggregateAndProof
of Web3SignerRequestKind.Attestation:
attestation*: AttestationData
of Web3SignerRequestKind.Block:
blck* {.
serializedFieldName: "block".}: phase0.BeaconBlock
of Web3SignerRequestKind.BlockV2:
beaconBlock* {.
serializedFieldName: "beacon_block".}: Web3SignerForkedBeaconBlock
Expand Down Expand Up @@ -799,19 +796,6 @@ func init*(t: typedesc[Web3SignerRequest], fork: Fork,
attestation: data
)

func init*(t: typedesc[Web3SignerRequest], fork: Fork,
genesis_validators_root: Eth2Digest, data: phase0.BeaconBlock,
signingRoot: Option[Eth2Digest] = none[Eth2Digest]()
): Web3SignerRequest =
Web3SignerRequest(
kind: Web3SignerRequestKind.Block,
forkInfo: some(Web3SignerForkInfo(
fork: fork, genesis_validators_root: genesis_validators_root
)),
signingRoot: signingRoot,
blck: data
)

func init*(t: typedesc[Web3SignerRequest], fork: Fork,
genesis_validators_root: Eth2Digest,
data: Web3SignerForkedBeaconBlock,
Expand Down
49 changes: 0 additions & 49 deletions tests/test_signing_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -425,55 +425,6 @@ suite "Nimbus remote signer/signing test (web3signer)":
finally:
await client.closeWait()

asyncTest "Signing phase0 block":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like the only block signing test we have - can we turn it into a more recent-version-test instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncTest "Signing BeaconBlock (getBlockSignature(phase0))":
let
forked = getBlock(ConsensusFork.Phase0)
blockRoot = withBlck(forked): hash_tree_root(blck)
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(altair))":
let
forked = getBlock(ConsensusFork.Altair)
blockRoot = withBlck(forked): hash_tree_root(blck)
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(bellatrix))":
let
forked = getBlock(ConsensusFork.Bellatrix)
blockRoot = withBlck(forked): hash_tree_root(blck)
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))":
let
forked = getBlock(ConsensusFork.Capella)
blockRoot = withBlck(forked): hash_tree_root(blck)
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(deneb))":
let
forked = getBlock(ConsensusFork.Deneb)
blockRoot = withBlck(forked): hash_tree_root(blck)
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()

have tests using the BlockV2 interface for all supported forks.

let
forked = getBlock(ConsensusFork.Phase0)
blockRoot = withBlck(forked): hash_tree_root(blck)
request = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot,
forked.phase0Data)
remoteUrl = "http://" & SigningNodeAddress & ":" &
$getNodePort(basePort, RemoteSignerType.Web3Signer)
prestoFlags = {RestClientFlag.CommaSeparatedArray}
rclient = RestClientRef.new(remoteUrl, prestoFlags, {})

check rclient.isOk()
let client = rclient.get()
let
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)

check:
sres1.isOk()
sres2.isOk()
sres3.isOk()

try:
let
publicKey1 = ValidatorPubKey.fromHex(ValidatorPubKey1).get()
publicKey2 = ValidatorPubKey.fromHex(ValidatorPubKey2).get()
publicKey3 = ValidatorPubKey.fromHex(ValidatorPubKey3).get()
response1 = await client.signData(publicKey1, request)
response2 = await client.signData(publicKey2, request)
response3 = await client.signData(publicKey3, request)

check:
response1.isOk()
response2.isOk()
response3.isOk()
response1.get().toValidatorSig() == sres1.get()
response2.get().toValidatorSig() == sres2.get()
response3.get().toValidatorSig() == sres3.get()

finally:
await client.closeWait()

asyncTest "Signing aggregation slot (getSlotSignature())":
let
sres1 =
Expand Down