Skip to content

Commit

Permalink
Merge branch 'tomas/split-up-node' (#3265)
Browse files Browse the repository at this point in the history
* tomas/split-up-node:
  changelog: add #3265
  post node split-up fixes
  `mv crates/node/src/mod.rs crates/node/src/lib.rs`
  `rm crates/node/src/lib.rs`
  `mv crates/apps_lib/src/bench_utils.rs crates/node/src/`
  `mv crates/node/src/tendermint_node.rs crates/apps_lib/src/`
  `mv crates/node/src/ledger/* crates/node/src/`
  `mv crates/node/src/mod.rs crates/node/src/lib.rs`
  `mv crates/apps_lib/src/node crates/node/src`
  node: add a new crate for node lib crate
  • Loading branch information
tzemanovic committed May 21, 2024
2 parents d91b142 + f18adaa commit 40e40c3
Show file tree
Hide file tree
Showing 67 changed files with 757 additions and 562 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/3265-split-up-node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Separated the node library code from other apps lib code into a new crate
`namada_node`. ([\#3265](https://github.com/anoma/namada/pull/3265))
100 changes: 64 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ members = [
"crates/parameters",
"crates/proof_of_stake",
"crates/replay_protection",
"crates/sdk",
"crates/namada",
"crates/node",
"crates/sdk",
"crates/shielded_token",
"crates/state",
"crates/storage",
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ crates += namada_merkle_tree
crates += namada_parameters
crates += namada_proof_of_stake
crates += namada_replay_protection
crates += namada_node
crates += namada_sdk
crates += namada_shielded_token
crates += namada_state
Expand Down
5 changes: 3 additions & 2 deletions crates/apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ path = "src/bin/namada-relayer/main.rs"
[features]
default = ["namada/mainnet", "migrations"]
mainnet = ["namada_apps_lib/mainnet"]
jemalloc = ["namada_apps_lib/jemalloc"]
jemalloc = ["namada_node/jemalloc"]
migrations = ["namada/migrations", "namada_apps_lib/migrations"]
namada-eth-bridge = ["namada_apps_lib/namada-eth-bridge"]

[dependencies]
namada = {path = "../namada"}
namada_apps_lib = {path = "../apps_lib"}
namada_node = {path = "../node"}

color-eyre.workspace = true
eyre.workspace = true
Expand All @@ -71,7 +72,7 @@ winapi.workspace = true
namada = {path = "../namada", default-features = false, features = ["testing", "wasm-runtime"]}
namada_test_utils = {path = "../test_utils"}

assert_matches = "1.5.0"
assert_matches.workspace = true
bit-set.workspace = true
proptest.workspace = true
test-log.workspace = true
Expand Down
24 changes: 15 additions & 9 deletions crates/apps/src/bin/namada-node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use eyre::{Context, Result};
use namada::core::time::{DateTimeUtc, Utc};
use namada_apps_lib::cli::cmds::TestGenesis;
use namada_apps_lib::cli::{self, cmds};
use namada_apps_lib::config::{Action, ActionAtHeight, ValidatorLocalConfig};
use namada_apps_lib::node::ledger;
use namada_node as node;
#[cfg(not(feature = "migrations"))]
use namada_sdk::display_line;

Expand All @@ -16,28 +17,28 @@ pub fn main() -> Result<()> {
let chain_ctx = ctx.take_chain_or_exit();
let wasm_dir = chain_ctx.wasm_dir();
sleep_until(args.start_time);
ledger::run(chain_ctx.config.ledger, wasm_dir);
node::run(chain_ctx.config.ledger, wasm_dir);
}
cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => {
let mut chain_ctx = ctx.take_chain_or_exit();
let wasm_dir = chain_ctx.wasm_dir();
sleep_until(args.time);
chain_ctx.config.ledger.shell.action_at_height =
Some(args.action_at_height);
ledger::run(chain_ctx.config.ledger, wasm_dir);
node::run(chain_ctx.config.ledger, wasm_dir);
}
cmds::Ledger::Reset(_) => {
let chain_ctx = ctx.take_chain_or_exit();
ledger::reset(chain_ctx.config.ledger)
node::reset(chain_ctx.config.ledger)
.wrap_err("Failed to reset Namada node")?;
}
cmds::Ledger::DumpDb(cmds::LedgerDumpDb(args)) => {
let chain_ctx = ctx.take_chain_or_exit();
ledger::dump_db(chain_ctx.config.ledger, args);
node::dump_db(chain_ctx.config.ledger, args);
}
cmds::Ledger::RollBack(_) => {
let chain_ctx = ctx.take_chain_or_exit();
ledger::rollback(chain_ctx.config.ledger)
node::rollback(chain_ctx.config.ledger)
.wrap_err("Failed to rollback the Namada node")?;
}
cmds::Ledger::UpdateDB(cmds::LedgerUpdateDB(args)) => {
Expand All @@ -50,7 +51,7 @@ pub fn main() -> Result<()> {
}
let mut chain_ctx = ctx.take_chain_or_exit();
#[cfg(feature = "migrations")]
ledger::update_db_keys(
node::update_db_keys(
chain_ctx.config.ledger.clone(),
args.updates,
args.dry_run,
Expand All @@ -68,7 +69,7 @@ pub fn main() -> Result<()> {
);
// don't stop on panics
let handle = std::thread::spawn(|| {
ledger::run(chain_ctx.config.ledger, wasm_dir)
node::run(chain_ctx.config.ledger, wasm_dir)
});
_ = handle.join();
std::env::remove_var("NAMADA_INITIAL_HEIGHT");
Expand All @@ -84,7 +85,7 @@ pub fn main() -> Result<()> {
}
let chain_ctx = ctx.take_chain_or_exit();
#[cfg(feature = "migrations")]
ledger::query_db(
node::query_db(
chain_ctx.config.ledger,
&args.key,
&args.hash,
Expand Down Expand Up @@ -129,6 +130,11 @@ pub fn main() -> Result<()> {
std::fs::write(config_path, updated_config).unwrap();
}
},
cmds::NamadaNode::Utils(sub) => match sub {
cmds::NodeUtils::TestGenesis(TestGenesis(args)) => {
node::utils::test_genesis(args)
}
},
}
Ok(())
}
Expand Down
Loading

0 comments on commit 40e40c3

Please sign in to comment.