Skip to content

Commit

Permalink
Merge remote-tracking branch 'namada/yuji/opt_tx_index' (#1278) into …
Browse files Browse the repository at this point in the history
…maint-0.15

* namada/yuji/opt_tx_index:
  add changelog
  fix for abcipp
  toggle to enable tx index
  • Loading branch information
juped committed Apr 19, 2023
2 parents 47f44f0 + 4f46ddf commit fb2e9cb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/1278-opt_tx_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Disable Tendermint tx_index as default
([#1278](https://github.com/anoma/namada/issues/1278))
3 changes: 2 additions & 1 deletion apps/src/bin/namada-node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pub fn main() -> Result<()> {
cmds::NamadaNode::Ledger(sub) => match sub {
cmds::Ledger::Run(cmds::LedgerRun(args)) => {
let wasm_dir = ctx.wasm_dir();
sleep_until(args.0);
sleep_until(args.start_time);
ctx.config.ledger.tendermint.tx_index = args.tx_index;
ledger::run(ctx.config.ledger, wasm_dir);
}
cmds::Ledger::RunUntil(cmds::LedgerRunUntil(args)) => {
Expand Down
24 changes: 20 additions & 4 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,10 @@ pub mod cmds {
.or(rollback)
.or(run_until)
// The `run` command is the default if no sub-command given
.or(Some(Self::Run(LedgerRun(args::LedgerRun(None)))))
.or(Some(Self::Run(LedgerRun(args::LedgerRun {
start_time: None,
tx_index: false,
}))))
})
}

Expand Down Expand Up @@ -1732,6 +1735,7 @@ pub mod args {
const STORAGE_KEY: Arg<storage::Key> = arg("storage-key");
const SUB_PREFIX: ArgOpt<String> = arg_opt("sub-prefix");
const SUSPEND_ACTION: ArgFlag = flag("suspend");
const TENDERMINT_TX_INDEX: ArgFlag = flag("tx-index");
const TIMEOUT_HEIGHT: ArgOpt<u64> = arg_opt("timeout-height");
const TIMEOUT_SEC_OFFSET: ArgOpt<u64> = arg_opt("timeout-sec-offset");
const TOKEN_OPT: ArgOpt<WalletAddress> = TOKEN.opt();
Expand Down Expand Up @@ -1802,12 +1806,19 @@ pub mod args {
}

#[derive(Clone, Debug)]
pub struct LedgerRun(pub Option<DateTimeUtc>);
pub struct LedgerRun {
pub start_time: Option<DateTimeUtc>,
pub tx_index: bool,
}

impl Args for LedgerRun {
fn parse(matches: &ArgMatches) -> Self {
let time = NAMADA_START_TIME.parse(matches);
Self(time)
let start_time = NAMADA_START_TIME.parse(matches);
let tx_index = TENDERMINT_TX_INDEX.parse(matches);
Self {
start_time,
tx_index,
}
}

fn def(app: App) -> App {
Expand All @@ -1819,6 +1830,11 @@ pub mod args {
equivalent:\n2023-01-20T12:12:12Z\n2023-01-20 \
12:12:12Z\n2023- 01-20T12: 12:12Z",
))
.arg(
TENDERMINT_TX_INDEX
.def()
.about("Enable Tendermint tx indexing."),
)
}
}

Expand Down
3 changes: 3 additions & 0 deletions apps/src/lib/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ pub struct Tendermint {
pub instrumentation_prometheus: bool,
pub instrumentation_prometheus_listen_addr: SocketAddr,
pub instrumentation_namespace: String,
/// Toggle to enable tx indexing
pub tx_index: bool,
}

impl Ledger {
Expand Down Expand Up @@ -189,6 +191,7 @@ impl Ledger {
26661,
),
instrumentation_namespace: "namadan_tm".to_string(),
tx_index: false,
},
}
}
Expand Down
11 changes: 10 additions & 1 deletion apps/src/lib/node/ledger/tendermint_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::config;
use crate::facade::tendermint::{block, Genesis};
use crate::facade::tendermint_config::net::Address as TendermintAddress;
use crate::facade::tendermint_config::{
Error as TendermintError, TendermintConfig,
Error as TendermintError, TendermintConfig, TxIndexConfig, TxIndexer,
};

/// Env. var to output Tendermint log to stdout
Expand Down Expand Up @@ -396,6 +396,15 @@ async fn update_tendermint_config(
tendermint_config.consensus_timeout_commit;
}

let indexer = if tendermint_config.tx_index {
TxIndexer::Kv
} else {
TxIndexer::Null
};
#[cfg(feature = "abcipp")]
let indexer = [indexer];
config.tx_index = TxIndexConfig { indexer };

let mut file = OpenOptions::new()
.write(true)
.truncate(true)
Expand Down
18 changes: 14 additions & 4 deletions tests/src/e2e/ibc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,22 @@ fn run_ledger_ibc() -> Result<()> {
let (test_a, test_b) = setup::two_single_node_nets()?;

// Run Chain A
let mut ledger_a =
run_as!(test_a, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?;
let mut ledger_a = run_as!(
test_a,
Who::Validator(0),
Bin::Node,
&["ledger", "run", "--tx-index"],
Some(40)
)?;
ledger_a.exp_string("Namada ledger node started")?;
// Run Chain B
let mut ledger_b =
run_as!(test_b, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?;
let mut ledger_b = run_as!(
test_b,
Who::Validator(0),
Bin::Node,
&["ledger", "run", "--tx-index"],
Some(40)
)?;
ledger_b.exp_string("Namada ledger node started")?;
ledger_a.exp_string("This node is a validator")?;
ledger_b.exp_string("This node is a validator")?;
Expand Down

0 comments on commit fb2e9cb

Please sign in to comment.