1use std::marker::PhantomData;
2
3use hotshot_types::{
4 data::{EpochNumber, ViewNumber},
5 signature_key::{BLSPubKey, SchnorrPubKey},
6 traits::{
7 node_implementation::{NodeType, Versions},
8 signature_key::SignatureKey,
9 },
10};
11use serde::{Deserialize, Serialize};
12
13pub mod config;
14mod header;
15mod impls;
16mod nsproof;
17pub mod traits;
18mod utils;
19pub use header::Header;
20#[cfg(any(test, feature = "testing"))]
21pub use impls::mock;
22pub use impls::{
23 get_l1_deposits, retain_accounts, validators_from_l1_events, BuilderValidationError,
24 EpochCommittees, FeeError, ProposalValidationError, StateValidationError,
25};
26pub use nsproof::*;
27pub use utils::*;
28use vbs::version::{StaticVersion, StaticVersionType};
29
30macro_rules! with_minor_versions {
39 ($m:ident!($($arg:tt),*)) => {
40 $m!($($arg,)* v0_1, v0_2, v0_3, v0_99);
41 };
42}
43
44macro_rules! define_modules {
46 ($($m:ident),+) => {
47 $(pub mod $m;)+
48 };
49}
50with_minor_versions!(define_modules!());
51
52macro_rules! assert_eq_all_versions_of_type {
53 ($t:ident, $($m:ident),+) => {
54 static_assertions::assert_type_eq_all!($($m::$t),+);
55 };
56}
57
58macro_rules! reexport_latest_version_of_type {
59 ($t:ident, $m:ident) => { pub use $m::$t; };
60 ($t:ident, $m1:ident, $($m:ident),+) => {
61 reexport_latest_version_of_type!($t, $($m),+);
62 }
63}
64
65macro_rules! reexport_unchanged_types {
67 ($($t:ident),+ $(,)?) => {
68 $(
69 with_minor_versions!(assert_eq_all_versions_of_type!($t));
70 with_minor_versions!(reexport_latest_version_of_type!($t));
71 )+
72 }
73}
74reexport_unchanged_types!(
75 AccountQueryData,
76 BlockMerkleCommitment,
77 BlockMerkleTree,
78 BuilderSignature,
79 ChainId,
80 Delta,
81 FeeAccount,
82 FeeAccountProof,
83 FeeAmount,
84 FeeInfo,
85 FeeMerkleCommitment,
86 FeeMerkleProof,
87 FeeMerkleTree,
88 Index,
89 Iter,
90 L1BlockInfo,
91 L1Client,
92 L1ClientOptions,
93 L1Snapshot,
94 NamespaceId,
95 NsIndex,
96 NsIter,
97 NsPayload,
98 NsPayloadBuilder,
99 NsPayloadByteLen,
100 NsPayloadOwned,
101 NsPayloadRange,
102 NsTable,
103 NsTableBuilder,
104 NsTableValidationError,
105 NumNss,
106 NumTxs,
107 NumTxsRange,
108 NumTxsUnchecked,
109 Payload,
110 PayloadByteLen,
111 Transaction,
112 TxIndex,
113 TxIter,
114 TxPayload,
115 TxPayloadRange,
116 TxProof,
117 TxTableEntries,
118 TxTableEntriesRange,
119 Upgrade,
120 UpgradeType,
121 UpgradeMode,
122 TimeBasedUpgrade,
123 ViewBasedUpgrade,
124 BlockSize,
125);
126
127pub(crate) use v0_3::{L1ClientMetrics, L1Event, L1State, L1UpdateTask};
128
129#[derive(
130 Clone, Copy, Debug, Default, Hash, Eq, PartialEq, PartialOrd, Ord, Deserialize, Serialize,
131)]
132pub struct SeqTypes;
133
134impl NodeType for SeqTypes {
135 type View = ViewNumber;
136 type Epoch = EpochNumber;
137 type BlockHeader = Header;
138 type BlockPayload = Payload;
139 type SignatureKey = PubKey;
140 type Transaction = Transaction;
141 type InstanceState = NodeState;
142 type ValidatedState = ValidatedState;
143 type Membership = EpochCommittees;
144 type BuilderSignatureKey = FeeAccount;
145 type AuctionResult = SolverAuctionResults;
146 type StateSignatureKey = SchnorrPubKey;
147}
148
149#[derive(Clone, Default, Debug, Copy)]
150pub struct SequencerVersions<Base: StaticVersionType, Upgrade: StaticVersionType> {
151 _pd: PhantomData<(Base, Upgrade)>,
152}
153
154impl<Base: StaticVersionType, Upgrade: StaticVersionType> SequencerVersions<Base, Upgrade> {
155 pub fn new() -> Self {
156 Self {
157 _pd: Default::default(),
158 }
159 }
160}
161
162impl<Base: StaticVersionType + 'static, Upgrade: StaticVersionType + 'static> Versions
163 for SequencerVersions<Base, Upgrade>
164{
165 type Base = Base;
166 type Upgrade = Upgrade;
167 const UPGRADE_HASH: [u8; 32] = [
168 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
169 0, 0,
170 ];
171
172 type Marketplace = MarketplaceVersion;
173 type Epochs = EpochVersion;
174}
175
176pub type MockSequencerVersions = SequencerVersions<StaticVersion<0, 1>, StaticVersion<0, 2>>;
177
178pub type V0_0 = StaticVersion<0, 0>;
179pub type V0_1 = StaticVersion<0, 1>;
180pub type FeeVersion = StaticVersion<0, 2>;
181pub type EpochVersion = StaticVersion<0, 3>;
182pub type MarketplaceVersion = StaticVersion<0, 99>;
183
184pub type Leaf = hotshot_types::data::Leaf<SeqTypes>;
185pub type Leaf2 = hotshot_types::data::Leaf2<SeqTypes>;
186
187pub type Event = hotshot::types::Event<SeqTypes>;
188
189pub type PubKey = BLSPubKey;
190pub type PrivKey = <PubKey as SignatureKey>::PrivateKey;
191
192pub type NetworkConfig = hotshot_types::network::NetworkConfig<SeqTypes>;
193
194pub use self::impls::{NodeState, SolverAuctionResultsProvider, UpgradeMap, ValidatedState};
195pub use crate::v0_1::{
196 BLOCK_MERKLE_TREE_HEIGHT, FEE_MERKLE_TREE_HEIGHT, NS_ID_BYTE_LEN, NS_OFFSET_BYTE_LEN,
197 NUM_NSS_BYTE_LEN, NUM_TXS_BYTE_LEN, TX_OFFSET_BYTE_LEN,
198};
199use crate::v0_99::{ChainConfig, SolverAuctionResults};