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

Acp 77 updates #585

Merged
merged 64 commits into from
Oct 15, 2024
Merged

Acp 77 updates #585

merged 64 commits into from
Oct 15, 2024

Conversation

cam-schultz
Copy link
Contributor

@cam-schultz cam-schultz commented Oct 2, 2024

Why this should be merged

Updates the Validator Manager contracts to match the updated ACP-77 spec: https://github.com/avalanche-foundation/ACPs/pull/149/files

Note: Until an Avalanchego commit that includes the updated message specifications and corresponding signature handlers is available, e2e tests are not expected to pass.

Review focus:

  • contracts/validator-manager

How this works

  • Updates the message specs in MessageSpec.md and ValidatorMessages.sol
  • Updates the internal structs to match the ordering of the variables in the updated spec

How this was tested

CI

How is this documented

Copy link
Contributor

@geoff-vball geoff-vball left a comment

Choose a reason for hiding this comment

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

Overall LGTM :)

contracts/validator-manager/MessageSpec.md Outdated Show resolved Hide resolved
@cam-schultz cam-schultz marked this pull request as ready for review October 10, 2024 20:51
@cam-schultz cam-schultz requested a review from a team as a code owner October 10, 2024 20:51
Specification:

```
SubnetConversionMessage
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't matter at all for this PR, but worth noting that markdown supports tables that provide auto-formatting in the future. It makes it easy to modify in the future without having to manually correct all of the spacing.


Description: Acknowledges a Validator weight update
- Signed by: Subnet
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not for this PR, but just a heads up that we'll be updating the terminology from subnet -> L1 soon, including for these message names and transaction types.

Subnets will refer to pre-Etna Subnets, where their validator set must also validate the primary network, making it a subset of the primary network validators.

L1s will refer to post-Etna sovereign networks, whose validators sets can be completely independent of the primary network.

@@ -236,7 +233,7 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida
if (input.blsPublicKey.length != BLS_PUBLIC_KEY_LENGTH) {
revert InvalidBLSKeyLength(input.blsPublicKey.length);
}
if (input.nodeID == bytes32(0)) {
if (input.nodeID.length == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As of Etna, the P-Chain will only support 20 byte node IDs, but it's planned to add support for other node IDs in the future (particularly 32-byte Ed25519 node IDs).

I've gone back and forth on if we should require 20 byte node IDs here and track them as bytes20, or if we should leave it more open to support those future upgrades by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I elected to use variable length nodeIDs in order to reduce the amount of deviation from the ACP-77 spec. The main consideration to using bytes20 would be potential gas savings, but I have no investigated that.

blsPublicKey: input.blsPublicKey,
registrationExpiry: input.registrationExpiry
remainingBalanceOwner: input.remainingBalanceOwner,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we validate the PChainOwners here? The requirements are:

  • If threshold is 0, addresses must be empty.
  • threshold <= len(addresses)
  • addresses must be sorted in ascending order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, added these validation checks

Copy link
Contributor

@geoff-vball geoff-vball left a comment

Choose a reason for hiding this comment

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

Generally LGTM

Copy link
Contributor

@bernard-avalabs bernard-avalabs left a comment

Choose a reason for hiding this comment

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

LGTM. Just one suggestion about unpacking/packing for a future PR.

}
if (codecID != CODEC_ID) {
revert InvalidCodecID();
// Individual fields are unpacked in their own scopes to avoid stack too deep errors.
Copy link
Contributor

Choose a reason for hiding this comment

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

(Not for this PR). This style of packing/unpacking is a bit error prone. Perhaps it may be worth writing some lex/bison (or some other lexer/parser) scripts to autogenerate these functions so they are easier to validate.

@cam-schultz cam-schultz merged commit 6174cef into validator-manager Oct 15, 2024
14 checks passed
@cam-schultz cam-schultz deleted the acp-77-updates branch October 15, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants