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

Phase 2 of Shielded Sync refactor #3456

Merged
merged 27 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d870d13
Implement phase 1 of shielded sync
sug0 Jul 10, 2024
0c72585
Implement a gnarly cross-platform logging iterator
sug0 Jul 15, 2024
dafa150
Document origin of obfuscated/opaque masp tx
sug0 Jul 15, 2024
6a18bc1
Changelog for #3498
sug0 Jul 10, 2024
9f06576
Define capabilities for masp rpc clients
sug0 Jun 19, 2024
b8fb3a6
Use `BlockHeight` instead of `u64` in fetch args
sug0 Jun 19, 2024
cf880a4
Always retry from the latest synced height during ss
sug0 Jun 19, 2024
4f96416
Emit spin loop hint on masp txs receiver
sug0 Jun 20, 2024
09cf887
Add new fetch methods to masp client trait
sug0 Jun 21, 2024
3dd6a6f
Make masp client caps a default method
sug0 Jun 21, 2024
2b8aef4
Disable building ledger masp client on wasm targets
sug0 Jun 21, 2024
d34bc82
Update `reqwest`
sug0 Jun 21, 2024
9d57867
Remove batch size arg
sug0 Jun 21, 2024
a40a04b
Decouple ledger rpc client from masp client
sug0 Jun 21, 2024
07b0cae
Implement a masp client backed by the `namada-masp-indexer`
sug0 Jun 21, 2024
bc0d6cf
Optionally trigger witness map update
sug0 Jun 25, 2024
efdc4b7
Advance peek iterator at the top of loop
sug0 Jun 25, 2024
6fe7618
Integrate indexer client with the CLI
sug0 Jun 26, 2024
5e60723
Fetch masp pre-built data during shielded sync
sug0 Jun 26, 2024
36f646c
Misc indexer client fixes
sug0 Jun 26, 2024
5e27e94
Inline caps in masp client
sug0 Jun 26, 2024
4e0fa10
Fetch indexed txs in batches of the max req thres
sug0 Jun 26, 2024
761e27c
More misc masp indexer client fixes
sug0 Jun 27, 2024
ead0ef4
Deserialize server err response from masp indexer client
sug0 Jul 3, 2024
4df4304
Remove default methods from masp client trait
sug0 Jul 15, 2024
6f83f9f
Remove `ThenAwait` abstraction
sug0 Jul 15, 2024
185cf27
Changelog for #3456
sug0 Jul 10, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Implements phase 1 of Issue [\#3385](https://github.com/anoma/namada/issues/3385)
- When fetching notes, connections and related failures should not halt shielded sync. Instead, the process
should be restarted
- If fetching is interrupted, the data fetched should be persisted locally so that progress isn't lost.
- A trait for fetching behavior should be added to provide modularity

([\#3498](https://github.com/anoma/namada/pull/3498))
4 changes: 4 additions & 0 deletions .changelog/unreleased/improvements/3456-masp-ss-phase-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Implement the phase 2 masp shielded sync client. This client uses
a [`namada-masp-indexer`](https://github.com/anoma/namada-masp-
indexer) instance to query the state of the shielded context.
([\#3456](https://github.com/anoma/namada/pull/3456))
28 changes: 26 additions & 2 deletions Cargo.lock

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

19 changes: 10 additions & 9 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3213,8 +3213,6 @@ pub mod args {
Err(_) => config::get_default_namada_folder(),
}),
);
pub const BATCH_SIZE_OPT: ArgDefault<u64> =
arg_default("batch-size", DefaultFn(|| 1));
pub const BLOCK_HEIGHT: Arg<BlockHeight> = arg("block-height");
pub const BLOCK_HEIGHT_OPT: ArgOpt<BlockHeight> = arg_opt("height");
pub const BLOCK_HEIGHT_FROM_OPT: ArgOpt<BlockHeight> =
Expand Down Expand Up @@ -3468,6 +3466,7 @@ pub mod args {
pub const WASM_CHECKSUMS_PATH: Arg<PathBuf> = arg("wasm-checksums-path");
pub const WASM_DIR: ArgOpt<PathBuf> = arg_opt("wasm-dir");
pub const WEBSITE_OPT: ArgOpt<String> = arg_opt("website");
pub const WITH_INDEXER: ArgOpt<String> = arg_opt("with-indexer");
pub const TX_PATH: Arg<PathBuf> = arg("tx-path");
pub const TX_PATH_OPT: ArgOpt<PathBuf> = TX_PATH.opt();

Expand Down Expand Up @@ -6575,27 +6574,23 @@ pub mod args {
impl Args for ShieldedSync<CliTypes> {
fn parse(matches: &ArgMatches) -> Self {
let ledger_address = CONFIG_RPC_LEDGER_ADDRESS.parse(matches);
let batch_size = BATCH_SIZE_OPT.parse(matches);
let start_query_height = BLOCK_HEIGHT_FROM_OPT.parse(matches);
let last_query_height = BLOCK_HEIGHT_TO_OPT.parse(matches);
let spending_keys = SPENDING_KEYS.parse(matches);
let viewing_keys = VIEWING_KEYS.parse(matches);
let with_indexer = WITH_INDEXER.parse(matches);
Self {
ledger_address,
batch_size,
start_query_height,
last_query_height,
spending_keys,
viewing_keys,
with_indexer,
}
}

fn def(app: App) -> App {
app.arg(CONFIG_RPC_LEDGER_ADDRESS.def().help(LEDGER_ADDRESS_ABOUT))
.arg(BATCH_SIZE_OPT.def().help(wrap!(
"Optional batch size which determines how many txs to \
fetch before caching locally. Default is 1."
)))
.arg(BLOCK_HEIGHT_TO_OPT.def().help(wrap!(
"Option block height to sync up to. Default is latest."
)))
Expand All @@ -6612,6 +6607,11 @@ pub mod args {
"List of new viewing keys with which to check note \
ownership. These will be added to the shielded context."
)))
.arg(WITH_INDEXER.def().help(wrap!(
"Address of a `namada-masp-indexer` live instance. If \
present, the shielded sync will be performed using data \
retrieved from the given indexer."
)))
}
}

Expand All @@ -6626,7 +6626,6 @@ pub mod args {

Ok(ShieldedSync {
ledger_address: chain_ctx.get(&self.ledger_address),
batch_size: self.batch_size,
start_query_height: self.start_query_height,
last_query_height: self.last_query_height,
spending_keys: self
Expand All @@ -6639,6 +6638,7 @@ pub mod args {
.iter()
.map(|vk| chain_ctx.get_cached(vk))
.collect(),
with_indexer: self.with_indexer.map(|_| ()),
})
}
}
Expand Down Expand Up @@ -6962,6 +6962,7 @@ pub mod args {
type Data = PathBuf;
type EthereumAddress = String;
type Keypair = WalletKeypair;
type MaspIndexerAddress = String;
type PaymentAddress = WalletPaymentAddr;
type PublicKey = WalletPublicKey;
type SpendingKey = WalletSpendingKey;
Expand Down
11 changes: 7 additions & 4 deletions crates/apps_lib/src/cli/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::cli::cmds::*;
use crate::client::{rpc, tx, utils};

impl CliApi {
pub async fn handle_client_command<C, IO: Io>(
pub async fn handle_client_command<C, IO: Io + Send + Sync>(
client: Option<C>,
cmd: cli::NamadaClient,
io: IO,
Expand Down Expand Up @@ -336,13 +336,16 @@ impl CliApi {
tx::submit_validator_metadata_change(&namada, args)
.await?;
}
Sub::ShieldedSync(ShieldedSync(args)) => {
Sub::ShieldedSync(ShieldedSync(mut args)) => {
let indexer_addr = args.with_indexer.take();
let args = args.to_sdk(&mut ctx)?;
let chain_ctx = ctx.take_chain_or_exit();
let client = client.unwrap_or_else(|| {
C::from_tendermint_address(&args.ledger_address)
});
client.wait_until_node_is_synced(&io).await?;
if indexer_addr.is_none() {
client.wait_until_node_is_synced(&io).await?;
}
let vks = chain_ctx
.wallet
.get_viewing_keys()
Expand All @@ -361,8 +364,8 @@ impl CliApi {
crate::client::masp::syncing(
chain_ctx.shielded,
&client,
indexer_addr.as_ref().map(|s| s.as_ref()),
&io,
args.batch_size,
args.start_query_height,
args.last_query_height,
&sks,
Expand Down
Loading
Loading