Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sishan/merge sig agg to main 0821 #1587

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
7625472
with public hotshot_primitive
dailinsubjam Jun 13, 2023
134862c
change signature scheme from BLSSignatureScheme to BLSOverBN254CurveS…
dailinsubjam Jun 21, 2023
8b5f092
Added KeyPair and a new robust version of jf-primitives
dailinsubjam Jun 29, 2023
0d1abfd
fixing small bugs when running all tests
dailinsubjam Jun 30, 2023
0cd0244
Implement Commitment<T> for all the kinds of VoteData
dailinsubjam Jul 1, 2023
61b6180
replace .as_bytes() with .commit().as_ref()
dailinsubjam Jul 3, 2023
e25d08f
Change the type of [u8] to [u8, 32] so that sign() can take in generi…
dailinsubjam Jul 3, 2023
d3cae68
Change the input type from [u8] to generic array
dailinsubjam Jul 3, 2023
8418e33
add notes for message in static_committee.rs
dailinsubjam Jul 3, 2023
286b39b
Merge pull request #1326 from EspressoSystems/sishan/implement_commit…
dailinsubjam Jul 4, 2023
590a08e
make validate() directly return bool for short term
dailinsubjam Jul 10, 2023
f7727c7
Add entry with stake public key and stake_amount for QC Aseembling
dailinsubjam Jul 10, 2023
fb25b1a
assembling of QC signature aggregation added
dailinsubjam Jul 10, 2023
543e95f
notes for assembling
dailinsubjam Jul 10, 2023
deace86
assembling mostly done (besides few bitvec-bytes transfer)
dailinsubjam Jul 11, 2023
91a6eb1
Update validate() before doing append()
dailinsubjam Jul 12, 2023
094e299
Add bitvec serialization
shenkeyao Jul 12, 2023
26311b2
Merge pull request #1377 from EspressoSystems/keyao/try-bit-vec
dailinsubjam Jul 12, 2023
923a4fe
add QCParams to qc
dailinsubjam Jul 12, 2023
198c275
Merge branch 'sishan/signature_aggregation_with_hsp' of github.com:Es…
dailinsubjam Jul 12, 2023
57e09d6
Add sig serialization helper
shenkeyao Jul 12, 2023
9a24c5a
Merge pull request #1378 from EspressoSystems/keyao/try-bit-vec
dailinsubjam Jul 12, 2023
5328c05
Merge branch 'sishan/signature_aggregation_with_hsp' of github.com:Es…
dailinsubjam Jul 13, 2023
276fac2
solve conflicts
dailinsubjam Jul 13, 2023
a436c39
validation not work
dailinsubjam Jul 13, 2023
bd65ec7
Validation on aggregated signature works
dailinsubjam Jul 13, 2023
73b0810
last commit also include separating DA vote and Yes vote in QC
dailinsubjam Jul 13, 2023
ca06668
param_pp and bit_vector is global now, so that only one signature and…
dailinsubjam Jul 20, 2023
c3e48bb
clean up
dailinsubjam Jul 20, 2023
4c5eebd
clean up on cargo dependency
dailinsubjam Jul 20, 2023
08e907a
more clean up and renaming QCYesNoVote to AssembledSignature since it…
dailinsubjam Jul 20, 2023
4b52521
more clean up and comments updated
dailinsubjam Jul 20, 2023
344f9e6
more clean up and ready to merge into run view refactor
dailinsubjam Jul 20, 2023
5b125bd
comments refined
dailinsubjam Jul 20, 2023
ad951e4
delete dead code and deal with potential panic situation
dailinsubjam Jul 20, 2023
d416b3f
blank line after last line for cargo.toml
dailinsubjam Jul 20, 2023
b2ccb15
delete dead code
dailinsubjam Jul 20, 2023
b1e2e7e
change the dependency of hotshot-primitives and jellyfish to the newe…
dailinsubjam Jul 22, 2023
de5e948
pin to jellyfish's and hotshot-primitives' hotshot-compat branch rath…
dailinsubjam Jul 22, 2023
58f0068
Merge branch 'sishan/signature_aggregation_with_hsp' into run_view_re…
dailinsubjam Jul 25, 2023
343e34b
changes for merging
dailinsubjam Jul 25, 2023
c333f2d
fix examples
dailinsubjam Jul 25, 2023
fca5743
Merge pull request #1432 from EspressoSystems/sishan/run_view_refacto…
dailinsubjam Jul 25, 2023
592578d
fix committable and is_valid_view_sync_cert() for run view related co…
dailinsubjam Jul 25, 2023
612d423
revert changes for two comment-ed files in testing/tests
dailinsubjam Jul 26, 2023
2cfc7d3
blank lines
dailinsubjam Jul 26, 2023
a078472
Merge pull request #1429 from EspressoSystems/run_view_refactor_sig_agg
dailinsubjam Jul 26, 2023
6a82c67
traits are also implemented for BN254
dailinsubjam Aug 3, 2023
d6ef7dd
(real) traits are also implemented for BN254
dailinsubjam Aug 3, 2023
ed6c6a2
update all the place using ed25519 to bn254
dailinsubjam Aug 5, 2023
64ab775
totally get rid of ed25519 except for libp2p
dailinsubjam Aug 5, 2023
12411cc
Restore validate() and sign() for original ed25519 for parameterizing…
dailinsubjam Aug 5, 2023
16edc06
hotshot-compat update
dailinsubjam Aug 5, 2023
1933d4d
clean up some warnings
dailinsubjam Aug 5, 2023
7bc3d14
cleanup some todo
dailinsubjam Aug 7, 2023
759bdf2
dealing with unwrap() and serialization in sign()
dailinsubjam Aug 7, 2023
9c8fa77
Merge pull request #1482 from EspressoSystems/sishan/signature_scheme…
dailinsubjam Aug 7, 2023
9d7425b
substitude all JfPubKey<JfPubKey<BLSOverBN254CurveSignatureScheme> to…
dailinsubjam Aug 9, 2023
546d6c7
totally get rid of JfPubKey
dailinsubjam Aug 9, 2023
1928da4
remove key_pair in validate()
dailinsubjam Aug 9, 2023
69037e7
remove KeyPair in sign()
dailinsubjam Aug 10, 2023
d53171c
remove KeyPair in make_vote_token() and validate_vote_token()
dailinsubjam Aug 10, 2023
462c5fc
clean up
dailinsubjam Aug 10, 2023
dd58214
Added get_committee_in_vec() for membership so that it can position a…
dailinsubjam Aug 10, 2023
e1a2f84
remove redundant parameters for VoteMetaData
dailinsubjam Aug 10, 2023
6f98011
remove redundant parameters in vote
dailinsubjam Aug 10, 2023
53b3bdb
remove redundant key_pair and ver_key
dailinsubjam Aug 10, 2023
682f1a4
renaming nodes with stake value
dailinsubjam Aug 10, 2023
e1068bc
clean up warnings
dailinsubjam Aug 10, 2023
7ad4498
Merge pull request #1530 from EspressoSystems/sishan/discard_Signatur…
dailinsubjam Aug 11, 2023
eb5e667
a non-working version
dailinsubjam Aug 14, 2023
db61256
Remove centralized server code
elliedavidson Aug 14, 2023
5f5df22
minor update
elliedavidson Aug 14, 2023
b86a7ef
minor update
elliedavidson Aug 14, 2023
f347544
feat: fix serde errors
DieracDelta Aug 14, 2023
6d6e5de
Add assemble() and check() to SignatureKey and partially parameterize…
dailinsubjam Aug 14, 2023
7a6137a
remove the file ed25519 with trait SignatureKey
dailinsubjam Aug 14, 2023
9134ddc
remove get_committee_in_vec()
dailinsubjam Aug 15, 2023
6dd41f2
remove get_committee_in_vec()
dailinsubjam Aug 15, 2023
d2cbaa4
remove get_stake_table() which only get Vec<PUBKEY>
dailinsubjam Aug 15, 2023
0b701c1
Merge pull request #1551 from EspressoSystems/sishan/parameterizing_c…
dailinsubjam Aug 15, 2023
b00eb77
fix errors and warnings arised when merging
dailinsubjam Aug 15, 2023
0e05b95
fix todo
dailinsubjam Aug 15, 2023
9cfbc91
clean up and try
dailinsubjam Aug 21, 2023
c7dd3ce
remain some cleanup
dailinsubjam Aug 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 99 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ tokio = { version = "1", optional = true, features = [
] }

