module ValidatorSet {
resource T {
// size of the validator set. Currently serialization format will enforce the lexicographic ordering by field
// name, thus we need to carefully choose the name for the deserialization order from the validator side.
// Validators need to interpret it and use the first `array_size` fields as the keys and ignore the rest.
// TODO: Replace this with generic array once Move supports generic collections.
array_size: u64,
// Pubkey list. Since we don't have array for now, use hard coded fields instead.
key0: V#Self.ValidatorPublicKeys,
key1: V#Self.ValidatorPublicKeys,
key2: V#Self.ValidatorPublicKeys,
key3: V#Self.ValidatorPublicKeys,
key4: V#Self.ValidatorPublicKeys,
key5: V#Self.ValidatorPublicKeys,
key6: V#Self.ValidatorPublicKeys,
key7: V#Self.ValidatorPublicKeys,
key8: V#Self.ValidatorPublicKeys,
key9: V#Self.ValidatorPublicKeys,
}
struct ValidatorPublicKeys {
account_address: address,
consensus_public_key: bytearray,
network_identity_public_key: bytearray,
network_signing_public_key: bytearray,
}
publish_validator_set(
size: u64,
key0: V#Self.ValidatorPublicKeys,
key1: V#Self.ValidatorPublicKeys,
key2: V#Self.ValidatorPublicKeys,
key3: V#Self.ValidatorPublicKeys,
key4: V#Self.ValidatorPublicKeys,
key5: V#Self.ValidatorPublicKeys,
key6: V#Self.ValidatorPublicKeys,
key7: V#Self.ValidatorPublicKeys,
key8: V#Self.ValidatorPublicKeys,
key9: V#Self.ValidatorPublicKeys
) {
let set: R#Self.T;
// We only support at most 10 validator keys for now. Will get rid of of that
assert(copy(size) <= 10, 42);
set = T {
array_size: move(size),
key0: move(key0),
key1: move(key1),
key2: move(key2),
key3: move(key3),
key4: move(key4),
key5: move(key5),
key6: move(key6),
key7: move(key7),
key8: move(key8),
key9: move(key9),
};
move_to_sender<T>(move(set));
return;
}
make_new_validator_key(
account_address: address,
consensus_public_key: bytearray,
network_signing_public_key: bytearray,
network_identity_public_key: bytearray
): V#Self.ValidatorPublicKeys {
let key: V#Self.ValidatorPublicKeys;
key = ValidatorPublicKeys {
account_address: move(account_address),
consensus_public_key: move(consensus_public_key),
network_signing_public_key: move(network_signing_public_key),
network_identity_public_key: move(network_identity_public_key),
};
return move(key);
}
}