Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 73c5e53

Browse files
cam-schultzqdm12
andauthored
[documentation] Differentiate between L1 and Subnet self-signing optimization cases (#1529)
Signed-off-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org>
1 parent 10aac5f commit 73c5e53

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

precompile/contracts/warp/README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,35 @@ Since the predicate is encoded into the [Transaction Access List](https://eips.e
7777

7878
Therefore, we use the [Predicate Utils](https://github.com/ava-labs/coreth/blob/master/predicate/Predicate.md) package to encode the actual byte slice of size N into the access list.
7979

80-
### Performance Optimization: C-Chain to Avalanche L1
80+
### Performance Optimization: Primary Network to Avalanche L1
8181

82-
For communication between the C-Chain and an L1, as well as broader interactions between the Primary Network and Avalanche L1s, we have implemented special handling for the C-Chain.
82+
The Primary Network has a large validator set compared to most Subnets and L1s, which makes Warp signature collection and verification from the entire Primary Network validator set costly. All Subnets and L1s track at least one blockchain of the Primary Network, so we can instead optimize this by using the validator set of the receiving L1 instead of the Primary Network for certain Warp messages.
8383

84-
The Primary Network has a large validator set, which creates a unique challenge for Avalanche Warp messages. To reach the required stake threshold, numerous signatures would need to be collected and verifying messages from the Primary Network would be computationally costly. However, we have developed a more efficient solution.
84+
#### Subnets
8585

86-
When an Avalanche L1 receives a message from a blockchain on the Primary Network, we use the validator set of the receiving L1 instead of the entire network when validating the message. Note this is NOT possible if an L1 does not validate the Primary Network, in which case the Warp precompile must be configured with `requirePrimaryNetworkSigners`.
86+
Recall that Avalanche Subnet validators must also validate the Primary Network, so it tracks all of the blockchains in the Primary Network (X, C, and P-Chains).
8787

88-
Sending messages from the C-Chain remains unchanged.
89-
However, when L1 XYZ receives a message from the C-Chain, it changes the semantics to the following:
88+
When an Avalanche Subnet receives a message from a blockchain on the Primary Network, we use the validator set of the receiving Subnet instead of the entire network when validating the message.
9089

91-
1. Read the `SourceChainID` of the signed message (C-Chain)
92-
2. Look up the `SubnetID` that validates C-Chain: Primary Network
93-
3. Look up the validator set of L1 XYZ (instead of the Primary Network) and the registered BLS Public Keys of L1 XYZ at the P-Chain height specified by the ProposerVM header
94-
4. Continue Warp Message verification using the validator set of L1 XYZ instead of the Primary Network
90+
Sending messages from the X, C, or P-Chain remains unchanged.
91+
However, when the Subnet receives the message, it changes the semantics to the following:
9592

96-
This means that C-Chain to L1 communication only requires a threshold of stake on the receiving L1 to sign the message instead of a threshold of stake for the entire Primary Network.
93+
1. Read the `SourceChainID` of the signed message
94+
2. Look up the `SubnetID` that validates `SourceChainID`. In this case it will be the Primary Network's `SubnetID`
95+
3. Look up the validator set of the Subnet (instead of the Primary Network) and the registered BLS Public Keys of the Subnet validators at the P-Chain height specified by the ProposerVM header
96+
4. Continue Warp Message verification using the validator set of the Subnet instead of the Primary Network
9797

98-
This assumes that the security of L1 XYZ already depends on the validators of L1 XYZ to behave virtuously. Therefore, requiring a threshold of stake from the receiving L1's validator set instead of the whole Primary Network does not meaningfully change security of the receiving L1.
98+
This means that Primary Network to Subnet communication only requires a threshold of stake on the receiving Subnet to sign the message instead of a threshold of stake for the entire Primary Network.
9999

100-
Note: this special case is ONLY applied during Warp Message verification. The message sent by the Primary Network will still contain the Avalanche C-Chain's blockchainID as the sourceChainID and signatures will be served by querying the C-Chain directly.
100+
Since the security of the Subnet is provided by trust in its validator set, requiring a threshold of stake from the receiving Subnet's validator set instead of the whole Primary Network does not meaningfully change the security of the receiving L1.
101+
102+
Note: this special case is ONLY applied during Warp Message verification. The message sent by the Primary Network will still contain the blockchainID of the Primary Network chain that sent the message as the sourceChainID and signatures will be served by querying the source chain directly.
103+
104+
#### L1s
105+
106+
Avalanche L1s are only required to sync the P-Chain, but are not required to validate the Primary Network. Therefore, **for L1s, this optimization only applies to Warp messages sent by the P-Chain.** The rest of the description of this optimization in the above section applies to L1s.
107+
108+
Note that **in order to properly verify messages from the C-Chain and X-Chain, the Warp precompile must be configured with `requirePrimaryNetworkSigners` set to `true`**. Otherwise, we will attempt to verify the message signature against the receiving L1's validator set, which is not required to track the C-Chain or X-Chain, and therefore will not in general be able to produce a valid Warp message.
101109

102110
## Design Considerations
103111

0 commit comments

Comments
 (0)