tracing = "0.1.37"
ethereum-types = { version = "0.14.1", features = ["impl-serde"] }
bitvec = { version = "1.0.1", default-features = false, features = ["alloc", "atomic", "serde"] }
typenum = { version = "1.16.0" }

[dev-dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }
Expand Down
6 changes: 5 additions & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ tokio = { version = "1", optional = true, features = [
"tracing",
] }
tracing = "0.1.37"
time = "0.3.23"
time = "0.3.22" # 0.3.23
bitvec = { version = "1.0.1", default-features = false, features = ["alloc", "atomic", "serde"] }
hotshot-primitives = { git = "https://github.com/EspressoSystems/hotshot-primitives", branch = 'hotshot-compat'} # rev = "4aee90c" for 'hotshot-compat'
jf-primitives = { git = "https://github.com/EspressoSystems/jellyfish", branch = 'hotshot-compat'} # rev = "470a833" for branch = 'hotshot-compat'
blake3 = { version = "1.3.3", features = ["traits-preview"] }
2 changes: 0 additions & 2 deletions consensus/src/da_member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,13 @@ impl<
if view_leader_key != sender {
continue;
}

let block_commitment = p.data.deltas.commit();
if !view_leader_key
.validate(&p.signature, block_commitment.as_ref())
{
warn!(?p.signature, "Could not verify proposal.");
continue;
}

