Skip to content

Commit

Permalink
Merge pull request #585 from ava-labs/acp-77-updates
Browse files Browse the repository at this point in the history
Acp 77 updates
  • Loading branch information
cam-schultz authored Oct 15, 2024
2 parents ba5cd03 + dac3220 commit 6174cef
Show file tree
Hide file tree
Showing 42 changed files with 2,604 additions and 1,674 deletions.
61 changes: 49 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
source scripts/constants.sh
go test ./...
e2e_tests:
name: e2e_tests
teleporter_e2e:
name: teleporter-e2e-tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repositories and submodules
Expand All @@ -67,15 +67,52 @@ jobs:
run: |
export PATH=$PATH:$HOME/.foundry/bin
export PATH="$PATH:$GOPATH/bin"
./scripts/local/e2e_test.sh
./scripts/local/e2e_test.sh --components teleporter
- name: Upload tmpnet network dir
uses: actions/upload-artifact@v4
if: always()
governance_e2e:
name: governance-e2e-tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repositories and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Install Foundry
run: ./scripts/install_foundry.sh

- name: Run E2E Tests
# Forge installs to BASE_DIR, but updates the PATH definition in $HOME/.bashrc
run: |
export PATH=$PATH:$HOME/.foundry/bin
export PATH="$PATH:$GOPATH/bin"
./scripts/local/e2e_test.sh --components governance
validator_manager_e2e:
name: validator-manager-e2e-tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repositories and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v5
with:
name: e2e-tmpnet-data
path: |
~/.tmpnet/networks
~/.tmpnet/prometheus/prometheus.log
~/.tmpnet/promtail/promtail.log
if-no-files-found: error
go-version-file: 'go.mod'

- name: Install Foundry
run: ./scripts/install_foundry.sh

- name: Run E2E Tests
# Forge installs to BASE_DIR, but updates the PATH definition in $HOME/.bashrc
run: |
export PATH=$PATH:$HOME/.foundry/bin
export PATH="$PATH:$GOPATH/bin"
./scripts/local/e2e_test.sh --components validator-manager
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ server.log

# Forge documentation
docs/
coverage/

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

164 changes: 111 additions & 53 deletions contracts/validator-manager/MessageSpec.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,115 @@
## Warp Message Format Reference

### `SubnetConversionMessage`

- Description: Confirms conversion to a Permissionless Subnet on the P-Chain

- Signed by: P-Chain

- Consumed by: Validator Manager contract

Specification:

```
SubnetConversionMessage
+--------------------+----------+----------+
| codecID : uint16 | 2 bytes |
+--------------------+----------+----------+
| typeID : uint32 | 4 bytes |
+--------------------+----------+----------+
| subnetConversionID : [32]byte | 32 bytes |
+--------------------+----------+----------+
| 38 bytes |
+----------+
```

where `subnetConversionID` is defined as the `sha256` hash of the serialization of the `SubnetConversionData`, defined as follows:

```
ValidatorData
+--------------+----------+------------------------+
| nodeID : []byte | 4 + len(nodeID) bytes |
+--------------+----------+------------------------+
| blsPublicKey : [48]byte | 48 bytes |
+--------------+----------+------------------------+
| weight : uint64 | 8 bytes |
+--------------+----------+------------------------+
| 60 + len(nodeID) bytes |
+------------------------+
SubnetConversionData
+----------------+-----------------+--------------------------------------------------------+
| codecID : uint16 | 2 bytes |
+----------------+-----------------+--------------------------------------------------------+
| subnetID : [32]byte | 32 bytes |
+----------------+-----------------+--------------------------------------------------------+
| managerChainID : [32]byte | 32 bytes |
+----------------+-----------------+--------------------------------------------------------+
| managerAddress : []byte | 4 + len(managerAddress) bytes |
+----------------+-----------------+--------------------------------------------------------+
| validators : []ValidatorData | 4 + sum(validatorLengths) bytes |
+----------------+-----------------+--------------------------------------------------------+
| 74 + len(managerAddress) + len(validatorLengths) bytes |
+--------------------------------------------------------+
```

### `RegisterSubnetValidatorMessage`

Description: Register a Subnet Validator on the P-Chain
- Description: Registers a Subnet Validator on the P-Chain

Signed by: Subnet
Consumed by: P-Chain
- Signed by: Subnet

- Consumed by: P-Chain

Specification:

