-
Notifications
You must be signed in to change notification settings - Fork 79
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
sign type block_v2 to support Altair and future forks #422
sign type block_v2 to support Altair and future forks #422
Conversation
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
...tance-tests/src/test/java/tech/pegasys/web3signer/dsl/signer/SignerConfigurationBuilder.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Usman Saleem <[email protected]>
@@ -77,7 +72,7 @@ void signAndVerifyBlockV2Signature(final SpecMilestone specMilestone) throws Exc | |||
@Test | |||
void signAndVerifyLegacyBlockSignature() throws Exception { | |||
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(SpecMilestone.PHASE0); | |||
setupSigner("eth2", null, "minimal", Optional.empty()); | |||
setupSigner("eth2", null, "minimal", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be overkill in this case, but could avoid passing the null into the Optional with another overloaded setupSigner method which doesn't call withAltairForkEpoch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are correct, its technically only for legacy block signing that we need to start web3signer without altair fork. Rest of signing types works with altair fork.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather we didn't pass in null as well, even an optional altair block would be nicer. Might be nit picking though.
Signed-off-by: Usman Saleem <[email protected]>
@@ -196,8 +197,13 @@ public SignerConfigurationBuilder withUseConfigFile(final boolean useConfigFile) | |||
return this; | |||
} | |||
|
|||
public SignerConfigurationBuilder withAltairForkEpoch(final long altairForkEpoch) { | |||
this.altairForkEpoch = altairForkEpoch; | |||
public SignerConfigurationBuilder withAltairForkEpoch(final Long altairForkEpoch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be nicer to use the primitive long
public SignerConfigurationBuilder withAltairForkEpoch(final long altairForkEpoch) { | ||
this.altairForkEpoch = altairForkEpoch; | ||
public SignerConfigurationBuilder withAltairForkEpoch(final Long altairForkEpoch) { | ||
this.altairForkEpoch = Optional.ofNullable(altairForkEpoch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ofNullable because null is being passed into the builder somewhere? Rather didn't do that
signingRoot = signingRootUtil.signingRootForSignBlock(beaconBlock, tekuForkInfo); | ||
} | ||
|
||
public Eth2SigningRequestBody createRandomBlockV2Request() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually random? Looks like dataStructureUtil creates deterministic data keyed off the slot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is deterministic ... I think createCanned.... naming makes more sense.
null); | ||
} | ||
|
||
public Eth2SigningRequestBody createRandomLegacyBlockRequest() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any benefit in having this method and the one in Eth2RequestUtils?
@@ -59,7 +59,7 @@ | |||
private static final BLSPublicKey publicKey = keyPair.getPublicKey(); | |||
|
|||
@ParameterizedTest | |||
@EnumSource | |||
@EnumSource(mode = EnumSource.Mode.EXCLUDE, names = "BLOCK_V2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to exclude BLOCK_V2? It would good to include the block v2 in these tests for completeness.
@@ -77,7 +72,7 @@ void signAndVerifyBlockV2Signature(final SpecMilestone specMilestone) throws Exc | |||
@Test | |||
void signAndVerifyLegacyBlockSignature() throws Exception { | |||
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(SpecMilestone.PHASE0); | |||
setupSigner("eth2", null, "minimal", Optional.empty()); | |||
setupSigner("eth2", null, "minimal", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather we didn't pass in null as well, even an optional altair block would be nicer. Might be nit picking though.
@@ -44,6 +45,7 @@ public Eth2SigningRequestBody( | |||
@JsonProperty("signingRoot") final Bytes signingRoot, | |||
@JsonProperty("fork_info") final ForkInfo fork_info, | |||
@JsonProperty("block") final BeaconBlock block, | |||
@JsonProperty("beacon_block") final BlockRequest blockRequest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bit confusing having block and beacon_block in the request. Not sure there is much we can do about now that Teku has implemented this though
} | ||
|
||
@Override | ||
public BlockRequest deserialize(final JsonParser p, final DeserializationContext ctxt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a test? We do have AT though, so maybe that is enough
import org.apache.tuweni.bytes.Bytes32; | ||
import org.apache.tuweni.units.bigints.UInt64; | ||
|
||
public class SigningJsonProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way we are using this doing new SigningJsonProvider().getObjectMapper()
perhaps a factory would be would be better?
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Block signing request for Altair fork uses different block than phase 0. Introduce new sign type BLOCK_V2 which will allow Altair and future forks block signing requests. Keep BLOCK for phase 0 backward compatibility.