Skip to content

Commit

Permalink
Merge branch 'main' into jh/dev-node-debug-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJeremyHe authored Jul 15, 2024
2 parents bdc793c + b9f54ce commit bd065bc
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 127 deletions.
5 changes: 2 additions & 3 deletions data/genesis/demo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ timestamp = "1970-01-01T00:00:00Z"

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

start_proposing_view = 5
stop_proposing_view = 15

[upgrade.chain_config]
chain_id = 999999999
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- The generated columns for header merkle roots were originally created by extracting fields
-- `block_merkle_tree_root` and `fee_merkle_tree_root` from the header JSON. Post 0.1, though, the
-- header serialization changed so that these fields are now nested one level deeper:
-- `fields.block_merkle_tree_root` and `fields.fee_merkle_tree_root`. This migration alters the
-- generated column expression to use NULL coalescing to extract the value from either of these
-- paths depending on which version of the header we have.
--
-- Pre 17.x (we target Postgres >= 16.x), there is not explicit instruction for changing the
-- expression of a generated column, so the best we can do is drop and re-add the column with a
-- different expression.

ALTER TABLE header
DROP column block_merkle_tree_root,
ADD column block_merkle_tree_root text
GENERATED ALWAYS AS (coalesce(data->'fields'->>'block_merkle_tree_root', data->>'block_merkle_tree_root')) STORED NOT NULL,
DROP column fee_merkle_tree_root,
ADD column fee_merkle_tree_root text
GENERATED ALWAYS AS (coalesce(data->'fields'->>'fee_merkle_tree_root', data->>'fee_merkle_tree_root')) STORED NOT NULL;
53 changes: 22 additions & 31 deletions sequencer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl<N: ConnectedNetwork<PubKey>, Ver: StaticVersionType + 'static, P: Sequencer

#[cfg(any(test, feature = "testing"))]
pub mod test_helpers {
use std::{collections::BTreeMap, time::Duration};
use std::time::Duration;

use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use async_std::task::sleep;
Expand All @@ -360,7 +360,7 @@ pub mod test_helpers {
use espresso_types::{
mock::MockStateCatchup,
v0::traits::{PersistenceOptions, StateCatchup},
NamespaceId, Upgrade, ValidatedState,
NamespaceId, ValidatedState,
};
use ethers::{prelude::Address, utils::Anvil};
use futures::{
Expand All @@ -378,7 +378,6 @@ pub mod test_helpers {
use portpicker::pick_unused_port;
use surf_disco::Client;
use tide_disco::error::ServerError;
use vbs::version::Version;

use super::*;
use crate::{
Expand Down Expand Up @@ -503,15 +502,6 @@ pub mod test_helpers {
}
}

#[derive(Clone, Debug)]
pub struct TestNetworkUpgrades {
pub upgrades: BTreeMap<Version, Upgrade>,
pub start_proposing_view: u64,
pub stop_proposing_view: u64,
pub start_voting_view: u64,
pub stop_voting_view: u64,
}

impl<P: PersistenceOptions, const NUM_NODES: usize> TestNetwork<P, { NUM_NODES }> {
pub async fn new<C: StateCatchup + 'static>(
cfg: TestNetworkConfig<{ NUM_NODES }, P, C>,
Expand All @@ -529,7 +519,7 @@ pub mod test_helpers {
.map(|(i, (state, persistence, catchup))| {
let opt = cfg.api_config.clone();
let cfg = &cfg.network_config;
let upgrades_map = cfg.upgrades().map(|e| e.upgrades).unwrap_or_default();
let upgrades_map = cfg.upgrades();
async move {
if i == 0 {
opt.serve(
Expand Down Expand Up @@ -1049,7 +1039,9 @@ mod test {
use committable::{Commitment, Committable};
use es_version::{SequencerVersion, SEQUENCER_VERSION};
use espresso_types::{
mock::MockStateCatchup, FeeAccount, FeeAmount, Header, Upgrade, UpgradeType, ValidatedState,
mock::MockStateCatchup,
v0_1::{UpgradeMode, ViewBasedUpgrade},
FeeAccount, FeeAmount, Header, Upgrade, UpgradeType, ValidatedState,
};
use ethers::utils::Anvil;
use futures::{
Expand All @@ -1063,14 +1055,17 @@ mod test {
};
use hotshot_types::{
event::LeafInfo,
traits::{metrics::NoMetrics, node_implementation::ConsensusTime},
traits::{
metrics::NoMetrics,
node_implementation::{ConsensusTime, NodeType},
},
};
use jf_merkle_tree::prelude::{MerkleProof, Sha3Node};
use portpicker::pick_unused_port;
use surf_disco::Client;
use test_helpers::{
catchup_test_helper, state_signature_test_helper, status_test_helper, submit_test_helper,
TestNetwork, TestNetworkConfigBuilder, TestNetworkUpgrades,
TestNetwork, TestNetworkConfigBuilder,
};
use tide_disco::{app::AppHealth, error::ServerError, healthcheck::HealthStatus};
use vbs::version::Version;
Expand Down Expand Up @@ -1446,28 +1441,24 @@ mod test {
base_fee: 1.into(),
..Default::default()
};
let mut map = std::collections::BTreeMap::new();
let start_proposing_view = 5;
let propose_window = 10;
map.insert(
Version { major: 0, minor: 2 },
let mut upgrades = std::collections::BTreeMap::new();

upgrades.insert(
<SeqTypes as NodeType>::Upgrade::VERSION,
Upgrade {
start_proposing_view,
propose_window,
mode: UpgradeMode::View(ViewBasedUpgrade {
start_voting_view: None,
stop_voting_view: None,
start_proposing_view: 1,
stop_proposing_view: 10,
}),
upgrade_type: UpgradeType::ChainConfig {
chain_config: chain_config_upgrade,
},
},
);

let stop_voting_view = 100;
let upgrades = TestNetworkUpgrades {
upgrades: map,
start_proposing_view,
stop_proposing_view: start_proposing_view + propose_window,
start_voting_view: 1,
stop_voting_view,
};
let stop_voting_view = u64::MAX;

const NUM_NODES: usize = 5;
let config = TestNetworkConfigBuilder::<NUM_NODES, _, _>::with_num_nodes()
Expand Down
Loading

0 comments on commit bd065bc

Please sign in to comment.