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

[VALIDATED_STATE] - Make Committable a supertrait of BlockHeader and merge changes in develop #2169

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
170 changes: 103 additions & 67 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/ValidatorConfigOutput
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ValidatorConfig { public_key: BLSPubKey { pub_key: VerKey((QuadExtField(2264797523581107490935262917175769123227923636811928330606075281145117212394 + 15807017392833049888165434456991157794698032464874424842715555348468160607934 * u), QuadExtField(7996517616082121122160563552650547601395271017260499735456299700133762512689 + 7504045709281061282278228438613345070383424761478787301859187055302953740948 * u), QuadExtField(1515973040548822760825076242090160370742046237881440422068330135941139244581 + 20251846261653098602911417004145145971080304248810966341160788194007704966108 * u))) }, private_key: BLSPrivKey { priv_key: SignKey(BigInt([3505488234151006356, 6655477166151225138, 3291219027844407676, 2153641080015542578])) }, stake_value: 1 }
ValidatorConfig { public_key: BLSPubKey { pub_key: VerKey((QuadExtField(2264797523581107490935262917175769123227923636811928330606075281145117212394 + 15807017392833049888165434456991157794698032464874424842715555348468160607934 * u), QuadExtField(7996517616082121122160563552650547601395271017260499735456299700133762512689 + 7504045709281061282278228438613345070383424761478787301859187055302953740948 * u), QuadExtField(1515973040548822760825076242090160370742046237881440422068330135941139244581 + 20251846261653098602911417004145145971080304248810966341160788194007704966108 * u))) }, private_key: BLSPrivKey { priv_key: SignKey(BigInt([3505488234151006356, 6655477166151225138, 3291219027844407676, 2153641080015542578])) }, stake_value: 1, state_key_pair: StateKeyPair(KeyPair { sk: SignKey(BigInt([2822822805887490846, 6664316196088353173, 4926510007447087464, 116097479308258694])), vk: VerKey(Projective { x: BigInt([11315198235793138814, 4744451806709910489, 6921831025042192557, 1125393823825936625]), y: BigInt([13035879815613524256, 18225673961538637854, 12006860967936477969, 1516668567229692859]), t: BigInt([13450777528397789701, 12242009376162249168, 12596256366242272750, 3368076418495976469]), z: BigInt([10465708325245823445, 13967918689717629445, 14943426723808572731, 621075342718756551]) }) }) }
40 changes: 17 additions & 23 deletions crates/hotshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ version = "0.3.3"
rust-version = "1.65.0"

[features]
default = ["demo", "docs", "doc-images"]

# Enable demo/testing logic
demo = [
"hotshot-types/demo",
"libp2p/rsa",
"dep:derivative",
]
default = ["docs", "doc-images"]

# Features required for binaries
bin-orchestrator = ["clap"]
Expand All @@ -28,74 +21,74 @@ hotshot-testing = []
# libp2p
[[example]]
name = "validator-libp2p"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/libp2p/validator.rs"

[[example]]
name = "multi-validator-libp2p"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/libp2p/multi-validator.rs"

[[example]]
name = "orchestrator-libp2p"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/libp2p/orchestrator.rs"

[[example]]
name = "all-libp2p"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/libp2p/all.rs"

# webserver
[[example]]
name = "webserver"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/webserver/webserver.rs"

[[example]]
name = "orchestrator-webserver"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/webserver/orchestrator.rs"

[[example]]
name = "validator-webserver"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/webserver/validator.rs"

[[example]]
name = "multi-validator-webserver"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/webserver/multi-validator.rs"

[[example]]
name = "multi-webserver"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/webserver/multi-webserver.rs"

[[example]]
name = "all-webserver"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/webserver/all.rs"

# combined
[[example]]
name = "all-combined"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/combined/all.rs"

[[example]]
name = "multi-validator-combined"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/combined/multi-validator.rs"

[[example]]
name = "validator-combined"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/combined/validator.rs"

[[example]]
name = "orchestrator-combined"
required-features = ["demo", "libp2p/rsa"]
required-features = ["libp2p/rsa"]
path = "examples/combined/orchestrator.rs"

[dependencies]
Expand Down Expand Up @@ -147,4 +140,5 @@ async-std = { workspace = true }
blake3 = { workspace = true }
clap = { version = "4.4", features = ["derive", "env"] }
serde_json = "1.0.108"
toml = { workspace = true }
toml = { workspace = true }
hotshot-testing = { path = "../testing" }
16 changes: 8 additions & 8 deletions crates/hotshot/examples/combined/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use async_compatibility_layer::art::async_spawn;
use async_compatibility_layer::channel::oneshot;
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot::demo::DemoTypes;
use hotshot_orchestrator::client::ValidatorArgs;
use hotshot_orchestrator::config::NetworkConfig;
use hotshot_testing::state_types::TestTypes;
use hotshot_types::traits::node_implementation::NodeType;
use std::net::{IpAddr, Ipv4Addr};
use std::sync::Arc;
Expand Down Expand Up @@ -45,7 +45,7 @@ async fn main() {

async_spawn(async move {
if let Err(e) = hotshot_web_server::run_web_server::<
<DemoTypes as hotshot_types::traits::node_implementation::NodeType>::SignatureKey,
<TestTypes as hotshot_types::traits::node_implementation::NodeType>::SignatureKey,
>(
Some(server_shutdown_cdn),
Url::parse("http://localhost:9000").unwrap(),
Expand All @@ -57,7 +57,7 @@ async fn main() {
});
async_spawn(async move {
if let Err(e) = hotshot_web_server::run_web_server::<
<DemoTypes as hotshot_types::traits::node_implementation::NodeType>::SignatureKey,
<TestTypes as hotshot_types::traits::node_implementation::NodeType>::SignatureKey,
>(
Some(server_shutdown_da),
Url::parse("http://localhost:9001").unwrap(),
Expand All @@ -70,7 +70,7 @@ async fn main() {

// orchestrator
async_spawn(run_orchestrator::<
DemoTypes,
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
Expand All @@ -84,14 +84,14 @@ async fn main() {

// nodes
let config: NetworkConfig<
<DemoTypes as NodeType>::SignatureKey,
<DemoTypes as NodeType>::ElectionConfigType,
> = load_config_from_file::<DemoTypes>(args.config_file);
<TestTypes as NodeType>::SignatureKey,
<TestTypes as NodeType>::ElectionConfigType,
> = load_config_from_file::<TestTypes>(args.config_file);
let mut nodes = Vec::new();
for _ in 0..config.config.total_nodes.into() {
let node = async_spawn(async move {
infra::main_entry_point::<
DemoTypes,
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
Expand Down
4 changes: 2 additions & 2 deletions crates/hotshot/examples/combined/multi-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use async_compatibility_layer::{
logging::{setup_backtrace, setup_logging},
};
use clap::Parser;
use hotshot::demo::DemoTypes;
use hotshot_orchestrator::client::ValidatorArgs;
use hotshot_testing::state_types::TestTypes;
use std::net::IpAddr;
use tracing::instrument;
use types::VIDNetwork;
Expand Down Expand Up @@ -50,7 +50,7 @@ async fn main() {

let node = async_spawn(async move {
infra::main_entry_point::<
DemoTypes,
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
Expand Down
4 changes: 2 additions & 2 deletions crates/hotshot/examples/combined/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod types;

use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot::demo::DemoTypes;
use hotshot_testing::state_types::TestTypes;
use tracing::instrument;
use types::VIDNetwork;

Expand All @@ -24,7 +24,7 @@ async fn main() {
setup_backtrace();
let args = OrchestratorArgs::parse();

run_orchestrator::<DemoTypes, DANetwork, QuorumNetwork, ViewSyncNetwork, VIDNetwork, NodeImpl>(
run_orchestrator::<TestTypes, DANetwork, QuorumNetwork, ViewSyncNetwork, VIDNetwork, NodeImpl>(
args,
)
.await;
Expand Down
24 changes: 11 additions & 13 deletions crates/hotshot/examples/combined/types.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
use crate::infra::CombinedDARun;
use hotshot::{
demo::DemoTypes,
traits::implementations::{CombinedCommChannel, MemoryStorage},
};
use hotshot::traits::implementations::{CombinedCommChannel, MemoryStorage};
use hotshot_testing::state_types::TestTypes;
use hotshot_types::traits::node_implementation::{ChannelMaps, NodeImplementation, NodeType};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

#[derive(Clone, Debug, Deserialize, Serialize, Hash, PartialEq, Eq)]
pub struct NodeImpl {}

pub type DANetwork = CombinedCommChannel<DemoTypes>;
pub type VIDNetwork = CombinedCommChannel<DemoTypes>;
pub type QuorumNetwork = CombinedCommChannel<DemoTypes>;
pub type ViewSyncNetwork = CombinedCommChannel<DemoTypes>;
pub type DANetwork = CombinedCommChannel<TestTypes>;
pub type VIDNetwork = CombinedCommChannel<TestTypes>;
pub type QuorumNetwork = CombinedCommChannel<TestTypes>;
pub type ViewSyncNetwork = CombinedCommChannel<TestTypes>;

impl NodeImplementation<DemoTypes> for NodeImpl {
type Storage = MemoryStorage<DemoTypes>;
impl NodeImplementation<TestTypes> for NodeImpl {
type Storage = MemoryStorage<TestTypes>;
type QuorumNetwork = QuorumNetwork;
type CommitteeNetwork = DANetwork;

fn new_channel_maps(
start_view: <DemoTypes as NodeType>::Time,
) -> (ChannelMaps<DemoTypes>, Option<ChannelMaps<DemoTypes>>) {
start_view: <TestTypes as NodeType>::Time,
) -> (ChannelMaps<TestTypes>, Option<ChannelMaps<TestTypes>>) {
(ChannelMaps::new(start_view), None)
}
}
pub type ThisRun = CombinedDARun<DemoTypes>;
pub type ThisRun = CombinedDARun<TestTypes>;
4 changes: 2 additions & 2 deletions crates/hotshot/examples/combined/validator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot::demo::DemoTypes;
use hotshot_testing::state_types::TestTypes;
use tracing::{info, instrument};
use types::VIDNetwork;

Expand Down Expand Up @@ -28,7 +28,7 @@ async fn main() {
args.url, args.port
);
infra::main_entry_point::<
DemoTypes,
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
Expand Down
31 changes: 15 additions & 16 deletions crates/hotshot/examples/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ use hotshot_orchestrator::{
config::{NetworkConfig, NetworkConfigFile, WebServerConfig},
};
use hotshot_task::task::FilterEvent;
use hotshot_types::block_impl::VIDBlockHeader;
use hotshot_testing::block_types::{TestBlockHeader, TestBlockPayload, TestTransaction};
use hotshot_types::message::Message;
use hotshot_types::traits::network::ConnectedNetwork;
use hotshot_types::ValidatorConfig;
use hotshot_types::{
block_impl::{VIDBlockPayload, VIDTransaction},
consensus::ConsensusMetricsValue,
data::{Leaf, TestableLeaf},
event::{Event, EventType},
Expand Down Expand Up @@ -291,7 +290,7 @@ pub trait RunDA<
> where
<TYPES as NodeType>::StateType: TestableState,
<TYPES as NodeType>::BlockPayload: TestableBlock,
TYPES: NodeType<Transaction = VIDTransaction>,
TYPES: NodeType<Transaction = TestTransaction>,
Leaf<TYPES>: TestableLeaf,
Self: Sync,
SystemContext<TYPES, NODE>: HotShotType<TYPES, NODE>,
Expand Down Expand Up @@ -372,7 +371,7 @@ pub trait RunDA<
async fn run_hotshot(
&self,
mut context: SystemContextHandle<TYPES, NODE>,
transactions: &mut Vec<VIDTransaction>,
transactions: &mut Vec<TestTransaction>,
transactions_to_send_per_round: u64,
) {
let NetworkConfig {
Expand Down Expand Up @@ -493,9 +492,9 @@ pub struct WebServerDARun<TYPES: NodeType> {
#[async_trait]
impl<
TYPES: NodeType<
Transaction = VIDTransaction,
BlockPayload = VIDBlockPayload,
BlockHeader = VIDBlockHeader,
Transaction = TestTransaction,
BlockPayload = TestBlockPayload,
BlockHeader = TestBlockHeader,
>,
NODE: NodeImplementation<
TYPES,
Expand Down Expand Up @@ -595,9 +594,9 @@ pub struct Libp2pDARun<TYPES: NodeType> {
#[async_trait]
impl<
TYPES: NodeType<
Transaction = VIDTransaction,
BlockPayload = VIDBlockPayload,
BlockHeader = VIDBlockHeader,
Transaction = TestTransaction,
BlockPayload = TestBlockPayload,
BlockHeader = TestBlockHeader,
>,
NODE: NodeImplementation<
TYPES,
Expand Down Expand Up @@ -688,9 +687,9 @@ pub struct CombinedDARun<TYPES: NodeType> {
#[async_trait]
impl<
TYPES: NodeType<
Transaction = VIDTransaction,
BlockPayload = VIDBlockPayload,
BlockHeader = VIDBlockHeader,
Transaction = TestTransaction,
BlockPayload = TestBlockPayload,
BlockHeader = TestBlockHeader,
>,
NODE: NodeImplementation<
TYPES,
Expand Down Expand Up @@ -799,9 +798,9 @@ where
/// Main entry point for validators
pub async fn main_entry_point<
TYPES: NodeType<
Transaction = VIDTransaction,
BlockPayload = VIDBlockPayload,
BlockHeader = VIDBlockHeader,
Transaction = TestTransaction,
BlockPayload = TestBlockPayload,
BlockHeader = TestBlockHeader,
>,
DACHANNEL: CommunicationChannel<TYPES> + Debug,
QUORUMCHANNEL: CommunicationChannel<TYPES> + Debug,
Expand Down
12 changes: 6 additions & 6 deletions crates/hotshot/examples/libp2p/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::types::ThisRun;
use async_compatibility_layer::art::async_spawn;
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot::demo::DemoTypes;
use hotshot_orchestrator::client::ValidatorArgs;
use hotshot_orchestrator::config::NetworkConfig;
use hotshot_testing::state_types::TestTypes;
use hotshot_types::traits::node_implementation::NodeType;
use std::net::{IpAddr, Ipv4Addr};
use surf_disco::Url;
Expand Down Expand Up @@ -37,7 +37,7 @@ async fn main() {

// orchestrator
async_spawn(run_orchestrator::<
DemoTypes,
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
Expand All @@ -51,14 +51,14 @@ async fn main() {

// nodes
let config: NetworkConfig<
<DemoTypes as NodeType>::SignatureKey,
<DemoTypes as NodeType>::ElectionConfigType,
> = load_config_from_file::<DemoTypes>(args.config_file);
<TestTypes as NodeType>::SignatureKey,
<TestTypes as NodeType>::ElectionConfigType,
> = load_config_from_file::<TestTypes>(args.config_file);
let mut nodes = Vec::new();
for _ in 0..config.config.total_nodes.into() {
let node = async_spawn(async move {
infra::main_entry_point::<
DemoTypes,
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
Expand Down
Loading
Loading