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

Aleks/wallet atomic #2831

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
76dab9f
Wallet store atomic update; atomic versions of validator data getters
karbyshev Mar 5, 2024
7595c6d
Atomic version of `extend_from_pregenesis`
karbyshev Mar 6, 2024
d345549
Fix comment
karbyshev Mar 6, 2024
d7e3287
Atomic versions of `get_addresses_with_vp_type`, `add_vp_type_to_addr…
karbyshev Mar 6, 2024
f25632d
Atomic version of `find_address`
karbyshev Mar 6, 2024
c0719aa
Make store error clonable
karbyshev Mar 6, 2024
bcfe595
Atomic versions of `find_address`, `find_alias`
karbyshev Mar 6, 2024
ba46390
Fix atomic version of `tokens_with_aliases`
karbyshev Mar 6, 2024
047cc59
Atomic version of `find_viewing_key`
karbyshev Mar 6, 2024
a6e6b18
Atomic version of `find_payment_addr`
karbyshev Mar 6, 2024
d0cd76e
Atomic version of `find_alias_by_payment_addr`
karbyshev Mar 6, 2024
cb32539
Make StoredKeypair and EncryptedKeypair clonable
karbyshev Mar 6, 2024
3189746
Atomic version of `get_secret_keys`
karbyshev Mar 6, 2024
4b703dd
Atomic version of `git_public_keys`
karbyshev Mar 6, 2024
bd0cb46
Atomic version of `get_addresses`
karbyshev Mar 6, 2024
fbb9336
Fix message
karbyshev Mar 6, 2024
44b7f04
Atomic version of `get_payment_addrs`
karbyshev Mar 7, 2024
c1ce9f3
Atomic version of `get_viewing_keys`
karbyshev Mar 7, 2024
ea028a3
Atomic version of `get_spending_keys`
karbyshev Mar 7, 2024
9335bae
Atomic version of `is_encrypted_secret_key`
karbyshev Mar 7, 2024
ba115f2
Atomic version of `is_encrypted_spending_key`
karbyshev Mar 7, 2024
c930e48
Clean
karbyshev Mar 7, 2024
c831635
Atomic version of `find_path_by_pkh`
karbyshev Mar 7, 2024
b170417
Atomic version of `find_public_key_by_pkh`
karbyshev Mar 7, 2024
10d4db9
Atomic `find_key_by_pk`, `find_key_by_pkh`
karbyshev Mar 7, 2024
72f0ca0
Atomic version of `find_public_key`
karbyshev Mar 7, 2024
5217ce2
Atomic version of `find_secret_key`
karbyshev Mar 7, 2024
07a00b8
Atomic version of `find_spending_key`
karbyshev Mar 7, 2024
e429460
Atomic version of `insert_address`
karbyshev Mar 7, 2024
2509ac7
Atomic version of `insert_keypair`
karbyshev Mar 7, 2024
08d4eb4
Clean
karbyshev Mar 7, 2024
6dc71d4
Atomic version of `insert_public_key`
karbyshev Mar 7, 2024
827d203
Atomic version of `insert_viewing_key`
karbyshev Mar 7, 2024
fe44233
Minor fix
karbyshev Mar 7, 2024
0602ba7
Atomic version of `insert_spending_key`
karbyshev Mar 7, 2024
b16cd22
Atomic version of `insert_payment_addr`
karbyshev Mar 7, 2024
c35b681
Atomic version of `extend`
karbyshev Mar 7, 2024
7b319ed
Atomic version of `remove_all_by_alias`
karbyshev Mar 7, 2024
c57d445
Atomic `derive_store_secret_key_from_mnemonic_code`
karbyshev Mar 7, 2024
9d519fd
Atomic `derive_store_spending_key_from_mnemonic_code`
karbyshev Mar 7, 2024
a3f6e2c
Atomic `gen_store_secret_key`
karbyshev Mar 7, 2024
fa487b9
Atomic `gen_store_spending_key`
karbyshev Mar 7, 2024
695bd39
Clean
karbyshev Mar 8, 2024
44cdf52
Remove partial_application crate
karbyshev Mar 8, 2024
e23c38d
Refactor `derive_hd_seed`
karbyshev Mar 8, 2024
1869be0
Atomic `derive_store_hd_secret_key`
karbyshev Mar 8, 2024
f66063e
Refactor `derive_store_secret_key_from_mnemonic_code`
karbyshev Mar 8, 2024
414ddff
Refactor
karbyshev Mar 8, 2024
9cdc7ef
Atomic `derive_store_hd_spendind_key`
karbyshev Mar 8, 2024
70ded5f
Refactor `derive_store_hd_spending_key_from_mnemonic_code`
karbyshev Mar 8, 2024
440ab11
Atomic `gen_disposable_signing_key`
karbyshev Mar 8, 2024
1ee25e5
Clean
karbyshev Mar 8, 2024
56b94be
Remove redundant mut modifiers
karbyshev Mar 15, 2024
b35d955
Atomic `lookup_ibc_token_alias`
karbyshev Apr 22, 2024
115ba71
Formatting
karbyshev Apr 22, 2024
c799c7b
Make Store clonable
karbyshev Apr 25, 2024
978197d
Add wallet in-memory store
karbyshev Apr 25, 2024
e806aa0
Add in-memory store loader
karbyshev Apr 25, 2024
06ad240
Add dry run mode setters
karbyshev Apr 25, 2024
b16a38a
Add wallet store util functions
karbyshev Apr 25, 2024
694206a
Remove `take_validator_data`
karbyshev Apr 25, 2024
fe91624
Use new dry-run wallet mode
karbyshev Apr 25, 2024
5a110d3
Use proper update store function
karbyshev Apr 25, 2024
1d70c18
Enable atomic wallet for change consensus key
karbyshev Apr 26, 2024
b5cb953
Adapt change-consensus-key for atomic wallet
karbyshev Apr 26, 2024
ecf3cf4
Remove old "save" calls
karbyshev Apr 26, 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
39 changes: 24 additions & 15 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,18 +953,24 @@ impl Default for BenchShieldedCtx {
let mut chain_ctx = ctx.take_chain_or_exit();

// Generate spending key for Albert and Bertha
chain_ctx.wallet.gen_store_spending_key(
ALBERT_SPENDING_KEY.to_string(),
None,
true,
&mut OsRng,
);
chain_ctx.wallet.gen_store_spending_key(
BERTHA_SPENDING_KEY.to_string(),
None,
true,
&mut OsRng,
);
chain_ctx
.wallet
.gen_store_spending_key_atomic(
ALBERT_SPENDING_KEY.to_string(),
None,
true,
&mut OsRng,
)
.expect("Failed to update the wallet storage.");
chain_ctx
.wallet
.gen_store_spending_key_atomic(
BERTHA_SPENDING_KEY.to_string(),
None,
true,
&mut OsRng,
)
.expect("Failed to update the wallet storage.");
crate::wallet::save(&chain_ctx.wallet).unwrap();

// Generate payment addresses for both Albert and Bertha
Expand All @@ -977,7 +983,8 @@ impl Default for BenchShieldedCtx {
let viewing_key: FromContext<ExtendedViewingKey> = FromContext::new(
chain_ctx
.wallet
.find_viewing_key(viewing_alias)
.find_viewing_key_atomic(viewing_alias)
.expect("Failed to read from the wallet storage.")
.unwrap()
.to_string(),
);
Expand All @@ -991,11 +998,12 @@ impl Default for BenchShieldedCtx {
let payment_addr = viewing_key.to_payment_address(div).unwrap();
let _ = chain_ctx
.wallet
.insert_payment_addr(
.insert_payment_addr_atomic(
alias,
PaymentAddress::from(payment_addr).pinned(false),
true,
)
.expect("Failed to update the wallet storage.")
.unwrap();
}

Expand All @@ -1020,7 +1028,8 @@ impl BenchShieldedCtx {
let async_runtime = tokio::runtime::Runtime::new().unwrap();
let spending_key = self
.wallet
.find_spending_key(ALBERT_SPENDING_KEY, None)
.find_spending_key_atomic(ALBERT_SPENDING_KEY, None)
.expect("Failed to read from the wallet storage.")
.unwrap();
self.shielded = async_runtime
.block_on(crate::client::masp::syncing(
Expand Down
26 changes: 13 additions & 13 deletions crates/apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4295,7 +4295,7 @@ pub mod args {
impl CliToSdk<TxInitAccount<SdkTypes>> for TxInitAccount<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> TxInitAccount<SdkTypes> {
let tx = self.tx.to_sdk(ctx);
let chain_ctx = ctx.borrow_mut_chain_or_exit();
let chain_ctx = ctx.borrow_chain_or_exit();
TxInitAccount::<SdkTypes> {
tx,
vp_code_path: self.vp_code_path,
Expand Down Expand Up @@ -4350,7 +4350,7 @@ pub mod args {
impl CliToSdk<TxBecomeValidator<SdkTypes>> for TxBecomeValidator<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> TxBecomeValidator<SdkTypes> {
let tx = self.tx.to_sdk(ctx);
let chain_ctx = ctx.borrow_mut_chain_or_exit();
let chain_ctx = ctx.borrow_chain_or_exit();
TxBecomeValidator::<SdkTypes> {
tx,
scheme: self.scheme,
Expand Down Expand Up @@ -4470,7 +4470,7 @@ pub mod args {
impl CliToSdk<TxInitValidator<SdkTypes>> for TxInitValidator<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> TxInitValidator<SdkTypes> {
let tx = self.tx.to_sdk(ctx);
let chain_ctx = ctx.borrow_mut_chain_or_exit();
let chain_ctx = ctx.borrow_chain_or_exit();
TxInitValidator::<SdkTypes> {
tx,
scheme: self.scheme,
Expand Down Expand Up @@ -4619,7 +4619,7 @@ pub mod args {
impl CliToSdk<TxUpdateAccount<SdkTypes>> for TxUpdateAccount<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> TxUpdateAccount<SdkTypes> {
let tx = self.tx.to_sdk(ctx);
let chain_ctx = ctx.borrow_mut_chain_or_exit();
let chain_ctx = ctx.borrow_chain_or_exit();
TxUpdateAccount::<SdkTypes> {
tx,
vp_code_path: self.vp_code_path,
Expand Down Expand Up @@ -5021,7 +5021,7 @@ pub mod args {
impl CliToSdk<RevealPk<SdkTypes>> for RevealPk<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> RevealPk<SdkTypes> {
let tx = self.tx.to_sdk(ctx);
let chain_ctx = ctx.borrow_mut_chain_or_exit();
let chain_ctx = ctx.borrow_chain_or_exit();
RevealPk::<SdkTypes> {
tx,
public_key: chain_ctx.get(&self.public_key),
Expand Down Expand Up @@ -5588,7 +5588,7 @@ pub mod args {
impl CliToSdk<ConsensusKeyChange<SdkTypes>> for ConsensusKeyChange<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> ConsensusKeyChange<SdkTypes> {
let tx = self.tx.to_sdk(ctx);
let chain_ctx = ctx.borrow_mut_chain_or_exit();
let chain_ctx = ctx.borrow_chain_or_exit();
ConsensusKeyChange::<SdkTypes> {
tx,
validator: chain_ctx.get(&self.validator),
Expand Down Expand Up @@ -6412,7 +6412,7 @@ pub mod args {

impl CliToSdk<Query<SdkTypes>> for Query<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> Query<SdkTypes> {
let chain_ctx = ctx.borrow_mut_chain_or_exit();
let chain_ctx = ctx.borrow_chain_or_exit();
Query::<SdkTypes> {
ledger_address: chain_ctx.get(&self.ledger_address),
}
Expand Down Expand Up @@ -6467,9 +6467,9 @@ pub mod args {

use crate::wallet::CliWalletUtils;

let find_viewing_key = |w: &mut Wallet<CliWalletUtils>| {
w.find_viewing_key(&self.viewing_key.raw)
.copied()
let find_viewing_key = |w: &Wallet<CliWalletUtils>| {
w.find_viewing_key_atomic(&self.viewing_key.raw)
.expect("Failed to read from the wallet storage.")
.unwrap_or_else(|_| {
eprintln!(
"Unknown viewing key {}",
Expand All @@ -6481,10 +6481,10 @@ pub mod args {
let viewing_key = if ctx.global_args.is_pre_genesis {
let wallet_path =
ctx.global_args.base_dir.join(PRE_GENESIS_DIR);
let mut wallet = crate::wallet::load_or_new(&wallet_path);
find_viewing_key(&mut wallet)
let wallet = crate::wallet::load_or_new(&wallet_path);
find_viewing_key(&wallet)
} else {
find_viewing_key(&mut ctx.borrow_mut_chain_or_exit().wallet)
find_viewing_key(&ctx.borrow_chain_or_exit().wallet)
};
PayAddressGen::<SdkTypes> {
alias: self.alias,
Expand Down
Loading
Loading