referrerpolicy=no-referrer-when-downgrade

snowbridge_beacon_primitives/
updates.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
3use codec::{Decode, DecodeWithMemTracking, Encode};
4use frame_support::{CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound};
5use scale_info::TypeInfo;
6use sp_core::H256;
7use sp_std::prelude::*;
8
9use crate::types::{BeaconHeader, SyncAggregate, SyncCommittee};
10
11#[derive(
12	Encode,
13	Decode,
14	DecodeWithMemTracking,
15	CloneNoBound,
16	PartialEqNoBound,
17	RuntimeDebugNoBound,
18	TypeInfo,
19)]
20#[cfg_attr(
21	feature = "std",
22	derive(serde::Serialize, serde::Deserialize),
23	serde(deny_unknown_fields, bound(serialize = ""), bound(deserialize = ""))
24)]
25pub struct CheckpointUpdate<const COMMITTEE_SIZE: usize> {
26	pub header: BeaconHeader,
27	pub current_sync_committee: SyncCommittee<COMMITTEE_SIZE>,
28	pub current_sync_committee_branch: Vec<H256>,
29	pub validators_root: H256,
30	pub block_roots_root: H256,
31	pub block_roots_branch: Vec<H256>,
32}
33
34#[derive(
35	Default,
36	Encode,
37	Decode,
38	DecodeWithMemTracking,
39	CloneNoBound,
40	PartialEqNoBound,
41	RuntimeDebugNoBound,
42	TypeInfo,
43)]
44#[cfg_attr(
45	feature = "std",
46	derive(serde::Deserialize),
47	serde(bound(serialize = ""), bound(deserialize = ""))
48)]
49pub struct Update<const COMMITTEE_SIZE: usize, const COMMITTEE_BITS_SIZE: usize> {
50	/// A recent header attesting to the finalized header, using its `state_root`.
51	pub attested_header: BeaconHeader,
52	/// The signing data that the sync committee produced for this attested header, including
53	/// who participated in the vote and the resulting signature.
54	pub sync_aggregate: SyncAggregate<COMMITTEE_SIZE, COMMITTEE_BITS_SIZE>,
55	/// The slot at which the sync aggregate can be found, typically attested_header.slot + 1, if
56	/// the next slot block was not missed.
57	pub signature_slot: u64,
58	/// The next sync committee for the next sync committee period, if present.
59	pub next_sync_committee_update: Option<NextSyncCommitteeUpdate<COMMITTEE_SIZE>>,
60	/// The latest finalized header.
61	pub finalized_header: BeaconHeader,
62	/// The merkle proof testifying to the finalized header, using the `attested_header.state_root`
63	/// as tree root.
64	pub finality_branch: Vec<H256>,
65	/// The finalized_header's `block_roots` root in the beacon state, used for ancestry proofs.
66	pub block_roots_root: H256,
67	/// The merkle path to prove the `block_roots_root` value.
68	pub block_roots_branch: Vec<H256>,
69}
70
71#[derive(
72	Default,
73	Encode,
74	Decode,
75	DecodeWithMemTracking,
76	CloneNoBound,
77	PartialEqNoBound,
78	RuntimeDebugNoBound,
79	TypeInfo,
80)]
81#[cfg_attr(
82	feature = "std",
83	derive(serde::Deserialize),
84	serde(deny_unknown_fields, bound(serialize = ""), bound(deserialize = ""))
85)]
86pub struct NextSyncCommitteeUpdate<const COMMITTEE_SIZE: usize> {
87	pub next_sync_committee: SyncCommittee<COMMITTEE_SIZE>,
88	pub next_sync_committee_branch: Vec<H256>,
89}