let vote_token = self.exchange.make_vote_token(self.cur_view);
match vote_token {
Err(e) => {
Expand Down
30 changes: 18 additions & 12 deletions consensus/src/sequencing_leader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use async_compatibility_layer::{
async_primitives::subscribable_rwlock::{ReadView, SubscribableRwLock},
};
use async_lock::{Mutex, RwLock};
use bitvec::prelude::*;
use commit::Commitment;
use commit::Committable;
use either::Either;
use either::{Left, Right};
use hotshot_types::data::QuorumProposal;
use hotshot_types::message::Message;
use hotshot_types::traits::election::CommitteeExchangeType;
use hotshot_types::traits::election::ConsensusExchange;
Expand All @@ -22,8 +22,8 @@ use hotshot_types::traits::node_implementation::{
};
use hotshot_types::traits::state::State;
use hotshot_types::{
certificate::{DACertificate, QuorumCertificate, YesNoSignature},
data::{DAProposal, SequencingLeaf},
certificate::{AssembledSignature, DACertificate, QuorumCertificate},
data::{DAProposal, QuorumProposal, SequencingLeaf},
message::{
CommitteeConsensusMessage, ConsensusMessageType, GeneralConsensusMessage, InternalTrigger,
ProcessedCommitteeConsensusMessage, ProcessedGeneralConsensusMessage,
Expand Down Expand Up @@ -98,16 +98,22 @@ where
&self,
cur_view: TYPES::Time,
threshold: NonZeroU64,
total_nodes_num: usize,
block_commitment: Commitment<<TYPES as NodeType>::BlockType>,
) -> Option<DACertificate<TYPES>> {
let lock = self.vote_collection_chan.lock().await;
let mut accumulator = VoteAccumulator {
total_vote_outcomes: HashMap::new(),
da_vote_outcomes: HashMap::new(),
yes_vote_outcomes: HashMap::new(),
no_vote_outcomes: HashMap::new(),
viewsync_precommit_vote_outcomes: HashMap::new(),
viewsync_commit_vote_outcomes: HashMap::new(),
viewsync_finalize_vote_outcomes: HashMap::new(),
success_threshold: threshold,
failure_threshold: threshold,
sig_lists: Vec::new(),
signers: bitvec![0; total_nodes_num],
};

while let Ok(msg) = lock.recv().await {
Expand Down Expand Up @@ -157,9 +163,8 @@ where
}
Either::Right(qc) => {
match qc.clone().signatures {
YesNoSignature::Yes(map) => {
info!("Number of DA signatures in this QC: {}", map.len());
}
AssembledSignature::Yes(_signature) => {}
AssembledSignature::DA(_signature) => {}
_ => unimplemented!(),
};
return Some(qc);
Expand Down Expand Up @@ -297,6 +302,7 @@ where
.wait_for_votes(
self.cur_view,
self.committee_exchange.success_threshold(),
self.committee_exchange.total_nodes(),
block_commitment,
)
.await
Expand Down Expand Up @@ -385,7 +391,6 @@ where
dac: Some(self.cert),
proposer_id: leaf.proposer_id,
};

let message =
SequencingMessage::<TYPES, I>(Left(GeneralConsensusMessage::Proposal(Proposal {
data: proposal,
Expand Down Expand Up @@ -459,14 +464,18 @@ where
pub async fn run_view(self) -> QuorumCertificate<TYPES, SequencingLeaf<TYPES>> {
let mut qcs = HashSet::<QuorumCertificate<TYPES, SequencingLeaf<TYPES>>>::new();
qcs.insert(self.generic_qc.clone());

let mut accumulator = VoteAccumulator {
total_vote_outcomes: HashMap::new(),
da_vote_outcomes: HashMap::new(),
yes_vote_outcomes: HashMap::new(),
no_vote_outcomes: HashMap::new(),
viewsync_precommit_vote_outcomes: HashMap::new(),
viewsync_commit_vote_outcomes: HashMap::new(),
viewsync_finalize_vote_outcomes: HashMap::new(),
success_threshold: self.quorum_exchange.success_threshold(),
failure_threshold: self.quorum_exchange.failure_threshold(),
sig_lists: Vec::new(),
signers: bitvec![0; self.quorum_exchange.total_nodes()],
};

let lock = self.vote_collection_chan.lock().await;
Expand Down Expand Up @@ -501,10 +510,7 @@ where
}
Either::Right(qc) => {
match qc.clone().signatures {
YesNoSignature::Yes(map) => info!(
"Number of qurorum signatures in this QC: {}",
map.len()
),
AssembledSignature::Yes(_signature) => {}
_ => unimplemented!(),
};
return qc;
Expand Down
6 changes: 5 additions & 1 deletion examples/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use hotshot_types::traits::node_implementation::NodeType;
use hotshot_types::traits::signature_key::SignatureKey;
use libp2p::{
identity::{
ed25519::{Keypair as EdKeypair, SecretKey},
bn254::{Keypair as EdKeypair, SecretKey},
Keypair,
},
multiaddr::{self},
Expand Down Expand Up @@ -57,6 +57,10 @@ pub fn load_config_from_file<TYPES: NodeType>(
})
.collect();

config.config.known_nodes_with_stake = (0..config.config.total_nodes.get())
.map(|node_id| config.config.known_nodes[node_id].get_stake_table_entry(1u64))
.collect();

config
}

Expand Down
9 changes: 5 additions & 4 deletions examples/infra/modDA.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ pub trait RunDA<

let config = self.get_config();

// Get KeyPair for certificate Aggregation
let (pk, sk) =
TYPES::SignatureKey::generated_from_seed_indexed(config.seed, config.node_index);
let ek = jf_primitives::aead::KeyPair::generate(&mut rand_chacha::ChaChaRng::from_seed(
config.seed,
));
let known_nodes = config.config.known_nodes.clone();
let known_nodes_with_stake = config.config.known_nodes_with_stake.clone();
let entry = pk.get_stake_table_entry(1u64);

let da_network = self.get_da_network();
let quorum_network = self.get_quorum_network();
Expand All @@ -252,6 +252,7 @@ pub trait RunDA<
);

let exchanges = NODE::Exchanges::create(
known_nodes_with_stake.clone(),
known_nodes.clone(),
(quorum_election_config, committee_election_config),
(
Expand All @@ -260,8 +261,8 @@ pub trait RunDA<
view_sync_network.clone(),
),
pk.clone(),
entry.clone(),
sk.clone(),
ek.clone(),
);

SystemContext::init(
Expand Down
14 changes: 11 additions & 3 deletions orchestrator/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use async_compatibility_layer::art::async_sleep;
use clap::Parser;
use futures::{Future, FutureExt};

use hotshot_types::traits::node_implementation::NodeType;
use hotshot_types::traits::{node_implementation::NodeType, signature_key::SignatureKey};
use surf_disco::{error::ClientError, Client};

/// Holds the client connection to the orchestrator
Expand Down Expand Up @@ -63,11 +63,19 @@ impl OrchestratorClient {
pub async fn get_config_from_orchestrator<TYPES: NodeType>(
&self,
node_index: u16,
) -> NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType> {
) -> NetworkConfig<
TYPES::SignatureKey,
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry,
TYPES::ElectionConfigType,
> {
let f = |client: Client<ClientError>| {
async move {
let config: Result<
NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType>,
NetworkConfig<
TYPES::SignatureKey,
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry,
TYPES::ElectionConfigType,
>,
ClientError,
> = client
.post(&format!("api/config/{node_index}"))
Expand Down
12 changes: 6 additions & 6 deletions orchestrator/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use hotshot_types::{ExecutionType, HotShotConfig};
use std::net::{Ipv4Addr, SocketAddr};
use std::{net::IpAddr, num::NonZeroUsize, time::Duration};

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
pub struct Libp2pConfig {
pub bootstrap_nodes: Vec<(SocketAddr, Vec<u8>)>,
Expand Down Expand Up @@ -53,7 +52,7 @@ pub struct WebServerConfig {
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
pub struct NetworkConfig<KEY, ELECTIONCONFIG> {
pub struct NetworkConfig<KEY, ENTRY, ELECTIONCONFIG> {
pub rounds: usize,
pub transactions_per_round: usize,
pub node_index: u64,
Expand All @@ -63,12 +62,12 @@ pub struct NetworkConfig<KEY, ELECTIONCONFIG> {
pub key_type_name: String,
pub election_config_type_name: String,
pub libp2p_config: Option<Libp2pConfig>,
pub config: HotShotConfig<KEY, ELECTIONCONFIG>,
pub config: HotShotConfig<KEY, ENTRY, ELECTIONCONFIG>,
pub web_server_config: Option<WebServerConfig>,
pub da_web_server_config: Option<WebServerConfig>,
}

impl<K, E> Default for NetworkConfig<K, E> {
impl<K, ENTRY, E> Default for NetworkConfig<K, ENTRY, E> {
fn default() -> Self {
Self {
rounds: default_rounds(),
Expand Down Expand Up @@ -115,7 +114,7 @@ fn default_web_server_config() -> Option<WebServerConfig> {
None
}

impl<K, E> From<NetworkConfigFile> for NetworkConfig<K, E> {
impl<K, ENTRY, E> From<NetworkConfigFile> for NetworkConfig<K, ENTRY, E> {
fn from(val: NetworkConfigFile) -> Self {
NetworkConfig {
rounds: val.rounds,
Expand Down Expand Up @@ -181,14 +180,15 @@ pub struct HotShotConfigFile {
pub propose_max_round_time: Duration,
}

impl<K, E> From<HotShotConfigFile> for HotShotConfig<K, E> {
impl<K, ENTRY, E> From<HotShotConfigFile> for HotShotConfig<K, ENTRY, E> {
fn from(val: HotShotConfigFile) -> Self {
HotShotConfig {
execution_type: ExecutionType::Continuous,
total_nodes: val.total_nodes,
max_transactions: val.max_transactions,
min_transactions: val.min_transactions,
known_nodes: Vec::new(),
known_nodes_with_stake: Vec::new(),
da_committee_size: val.committee_nodes,
next_view_timeout: val.next_view_timeout,
timeout_ratio: val.timeout_ratio,
Expand Down
28 changes: 15 additions & 13 deletions orchestrator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ pub fn libp2p_generate_indexed_identity(seed: [u8; 32], index: u64) -> Keypair {
}

#[derive(Default, Clone)]
struct OrchestratorState<KEY, ELECTION> {
struct OrchestratorState<KEY, ENTRY, ELECTION> {
/// Tracks the latest node index we have generated a configuration for
latest_index: u16,
/// The network configuration
config: NetworkConfig<KEY, ELECTION>,
config: NetworkConfig<KEY, ENTRY, ELECTION>,
/// Whether nodes should start their HotShot instances
/// Will be set to true once all nodes post they are ready to start
start: bool,
Expand All @@ -52,9 +52,9 @@ struct OrchestratorState<KEY, ELECTION> {
}

impl<KEY: SignatureKey + 'static, ELECTION: ElectionConfig + 'static>
OrchestratorState<KEY, ELECTION>
OrchestratorState<KEY, KEY::StakeTableEntry, ELECTION>
{
pub fn new(network_config: NetworkConfig<KEY, ELECTION>) -> Self {
pub fn new(network_config: NetworkConfig<KEY, KEY::StakeTableEntry, ELECTION>) -> Self {
let mut web_client = None;
if network_config.web_server_config.is_some() {
let base_url = "http://0.0.0.0/9000".to_string().parse().unwrap();
Expand All @@ -70,18 +70,19 @@ impl<KEY: SignatureKey + 'static, ELECTION: ElectionConfig + 'static>
}
}

pub trait OrchestratorApi<KEY, ELECTION> {
pub trait OrchestratorApi<KEY, ENTRY, ELECTION> {
fn post_identity(&mut self, identity: IpAddr) -> Result<u16, ServerError>;
fn post_getconfig(
&mut self,
node_index: u16,
) -> Result<NetworkConfig<KEY, ELECTION>, ServerError>;
) -> Result<NetworkConfig<KEY, ENTRY, ELECTION>, ServerError>;
fn get_start(&self) -> Result<bool, ServerError>;
fn post_ready(&mut self) -> Result<(), ServerError>;
fn post_run_results(&mut self) -> Result<(), ServerError>;
}

impl<KEY, ELECTION> OrchestratorApi<KEY, ELECTION> for OrchestratorState<KEY, ELECTION>
impl<KEY, ELECTION> OrchestratorApi<KEY, KEY::StakeTableEntry, ELECTION>
for OrchestratorState<KEY, KEY::StakeTableEntry, ELECTION>
where
KEY: serde::Serialize + Clone + SignatureKey,
ELECTION: serde::Serialize + Clone + Send,
Expand Down Expand Up @@ -142,7 +143,7 @@ where
fn post_getconfig(
&mut self,
_node_index: u16,
) -> Result<NetworkConfig<KEY, ELECTION>, ServerError> {
) -> Result<NetworkConfig<KEY, KEY::StakeTableEntry, ELECTION>, ServerError> {
if self.config.libp2p_config.is_some() {
let libp2p_config = self.config.clone().libp2p_config.unwrap();
if libp2p_config.bootstrap_nodes.len()
Expand Down Expand Up @@ -185,11 +186,12 @@ where
}

/// Sets up all API routes
fn define_api<KEY, ELECTION, State>() -> Result<Api<State, ServerError>, ApiError>
fn define_api<KEY, ELECTION, ENTRY, State>() -> Result<Api<State, ServerError>, ApiError>
where
State: 'static + Send + Sync + ReadState + WriteState,
<State as ReadState>::State: Send + Sync + OrchestratorApi<KEY, ELECTION>,
<State as ReadState>::State: Send + Sync + OrchestratorApi<KEY, ENTRY, ELECTION>,
KEY: serde::Serialize,
ENTRY: serde::Serialize,
ELECTION: serde::Serialize,
{
let api_toml = toml::from_str::<toml::Value>(include_str!(concat!(
Expand Down Expand Up @@ -232,7 +234,7 @@ where

/// Runs the orchestrator
pub async fn run_orchestrator<KEY, ELECTION>(
network_config: NetworkConfig<KEY, ELECTION>,
network_config: NetworkConfig<KEY, KEY::StakeTableEntry, ELECTION>,
host: IpAddr,
port: u16,
) -> io::Result<()>
Expand All @@ -242,10 +244,10 @@ where
{
let api = define_api().map_err(|_e| io::Error::new(ErrorKind::Other, "Failed to define api"));

let state: RwLock<OrchestratorState<KEY, ELECTION>> =
let state: RwLock<OrchestratorState<KEY, KEY::StakeTableEntry, ELECTION>> =
RwLock::new(OrchestratorState::new(network_config));

let mut app = App::<RwLock<OrchestratorState<KEY, ELECTION>>, ServerError>::with_state(state);
let mut app = App::<RwLock<OrchestratorState<KEY, KEY::StakeTableEntry, ELECTION>>, ServerError>::with_state(state);
app.register_module("api", api.unwrap())
.expect("Error registering api");
tracing::error!("lisening on {:?}:{:?}", host, port);
Expand Down
Loading
Loading