```
+--------------+----------+-----------+
| codecID : uint16 | 2 bytes |
+--------------+----------+-----------+
| typeID : uint32 | 4 bytes |
+--------------+----------+-----------+
| subnetID : [32]byte | 32 bytes |
+--------------+----------+-----------+
| nodeID : [32]byte | 32 bytes |
+--------------+----------+-----------+
| weight : uint64 | 8 bytes |
+--------------+----------+-----------+
| blsPublicKey : [48]byte | 48 bytes |
+--------------+----------+-----------+
| expiry : uint64 | 8 bytes |
+--------------+----------+-----------+
| 134 bytes |
+-----------+
PChainOwner
+-----------+------------+-------------------------------+
| threshold : uint32 | 4 bytes |
+-----------+------------+-------------------------------+
| addresses : [][20]byte | 4 + len(addresses) * 20 bytes |
+-----------+------------+-------------------------------+
| 8 + len(addresses) * 20 bytes |
+-------------------------------+
RegisterSubnetValidatorMessage
+-----------------------+-------------+--------------------------------------------------------------------+
| codecID : uint16 | 2 bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| typeID : uint32 | 4 bytes |
+-----------------------+-------------+-------------------------------------------------------------------+
| subnetID : [32]byte | 32 bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| nodeID : []byte | 4 + len(nodeID) bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| blsPublicKey : [48]byte | 48 bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| expiry : uint64 | 8 bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| remainingBalanceOwner : PChainOwner | 4 + len(addresses) * 20 bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| disableOwner : PChainOwner | 4 + len(addresses) * 20 bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| weight : uint64 | 8 bytes |
+-----------------------+-------------+--------------------------------------------------------------------+
| 114 + len(nodeID) + (len(addresses1) + len(addresses2)) * 20 bytes |
+--------------------------------------------------------------------+
```

### `SubnetValidatorRegistrationMessage`

Description: Confirms a Subnet Validator's registration validity on the P-Chain
- Description: Confirms a Subnet Validator's registration validity on the P-Chain

- Signed by: P-Chain

Signed by: P-Chain
Consumed by: Validator Manager contract
- Consumed by: Validator Manager contract

Specification:

```
SubnetValidatorRegistrationMessage
+--------------+----------+----------+
| codecID : uint16 | 2 bytes |
+--------------+----------+----------+
Expand All @@ -53,39 +123,27 @@ Specification:
+----------+
```

### `ValidationUptimeMessage`
### `SubnetValidatorWeightMessage`

Description: Provides a Validator's uptime for calculating staking rewards
- Description: Used to set and acknowledge a Validator's stake weight on another chain

Signed by: Subnet
Consumed by: Validator Manager contract
- To effect a weight change:

Specification:
- Signed by: Subnet

```
+--------------+----------+----------+
| codecID : uint16 | 2 bytes |
+--------------+----------+----------+
| typeID : uint32 | 4 bytes |
+--------------+----------+----------+
| validationID : [32]byte | 32 bytes |
+--------------+----------+----------+
| uptime : uint64 | 8 bytes |
+--------------+----------+----------+
| 46 bytes |
+----------+
```
- Consumed by: P-Chain

### `SetSubnetValidatorWeightMessage`
- To acknowledge the weight change:

Description: Used to set a Validator's stake weight on another chain
- Signed by P-Chain

Signed by: Subnet
Consumed by: P-Chain

- Consumed by Subnet

Specification:

```
SubnetValidatorWeightMessage
+--------------+----------+----------+
| codecID : uint16 | 2 bytes |
+--------------+----------+----------+
Expand All @@ -101,27 +159,27 @@ Specification:
+----------+
```

### `SubnetValidatorWeightUpdateMessage`
### `ValidationUptimeMessage`

- Description: Provides a Validator's uptime for calculating staking rewards

Description: Acknowledges a Validator weight update
- Signed by: Subnet

Signed by: P-Chain
Consumed by: Validator Manager contract
- Consumed by: Validator Manager contract

Specification:

```
ValidationUptimeMessage
+--------------+----------+----------+
| codecID : uint16 | 2 bytes |
+--------------+----------+----------+
| typeID : uint32 | 4 bytes |
+--------------+----------+----------+
| validationID : [32]byte | 32 bytes |
+--------------+----------+----------+
| nonce : uint64 | 8 bytes |
+--------------+----------+----------+
| weight : uint64 | 8 bytes |
| uptime : uint64 | 8 bytes |
+--------------+----------+----------+
| 54 bytes |
| 46 bytes |
+----------+
```
6 changes: 3 additions & 3 deletions contracts/validator-manager/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ abstract contract PoSValidatorManager is

// Unpack the Warp message
(bytes32 messageValidationID, uint64 nonce,) = ValidatorMessages
.unpackSubnetValidatorWeightUpdateMessage(_getPChainWarpMessage(messageIndex).payload);
.unpackSubnetValidatorWeightMessage(_getPChainWarpMessage(messageIndex).payload);

if (validationID != messageValidationID) {
revert InvalidValidationID(delegator.validationID);
Expand Down Expand Up @@ -589,7 +589,7 @@ abstract contract PoSValidatorManager is

// Submit the message to the Warp precompile.
WARP_MESSENGER.sendWarpMessage(
ValidatorMessages.packSetSubnetValidatorWeightMessage(
ValidatorMessages.packSubnetValidatorWeightMessage(
delegator.validationID, validator.messageNonce, validator.weight
)
);
Expand All @@ -613,7 +613,7 @@ abstract contract PoSValidatorManager is
// Unpack the Warp message
WarpMessage memory warpMessage = _getPChainWarpMessage(messageIndex);
(bytes32 validationID, uint64 nonce,) =
ValidatorMessages.unpackSubnetValidatorWeightUpdateMessage(warpMessage.payload);
ValidatorMessages.unpackSubnetValidatorWeightMessage(warpMessage.payload);

if (delegator.validationID != validationID) {
revert InvalidValidationID(validationID);
Expand Down
Loading

0 comments on commit 6174cef

Please sign in to comment.