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 out Halt abstractions #1953

Merged
merged 21 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fe6c3eb
Combined construction of signing data with transaction construction.
murisi Sep 19, 2023
16425d5
Created builders and constructors for each type of transaction.
murisi Sep 20, 2023
d10ba96
Allow the prototypical Tx builder to be modified in NamadaImpl instan…
murisi Sep 25, 2023
e471b6c
Moved FsShieldedUtils into the SDK behind a feature flag.
murisi Sep 27, 2023
1142e64
Adding saving and loading function to Wallet.
murisi Sep 28, 2023
f99eaa3
Made the ShieldedUtils trait similar to the WalletStorage trait.
murisi Oct 1, 2023
79f006a
Added function to construct DenominatedAmounts from Amounts.
murisi Oct 1, 2023
c775ec7
Removed unnecessary requirement for mutable references in Namada trait.
murisi Oct 1, 2023
9f06a4b
Enabled parallel usage of the Namada trait using read and write locks.
murisi Oct 1, 2023
b1bc845
Reintegrated generic IO support.
murisi Oct 4, 2023
615ebc8
SDK can now query for the native token address from the network. Also…
murisi Oct 9, 2023
17c3e6c
Separated an SDK crate out of the shared crate.
murisi Oct 11, 2023
f892ab4
Changes to enable better usage of the SDK in the absence of wallet or…
murisi Oct 12, 2023
94b2d4b
Added a change log entry.
murisi Oct 12, 2023
0c006ec
Add new SDK errors
sug0 Sep 26, 2023
027a920
Phase out Halt and its cousins from the SDK
sug0 Sep 26, 2023
cff47a2
Remove halt abstraction from the SDK
sug0 Sep 27, 2023
e986bcf
Apply suggestions from code review
sug0 Sep 29, 2023
1831e8e
Internal macros SDK module
sug0 Oct 9, 2023
f338ae3
Echo SDK errors to stdout
sug0 Oct 9, 2023
af1fa0e
Changelog for #1953
sug0 Sep 28, 2023
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/SDK/1953-phase-out-try-halt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Phase out Halt abstractions
([\#1953](https://github.com/anoma/namada/pull/1953))
2 changes: 2 additions & 0 deletions .changelog/unreleased/SDK/1963-sdk-refactor-rebased.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improved the usability of the SDK and moved it to separate crate.
([\#1963](https://github.com/anoma/namada/pull/1963))
52 changes: 52 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"macros",
"vp_prelude",
"encoding_spec",
"sdk",
]

# wasm packages have to be built separately
Expand Down
3 changes: 2 additions & 1 deletion apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mainnet = [
"namada/mainnet",
]
dev = ["namada/dev"]
std = ["ed25519-consensus/std", "rand/std", "rand_core/std", "namada/std"]
std = ["ed25519-consensus/std", "rand/std", "rand_core/std", "namada/std", "namada_sdk/std"]
# for integration tests and test utilies
testing = ["dev"]

Expand All @@ -67,6 +67,7 @@ abciplus = [

[dependencies]
namada = {path = "../shared", features = ["ferveo-tpke", "masp-tx-gen", "multicore", "http-client"]}
namada_sdk = {path = "../sdk", default-features = false, features = ["wasm-runtime", "masp-tx-gen"]}
ark-serialize.workspace = true
ark-std.workspace = true
arse-merkle-tree = { workspace = true, features = ["blake2b"] }
Expand Down
3 changes: 2 additions & 1 deletion apps/src/bin/namada-client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ async fn main() -> Result<()> {
let _log_guard = logging::init_from_env_or(LevelFilter::INFO)?;

// run the CLI
CliApi::<CliIo>::handle_client_command::<HttpClient>(
CliApi::handle_client_command::<HttpClient, _>(
None,
cli::namada_client_cli()?,
&CliIo,
)
.await
}
2 changes: 1 addition & 1 deletion apps/src/bin/namada-relayer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ async fn main() -> Result<()> {

let cmd = cli::namada_relayer_cli()?;
// run the CLI
CliApi::<CliIo>::handle_relayer_command::<HttpClient>(None, cmd).await
CliApi::handle_relayer_command::<HttpClient>(None, cmd, &CliIo).await
}
2 changes: 1 addition & 1 deletion apps/src/bin/namada-wallet/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ pub fn main() -> Result<()> {
color_eyre::install()?;
let (cmd, ctx) = cli::namada_wallet_cli()?;
// run the CLI
CliApi::<CliIo>::handle_wallet_command(cmd, ctx)
CliApi::handle_wallet_command(cmd, ctx, &CliIo)
}
11 changes: 6 additions & 5 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod wallet;

use clap::{ArgGroup, ArgMatches, ColorChoice};
use color_eyre::eyre::Result;
use namada::types::io::DefaultIo;
use namada::types::io::StdIo;
use utils::*;
pub use utils::{safe_exit, Cmd};

Expand Down Expand Up @@ -2517,7 +2517,6 @@ pub mod args {
use std::str::FromStr;

use namada::ibc::core::ics24_host::identifier::{ChannelId, PortId};
pub use namada::sdk::args::*;
use namada::types::address::Address;
use namada::types::chain::{ChainId, ChainIdPrefix};
use namada::types::dec::Dec;
Expand All @@ -2530,10 +2529,12 @@ pub mod args {
use namada::types::token;
use namada::types::token::NATIVE_MAX_DECIMAL_PLACES;
use namada::types::transaction::GasLimit;
pub use namada_sdk::args::*;

use super::context::*;
use super::utils::*;
use super::{ArgGroup, ArgMatches};
use crate::cli::context::FromContext;
use crate::config::{self, Action, ActionAtHeight};
use crate::facade::tendermint::Timeout;
use crate::facade::tendermint_config::net::Address as TendermintAddress;
Expand Down Expand Up @@ -3525,8 +3526,8 @@ pub mod args {
target,
token,
amount,
native_token: (),
tx_code_path,
native_token: (),
}
}

Expand Down Expand Up @@ -3881,8 +3882,8 @@ pub mod args {
validator,
amount,
source,
native_token: (),
tx_code_path,
native_token: (),
}
}

Expand Down Expand Up @@ -5799,7 +5800,7 @@ pub fn namada_relayer_cli() -> Result<NamadaRelayer> {
cmds::EthBridgePool::WithContext(sub_cmd),
) => {
let global_args = args::Global::parse(&matches);
let context = Context::new::<DefaultIo>(global_args)?;
let context = Context::new::<StdIo>(global_args)?;
Ok(NamadaRelayer::EthBridgePoolWithCtx(Box::new((
sub_cmd, context,
))))
Expand Down
22 changes: 13 additions & 9 deletions apps/src/lib/cli/api.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::marker::PhantomData;

use namada::sdk::queries::Client;
use namada::sdk::rpc::wait_until_node_is_synched;
use namada::tendermint_rpc::HttpClient;
use namada::types::control_flow::Halt;
use namada::types::io::Io;
use namada_sdk::error::Error;
use namada_sdk::queries::Client;
use namada_sdk::rpc::wait_until_node_is_synched;
use tendermint_config::net::Address as TendermintAddress;

use crate::client::utils;
Expand All @@ -13,7 +11,10 @@ use crate::client::utils;
#[async_trait::async_trait(?Send)]
pub trait CliClient: Client + Sync {
fn from_tendermint_address(address: &mut TendermintAddress) -> Self;
async fn wait_until_node_is_synced<IO: Io>(&self) -> Halt<()>;
async fn wait_until_node_is_synced(
&self,
io: &impl Io,
) -> Result<(), Error>;
}

#[async_trait::async_trait(?Send)]
Expand All @@ -22,8 +23,11 @@ impl CliClient for HttpClient {
HttpClient::new(utils::take_config_address(address)).unwrap()
}

async fn wait_until_node_is_synced<IO: Io>(&self) -> Halt<()> {
wait_until_node_is_synched::<_, IO>(self).await
async fn wait_until_node_is_synced(
&self,
io: &impl Io,
) -> Result<(), Error> {
wait_until_node_is_synched(self, io).await
}
}

Expand All @@ -32,4 +36,4 @@ pub struct CliIo;
#[async_trait::async_trait(?Send)]
impl Io for CliIo {}

pub struct CliApi<IO: Io = CliIo>(PhantomData<IO>);
pub struct CliApi;
Loading
Loading