1pub use hotshot_new_protocol::message::Certificate2;
2pub use hotshot_types::new_protocol::Proposal as NewProposal;
3use hotshot_types::{
4 signature_key::{BLSPubKey, SchnorrPubKey},
5 traits::{node_implementation::NodeType, signature_key::SignatureKey},
6};
7use serde::{Deserialize, Serialize};
8
9pub mod config;
10mod header;
11mod impls;
12mod nsproof;
13pub mod reward_mt;
14pub mod sparse_mt;
15pub mod traits;
16mod txproof;
17mod utils;
18
19pub use header::Header;
20#[cfg(any(test, feature = "testing"))]
21pub use impls::mock;
22pub use impls::reward::{
24 ComputedRewards, EpochRewardsCalculator, EpochRewardsResult, RewardDistributor,
25 ValidatorLeaderCounts,
26};
27#[cfg(any(test, feature = "testing"))]
28pub use impls::testing;
29pub use impls::{
30 BuilderValidationError, EpochCommittees, EpochCommitteesError, EpochSnapshot, FeeError,
31 ProposalValidationError, StateValidationError, ValidatorSet, get_l1_deposits, retain_accounts,
32 validators_from_l1_events,
33};
34pub use nsproof::*;
35pub use txproof::*;
36pub use utils::*;
37use vbs::version::StaticVersion;
38
39macro_rules! with_minor_versions {
48 ($m:ident!($($arg:tt),*)) => {
49 $m!($($arg,)* v0_1, v0_2, v0_3, v0_4, v0_5, v0_6);
50 };
51}
52
53macro_rules! define_modules {
55 ($($m:ident),+) => {
56 $(pub mod $m;)+
57 };
58}
59with_minor_versions!(define_modules!());
60
61macro_rules! assert_eq_all_versions_of_type {
62 ($t:ident, $($m:ident),+) => {
63 static_assertions::assert_type_eq_all!($($m::$t),+);
64 };
65}
66
67macro_rules! reexport_latest_version_of_type {
68 ($t:ident, $m:ident) => { pub use $m::$t; };
69 ($t:ident, $m1:ident, $($m:ident),+) => {
70 reexport_latest_version_of_type!($t, $($m),+);
71 }
72}
73
74macro_rules! reexport_unchanged_types {
76 ($($t:ident),+ $(,)?) => {
77 $(
78 with_minor_versions!(assert_eq_all_versions_of_type!($t));
79 with_minor_versions!(reexport_latest_version_of_type!($t));
80 )+
81 }
82}
83reexport_unchanged_types!(
84 AccountQueryData,
85 BlockMerkleCommitment,
86 BlockMerkleTree,
87 BuilderSignature,
88 ChainId,
89 FeeAccount,
90 FeeAccountProof,
91 FeeAmount,
92 FeeInfo,
93 FeeMerkleCommitment,
94 FeeMerkleProof,
95 FeeMerkleTree,
96 Index,
97 Iter,
98 L1BlockInfo,
99 L1Client,
100 L1ClientOptions,
101 L1Snapshot,
102 NamespaceId,
103 NsIndex,
104 NsIter,
105 NsPayload,
106 NsPayloadBuilder,
107 NsPayloadByteLen,
108 NsPayloadOwned,
109 NsPayloadRange,
110 NsTable,
111 NsTableBuilder,
112 NsTableValidationError,
113 NumNss,
114 NumTxs,
115 NumTxsRange,
116 NumTxsUnchecked,
117 Payload,
118 PayloadByteLen,
119 Transaction,
120 TxIndex,
121 TxIter,
122 TxPayload,
123 TxPayloadRange,
124 TxTableEntries,
125 TxTableEntriesRange,
126 Upgrade,
127 UpgradeType,
128 UpgradeMode,
129 TimeBasedUpgrade,
130 ViewBasedUpgrade,
131 BlockSize,
132);
133
134pub use v0_3::StateCertQueryDataV1;
135pub(crate) use v0_3::{L1ClientMetrics, L1Event, L1State, L1UpdateTask};
136pub use v0_4::StateCertQueryDataV2;
137use versions::version;
138
139#[derive(
140 Clone, Copy, Debug, Default, Hash, Eq, PartialEq, PartialOrd, Ord, Deserialize, Serialize,
141)]
142pub struct SeqTypes;
143
144impl NodeType for SeqTypes {
145 type BlockHeader = Header;
146 type BlockPayload = Payload;
147 type SignatureKey = PubKey;
148 type Transaction = Transaction;
149 type InstanceState = NodeState;
150 type ValidatedState = ValidatedState;
151 type Membership = EpochCommittees;
152 type BuilderSignatureKey = FeeAccount;
153 type StateSignatureKey = SchnorrPubKey;
154}
155
156pub const MOCK_SEQUENCER_VERSIONS: versions::Upgrade =
157 versions::Upgrade::new(version(0, 1), version(0, 2));
158
159pub type FeeVersion = StaticVersion<0, 2>;
160pub type EpochVersion = StaticVersion<0, 3>;
161pub type DrbAndHeaderUpgradeVersion = StaticVersion<0, 4>;
162pub type EpochRewardVersion = StaticVersion<0, 5>;
163
164pub type Leaf = hotshot_types::data::Leaf<SeqTypes>;
165pub type Leaf2 = hotshot_types::data::Leaf2<SeqTypes>;
166
167pub type Event = hotshot::types::Event<SeqTypes>;
168
169pub type PubKey = BLSPubKey;
170pub type PrivKey = <PubKey as SignatureKey>::PrivateKey;
171
172pub type NetworkConfig = hotshot_types::network::NetworkConfig<SeqTypes>;
173
174pub use self::impls::{
175 AuthenticatedValidatorMap, NodeState, RegisteredValidatorMap, UpgradeMap, ValidatedState,
176};
177pub use crate::{
178 v0::impls::{
179 StakeTableHash, StakeTableState, calculate_proportion_staked_and_reward_rate,
180 to_registered_validator_map,
181 },
182 v0_1::{
183 BLOCK_MERKLE_TREE_HEIGHT, FEE_MERKLE_TREE_HEIGHT, NS_ID_BYTE_LEN, NS_OFFSET_BYTE_LEN,
184 NUM_NSS_BYTE_LEN, NUM_TXS_BYTE_LEN, TX_OFFSET_BYTE_LEN,
185 },
186 v0_3::ChainConfig,
187};