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

Bellatrix fork + External Signer: Send block_header for block sign request #5354

Merged
merged 12 commits into from
Apr 21, 2022

Conversation

usmansaleem
Copy link
Contributor

PR Description

For Bellatrix fork, send block_header instead of block for external signer block signing request (BLOCK_V2). block_header contains body_root instead of complete beacon block body which significantly reduces the traffic between Teku and external signer for block signing request.

Either block_header or block can be used to calculate signing root by the external signer. For backward compatibility with PHASE0 and ALTAIR forks, only block is sent; for Bellatrix and later forks, only block_header is sent.

Fixed Issue(s)

Consensys/web3signer#437

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

 - Create BeaconBlockHeader from BeaconBlock
 - Update ExternalSigner for Bellatrix
 - Update SigningRootUtil to sign BeaconBlockHeader
 - Update BlockRequestBody to send block_header
@usmansaleem usmansaleem marked this pull request as ready for review April 19, 2022 02:16
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM.

return spec.computeSigningRoot(block, getDomainForSignBlock(block.getSlot(), forkInfo));
}

public Bytes signingRootForSignBlock(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call this signingRootForSignBlockHeader?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

+ block.getSlot()
+ " as it may violate a slashing condition";
String.format(
"External signed refused to sign block at slot %s as it may violate a slashing condition",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"External signed refused to sign block at slot %s as it may violate a slashing condition",
"External signer refused to sign block at slot %s as it may violate a slashing condition",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated typo.

case ALTAIR:
metadata.put(
"beacon_block",
new BlockRequestBody(spec.atSlot(block.getSlot()).getMilestone(), beaconBlock, null));
Copy link
Contributor

Choose a reason for hiding this comment

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

It probably makes sense to have two separate constructors for BlockRequestBody, one that takes just a beacon block and one that takes just a header. May still need the version that takes both for JSON deserialisation but would be nice to clean this up to not have to specify null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, introduced overloaded constructor. Also updated unit tests to assert correct fields are populated.

@usmansaleem usmansaleem self-assigned this Apr 21, 2022
@usmansaleem usmansaleem added the TeamGroot Under active development by TeamGroot @PegaSys label Apr 21, 2022
@usmansaleem usmansaleem merged commit 3ead721 into Consensys:master Apr 21, 2022
@usmansaleem usmansaleem deleted the block_body_root branch April 21, 2022 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TeamGroot Under active development by TeamGroot @PegaSys
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants