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

Fee Upgrade #1530

Merged
merged 58 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c067572
add ResolvableChainConfig to ValidatedState
imabdulbasit May 28, 2024
cfd2662
get_chain_config
imabdulbasit May 28, 2024
9515679
Merge branch 'main' into abdul/move-chain-config
imabdulbasit May 28, 2024
6242d27
chain config route
imabdulbasit May 28, 2024
3c5f368
Merge remote-tracking branch 'origin/main' into abdul/move-chain-config
imabdulbasit May 28, 2024
870858c
Merge branch 'main' into abdul/move-chain-config
imabdulbasit May 28, 2024
e9bde5a
add test
imabdulbasit May 28, 2024
1f8d73f
clippy
imabdulbasit May 29, 2024
e49ec5c
Merge branch 'main' into abdul/move-chain-config
imabdulbasit May 29, 2024
581ac67
Merge remote-tracking branch 'origin/main' into abdul/move-chain-config
imabdulbasit May 30, 2024
3568098
point hotshot to main and others to daily-build
imabdulbasit May 30, 2024
0b6bd2b
pass simple builder config
imabdulbasit May 30, 2024
48ce9bd
merge abdul/move-chain-config, hotshot ss/fee-upgrade others abdul/up…
imabdulbasit May 30, 2024
8f5df88
make clippy happy
imabdulbasit May 30, 2024
f8c817b
Merge branch 'abdul/move-chain-config' into abdul/fee-upgrade
imabdulbasit May 30, 2024
b924031
update lockfile to point to specific hotshot commit
imabdulbasit May 30, 2024
05629c1
update builder-core
imabdulbasit May 30, 2024
f0cf3ef
Merge remote-tracking branch 'origin/abdul/move-chain-config' into ab…
imabdulbasit May 30, 2024
434969b
arc SystemContextHandle
imabdulbasit May 30, 2024
375e34a
add upgrades to Genesis and Nodestate
imabdulbasit Jun 3, 2024
727a7cd
use fee_contract address from updated chain_config
imabdulbasit Jun 3, 2024
cc80ce3
rename upgrade block field to view
imabdulbasit Jun 3, 2024
c88dcea
Chain config persistence
imabdulbasit Jun 4, 2024
510da55
fix: use instance chain config for genesis validated_state
imabdulbasit Jun 4, 2024
5cd07e9
test for chain config catchup
imabdulbasit Jun 4, 2024
3b15b05
remove version from NodeState
imabdulbasit Jun 4, 2024
32eeb8e
move proposal.chain_config and state chainconfig check below upgrade
imabdulbasit Jun 5, 2024
8079e64
move current version back to NodeState
imabdulbasit Jun 5, 2024
f2d92d5
get upgrade for current_version
imabdulbasit Jun 5, 2024
1b53a5a
Merge remote-tracking branch 'origin/main' into abdul/fee-upgrade
imabdulbasit Jun 5, 2024
81c8292
update lockfile
imabdulbasit Jun 5, 2024
59a337c
add test for chain config upgrade
imabdulbasit Jun 5, 2024
366f91c
Merge remote-tracking branch 'origin/main' into abdul/fee-upgrade
imabdulbasit Jun 5, 2024
4ab7e3c
pass None for builder port
imabdulbasit Jun 5, 2024
f186c45
merge main
imabdulbasit Jun 5, 2024
353a80d
fix test
imabdulbasit Jun 6, 2024
af27263
update migration version to V31 and cleanup
imabdulbasit Jun 6, 2024
d9366a0
apply_upgrade() and get_chain_config()
imabdulbasit Jun 7, 2024
b585bac
update only if chain config is different
imabdulbasit Jun 7, 2024
c54d166
return early
imabdulbasit Jun 7, 2024
625d4c4
Merge remote-tracking branch 'origin/main' into abdul/fee-upgrade
imabdulbasit Jun 13, 2024
9b3952a
use Base::instance()
imabdulbasit Jun 13, 2024
ef2e491
add propose_window, commit and revert in caller, remove header cf com…
imabdulbasit Jun 13, 2024
c3625aa
lint
imabdulbasit Jun 13, 2024
17d9277
lint
imabdulbasit Jun 13, 2024
56bbcfc
fix migrations version and use propose_window
imabdulbasit Jun 14, 2024
1f49651
fix: enforce_max_block_size test
imabdulbasit Jun 14, 2024
7f976ff
change TestConfig nodes to 5
imabdulbasit Jun 14, 2024
03b4e3c
set propose window to 10
imabdulbasit Jun 14, 2024
119f60a
use transaction()
imabdulbasit Jun 14, 2024
4d16988
remove header cf commit check
imabdulbasit Jun 14, 2024
e9fbe2d
update hotshot and cdn
imabdulbasit Jun 14, 2024
1ac5cf2
Update CDN in `ab/fee-upgrade` (#1606)
rob-maron Jun 14, 2024
f6b1d6c
cargo sort
imabdulbasit Jun 14, 2024
98ad78b
add commit check back
imabdulbasit Jun 14, 2024
257727b
`try_cast`
rob-maron Jun 14, 2024
8d9d7a7
clippy
rob-maron Jun 14, 2024
57e9cfb
bump
jparr721 Jun 14, 2024
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
446 changes: 346 additions & 100 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ dotenvy = "0.15"
ethers = { version = "2.0", features = ["solc"] }
futures = "0.3"

hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.57" }
hotshot = { git = "https://github.com/EspressoSystems/hotshot", branch = "main" }
# Hotshot imports
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.57" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.27" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.27" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.57" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.39" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.57" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "main" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", branch = "daily-build" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", branch = "main" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", branch = "main" }
hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.57" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.57" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.57" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", branch = "main" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", branch = "main" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "main" }
hotshot-contract-adapter = { version = "0.1.0", path = "contracts/rust/adapter" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "daily-build" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", branch = "daily-build" }

# Push CDN imports
cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [
Expand Down Expand Up @@ -115,6 +115,7 @@ serde = { version = "1.0.195", features = ["derive"] }
toml = "0.8"
url = "2.3"
vbs = "0.1"
vec1 = "1.12"
vergen = { version = "8.3", features = ["git", "gitcl"] }
zeroize = "1.7"
committable = "0.2"
Expand Down
1 change: 1 addition & 0 deletions builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tide-disco = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
vbs = { workspace = true }
vec1 = { workspace = true }

[dev-dependencies]
sequencer = { path = "../sequencer", features = ["testing"] }
5 changes: 3 additions & 2 deletions builder/src/bin/permissionless-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,27 @@ async fn main() -> anyhow::Result<()> {
)
.unwrap();

let validated_state = ValidatedState::genesis(&instance_state).0;

let api_response_timeout_duration = opt.max_api_timeout_duration;

// make the txn timeout as 1/4 of the api_response_timeout_duration
let txn_timeout_duration = api_response_timeout_duration / 4;

let buffer_view_num_count = opt.buffer_view_num_count;
let validated_state = ValidatedState::genesis(&instance_state).0;

let _builder_config = BuilderConfig::init(
builder_key_pair,
bootstrapped_view,
opt.channel_capacity,
opt.node_count,
instance_state,
validated_state,
opt.hotshot_event_streaming_url,
builder_server_url,
api_response_timeout_duration,
buffer_view_num_count,
txn_timeout_duration,
validated_state,
)
.await;

Expand Down
50 changes: 26 additions & 24 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ use hotshot_orchestrator::{
};
use hotshot_types::{
consensus::ConsensusMetricsValue,
constants::{Version01, STATIC_VER_0_1},
constants::Base,
event::Event,
light_client::StateKeyPair,
signature_key::{BLSPrivKey, BLSPubKey},
traits::election::Membership,
traits::metrics::Metrics,
traits::{election::Membership, metrics::Metrics},
HotShotConfig, PeerConfig, ValidatorConfig,
};
use std::fmt::Display;
Expand Down Expand Up @@ -68,20 +67,18 @@ pub mod permissioned;
// It runs the api service for the builder
pub fn run_builder_api_service(url: Url, source: ProxyGlobalState<SeqTypes>) {
// it is to serve hotshot
let builder_api = hotshot_builder_api::builder::define_api::<
ProxyGlobalState<SeqTypes>,
SeqTypes,
Version01,
>(&HotshotBuilderApiOptions::default())
.expect("Failed to construct the builder APIs");
let builder_api =
hotshot_builder_api::builder::define_api::<ProxyGlobalState<SeqTypes>, SeqTypes, Base>(
&HotshotBuilderApiOptions::default(),
)
.expect("Failed to construct the builder APIs");

// it enables external clients to submit txn to the builder's private mempool
let private_mempool_api = hotshot_builder_api::builder::submit_api::<
ProxyGlobalState<SeqTypes>,
SeqTypes,
Version01,
>(&HotshotBuilderApiOptions::default())
.expect("Failed to construct the builder API for private mempool txns");
let private_mempool_api =
hotshot_builder_api::builder::submit_api::<ProxyGlobalState<SeqTypes>, SeqTypes, Base>(
&HotshotBuilderApiOptions::default(),
)
.expect("Failed to construct the builder API for private mempool txns");

let mut app: App<ProxyGlobalState<SeqTypes>, BuilderApiError> = App::with_state(source);

Expand All @@ -91,7 +88,7 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState<SeqTypes>) {
app.register_module("txn_submit", private_mempool_api)
.expect("Failed to register the private mempool API");

async_spawn(app.serve(url, STATIC_VER_0_1));
async_spawn(app.serve(url, Base::instance()));
}

#[cfg(test)]
Expand Down Expand Up @@ -121,6 +118,7 @@ pub mod testing {
ExecutionType, HotShotConfig, PeerConfig, ValidatorConfig,
};
use portpicker::pick_unused_port;
use vbs::version::StaticVersion;
//use sequencer::persistence::NoStorage;
use async_broadcast::{
broadcast, Receiver as BroadcastReceiver, RecvError, Sender as BroadcastSender,
Expand Down Expand Up @@ -160,7 +158,6 @@ pub mod testing {
events::{Error as EventStreamApiError, Options as EventStreamingApiOptions},
events_source::{EventConsumer, EventsStreamer},
};
use hotshot_types::constants::{Version01, STATIC_VER_0_1};
use serde::{Deserialize, Serialize};
use snafu::{guide::feature_flags, *};

Expand All @@ -172,7 +169,7 @@ pub mod testing {
staking_nodes_state_key_pairs: Vec<StateKeyPair>,
non_staking_nodes_state_key_pairs: Vec<StateKeyPair>,
non_staking_nodes_stake_entries: Vec<PeerConfig<hotshot_state_prover::QCVerKey>>,
master_map: Arc<MasterMap<Message<SeqTypes>, PubKey>>,
master_map: Arc<MasterMap<PubKey>>,
anvil: Arc<AnvilInstance>,
}

Expand Down Expand Up @@ -220,12 +217,16 @@ pub mod testing {
data_request_delay: Duration::from_millis(200),
view_sync_timeout: Duration::from_secs(5),
fixed_leader_for_gpuvid: 0,
builder_url,
builder_urls: vec1::vec1![builder_url],
builder_timeout: Duration::from_secs(1),
start_threshold: (
known_nodes_with_stake.clone().len() as u64,
known_nodes_with_stake.clone().len() as u64,
),
start_proposing_view: 0,
stop_proposing_view: 0,
start_voting_view: 0,
stop_voting_view: 0,
};

Self {
Expand Down Expand Up @@ -436,7 +437,7 @@ pub mod testing {
let hotshot_events_api = hotshot_events_service::events::define_api::<
Arc<RwLock<EventsStreamer<SeqTypes>>>,
SeqTypes,
Version01,
Base,
>(&EventStreamingApiOptions::default())
.expect("Failed to define hotshot eventsAPI");

Expand All @@ -445,7 +446,7 @@ pub mod testing {
app.register_module("hotshot-events", hotshot_events_api)
.expect("Failed to register hotshot events API");

async_spawn(app.serve(url, STATIC_VER_0_1));
async_spawn(app.serve(url, Base::instance()));
}
// enable hotshot event streaming
pub fn enable_hotshot_node_event_streaming<P: SequencerPersistence>(
Expand Down Expand Up @@ -555,12 +556,12 @@ pub mod testing {
channel_capacity,
node_count,
node_state,
ValidatedState::default(),
hotshot_events_streaming_api_url,
hotshot_builder_api_url,
Duration::from_millis(2000),
15,
Duration::from_millis(500),
ValidatedState::default(),
)
.await
.unwrap();
Expand Down Expand Up @@ -620,11 +621,11 @@ pub mod testing {
bootstrapped_view,
channel_capacity,
node_state,
ValidatedState::default(),
hotshot_builder_api_url,
Duration::from_millis(2000),
15,
Duration::from_millis(500),
ValidatedState::default(),
)
.await
.unwrap();
Expand Down Expand Up @@ -703,10 +704,11 @@ mod test {
}

let genesis_state = NodeState::mock();
let validated_state = ValidatedState::default();
let mut parent = {
// TODO refactor repeated code from other tests
let (genesis_payload, genesis_ns_table) =
Payload::from_transactions([], &ValidatedState::default(), &genesis_state)
Payload::from_transactions([], &validated_state, &genesis_state)
.await
.expect("unable to create genesis payload");
let builder_commitment = genesis_payload.builder_commitment(&genesis_ns_table);
Expand Down
20 changes: 8 additions & 12 deletions builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use hotshot_builder_core::{
};

use hotshot_types::{
constants::{Version01, STATIC_VER_0_1},
data::{fake_commitment, Leaf, ViewNumber},
traits::{
block_contents::{vid_commitment, GENESIS_VID_NUM_STORAGE_NODES},
Expand Down Expand Up @@ -82,12 +81,12 @@ impl BuilderConfig {
channel_capacity: NonZeroUsize,
node_count: NonZeroUsize,
instance_state: NodeState,
validated_state: ValidatedState,
hotshot_events_api_url: Url,
hotshot_builder_apis_url: Url,
max_api_timeout_duration: Duration,
buffered_view_num_count: usize,
maximize_txns_count_timeout_duration: Duration,
validated_state: ValidatedState,
) -> anyhow::Result<Self> {
tracing::info!(
address = %builder_key_pair.fee_account(),
Expand Down Expand Up @@ -161,8 +160,7 @@ impl BuilderConfig {
.base_fee
.as_u64()
.context("the base fee exceeds the maximum amount that a builder can pay (defined by u64::MAX)")?,
Arc::new(instance_state),
Duration::from_secs(60),
Arc::new(instance_state), Duration::from_secs(60),
Arc::new(validated_state),
);

Expand Down Expand Up @@ -232,12 +230,10 @@ mod test {
events::{Error as EventStreamApiError, Options as EventStreamingApiOptions},
events_source::{BuilderEvent, EventConsumer, EventsStreamer},
};
use hotshot_types::{
constants::{Version01, STATIC_VER_0_1},
traits::{
block_contents::{BlockPayload, GENESIS_VID_NUM_STORAGE_NODES},
node_implementation::NodeType,
},
use hotshot_types::constants::Base;
use hotshot_types::traits::{
block_contents::{BlockPayload, GENESIS_VID_NUM_STORAGE_NODES},
node_implementation::NodeType,
};
use hotshot_types::{signature_key::BLSPubKey, traits::signature_key::SignatureKey};
use sequencer::{
Expand Down Expand Up @@ -294,7 +290,7 @@ mod test {
);

// builder api url
let hotshot_builder_api_url = hotshot_config.config.builder_url.clone();
let hotshot_builder_api_url = hotshot_config.config.builder_urls[0].clone();

let builder_config = NonPermissionedBuilderTestConfig::init_non_permissioned_builder(
&hotshot_config,
Expand All @@ -306,7 +302,7 @@ mod test {
let builder_pub_key = builder_config.fee_account;

// Start a builder api client
let builder_client = Client::<hotshot_builder_api::builder::Error, Version01>::new(
let builder_client = Client::<hotshot_builder_api::builder::Error, Base>::new(
hotshot_builder_api_url.clone(),
);
assert!(builder_client.connect(Some(Duration::from_secs(60))).await);
Expand Down
18 changes: 11 additions & 7 deletions builder/src/permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ use tide_disco::{app, method::ReadState, App, Url};
use vbs::version::StaticVersionType;

use hotshot_types::{
constants::{Version01, STATIC_VER_0_1},
data::{fake_commitment, Leaf, ViewNumber},
traits::{
block_contents::{vid_commitment, GENESIS_VID_NUM_STORAGE_NODES},
Expand Down Expand Up @@ -259,7 +258,10 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
// crash horribly just because we're not using the P2P network yet.
let _ = NetworkingMetricsValue::new(metrics);

let mut genesis_state = ValidatedState::default();
let mut genesis_state = ValidatedState {
chain_config: genesis.chain_config.into(),
..Default::default()
};
for (address, amount) in genesis.accounts {
tracing::warn!(%address, %amount, "Prefunding account for demo");
genesis_state.prefund_account(address, amount);
Expand All @@ -282,6 +284,8 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
l1_genesis,
peers: Arc::new(StatePeers::<Ver>::from_urls(network_params.state_peers)),
node_id: node_index,
upgrades: Default::default(),
current_version: Ver::VERSION,
};

let stake_table_commit =
Expand Down Expand Up @@ -309,11 +313,11 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
bootstrapped_view,
channel_capacity,
instance_state,
genesis_state,
hotshot_builder_api_url,
max_api_timeout_duration,
buffered_view_num_count,
maximize_txns_count_timeout_duration,
genesis_state,
)
.await?;

Expand Down Expand Up @@ -407,11 +411,11 @@ impl<N: network::Type, P: SequencerPersistence, Ver: StaticVersionType + 'static
bootstrapped_view: ViewNumber,
channel_capacity: NonZeroUsize,
instance_state: NodeState,
validated_state: ValidatedState,
hotshot_builder_api_url: Url,
max_api_timeout_duration: Duration,
buffered_view_num_count: usize,
maximize_txns_count_timeout_duration: Duration,
validated_state: ValidatedState,
) -> anyhow::Result<Self> {
// tx channel
let (tx_sender, tx_receiver) = broadcast::<MessageType<SeqTypes>>(channel_capacity.get());
Expand Down Expand Up @@ -557,8 +561,8 @@ mod test {
events::{Error as EventStreamApiError, Options as EventStreamingApiOptions},
events_source::{BuilderEvent, EventConsumer, EventsStreamer},
};
use hotshot_types::constants::Base;
use hotshot_types::{
constants::{Version01, STATIC_VER_0_1},
signature_key::BLSPubKey,
traits::{
block_contents::{BlockPayload, GENESIS_VID_NUM_STORAGE_NODES},
Expand Down Expand Up @@ -600,7 +604,7 @@ mod test {
let state_signer = handles[node_id].1.take().unwrap();

// builder api url
let hotshot_builder_api_url = hotshot_config.config.builder_url.clone();
let hotshot_builder_api_url = hotshot_config.config.builder_urls[0].clone();
let builder_config = PermissionedBuilderTestConfig::init_permissioned_builder(
hotshot_config,
hotshot_context_handle,
Expand All @@ -613,7 +617,7 @@ mod test {
let builder_pub_key = builder_config.fee_account;

// Start a builder api client
let builder_client = Client::<hotshot_builder_api::builder::Error, Version01>::new(
let builder_client = Client::<hotshot_builder_api::builder::Error, Base>::new(
hotshot_builder_api_url.clone(),
);
assert!(builder_client.connect(Some(Duration::from_secs(60))).await);
Expand Down
13 changes: 13 additions & 0 deletions data/genesis/demo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@ fee_contract = '0xa15bb66138824a1c7167f5e85b957d04dd34e468'

[header]
timestamp = "1970-01-01T00:00:00Z"

[[upgrade]]
version = "0.2"
view = 5
propose_window = 100


[upgrade.chain_config]
jbearer marked this conversation as resolved.
Show resolved Hide resolved
chain_id = 999999999
base_fee = '2 wei'
max_block_size = '1mb'
fee_recipient = '0x0000000000000000000000000000000000000000'
fee_contract = '0xa15bb66138824a1c7167f5e85b957d04dd34e468'
Loading
Loading