Add comments on vaa min length (#1206)

* Add proof of work on minVAALength

* Change minVAALength to 57
This commit is contained in:
Jonathan Claudius 2022-05-24 10:42:30 -04:00 committed by GitHub
parent e63d7f5b77
commit 1e6611ebb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -198,7 +198,25 @@ const (
// ChainIDEthereumRopsten is the ChainID of Ethereum Ropsten
ChainIDEthereumRopsten ChainID = 10001
minVAALength = 1 + 4 + 52 + 4 + 1 + 1
// Minimum VAA size is derrived from the following assumptions:
// HEADER
// - Supported VAA Version (1 byte)
// - Guardian Set Index (4 bytes)
// - Length of Signatures (1 byte) <== assume no signatures
// - Actual Signatures (0 bytes)
// BODY
// - timestamp (4 bytes)
// - nonce (4 bytes)
// - emitter chain (2 bytes)
// - emitter address (32 bytes)
// - sequence (8 bytes)
// - consistency level (1 byte)
// - payload (0 bytes)
//
// From Above: 1 + 4 + 1 + 0 + 4 + 4 + 2 + 32 + 8 + 1 + 0 // Equals 57
//
// More details here: https://docs.wormholenetwork.com/wormhole/vaas
minVAALength = 57
SupportedVAAVersion = 0x01
)

View File

@ -114,6 +114,10 @@ func TestSignature_DataString(t *testing.T) {
assert.Equal(t, sigData.String(), expected)
}
func TestMinVAALength(t *testing.T) {
assert.Equal(t, minVAALength, 57)
}
func TestChainId_String(t *testing.T) {
type test struct {
input ChainID