-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat(core): multi-pubkey DB support #2093
base: dev
Are you sure you want to change the base?
Changes from 1 commit
aa0909f
f051600
c8a434e
3e0061f
c6146d0
eff374c
fef8a4e
6247766
fa0f5ab
947ab8d
ae95d4e
c0d13e7
71c4e9c
be3dc81
ffbc262
07c1168
1ec96bc
3ccfa00
29763e2
cf749eb
368441c
7095605
8823be2
42a22b1
23f0566
65a07d2
71ae0b1
61c49bb
d184c1e
bd114fc
f58c80a
a99c8a6
5298f2b
d9d8e53
1538f81
c0355fa
a27ec3e
3407835
c27206c
ca13b41
3f053bd
f0e8016
f5e5245
f8d08cf
2d96232
d2152f8
04d2896
879438b
234a2aa
e2dacfc
a00c2c7
04e1d97
f904927
ea778d2
8fa9cec
86649f5
0699843
3480e26
b9375e0
4c3a61c
12537c0
77b43f5
fbe1fe2
795f718
42f5db0
88754f7
cc3a02f
ee8d9d0
acd6383
4d04128
e508b59
d7c4a83
3a7fa66
4e7ae81
69d9886
8796922
875c9df
4f7824d
4bba3fb
637286d
7cd60f8
b03a0aa
98cb993
061d1ff
398b93b
e2877a8
577e18b
9eaeb2e
9882ccc
8a2f4a7
4594ff6
9ff52de
49b9260
6db0236
f970a12
094a659
92b94ac
6d51390
a4c27b9
1c08ef5
a6d0b51
35b102a
474d641
0686d0e
ca440df
719862b
8921e4a
6d6169f
6954d62
79e7c89
20a4486
7a2ebaf
fdb4f55
6c93752
db397e5
393e825
6e515ae
22319bc
b036c62
9dcb662
0ac682d
c409ecc
23bb803
8281609
115a873
9062bee
b370bec
46f8712
5bde012
e036383
fab32e2
789ce8d
ac5cc96
d8caebd
76efdf3
24774a4
6a0d0b6
fbfe747
097a63e
8a6d0cd
f685f72
df3cf1e
c028061
309a5ac
3cfd616
0b5275c
a53bd38
ff42791
4b99dba
2d427d9
b516435
497a006
df10264
d32f8f6
966607d
19930d3
527efbc
bb41f41
916ce6a
0f7c075
bf12b01
41b61c1
54714eb
7699f55
e9ef701
1b3931b
4962351
f449cdd
a4ac369
99e6ca6
a94c791
33ba505
8a01341
b19d2ba
f35f371
0856b54
9a1f89d
5fdee3e
9a8494e
7c12cce
0b4d808
90f89b7
8f19481
e643ab3
a78704d
bdd79af
7e3d3a6
5470b25
d57e394
b690e93
1675a53
5e02fa4
5f72e83
a0cf3cb
0c817e8
34f9d27
79f3792
117aa44
2f3086c
c6b3648
06ce83b
eb9d74a
5cbfd89
cea464b
07a478c
342fab8
07177cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -742,7 +742,9 @@ pub(crate) async fn build_address_and_priv_key_policy( | |
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
{ | ||
let pubkey = dhash160(activated_key.public().as_bytes()).to_string(); | ||
// Skip the first byte of the uncompressed public key before converting to the eth address. | ||
let pubkey = Public::from_slice(&activated_key.public().as_bytes()[1..]); | ||
let pubkey = public_to_address(&pubkey).to_string(); | ||
run_db_migration_for_new_pubkey(ctx, pubkey) | ||
.await | ||
.map_to_mm(EthActivationV2Error::InternalError)?; | ||
|
@@ -1013,10 +1015,11 @@ pub(super) async fn eth_shared_db_id(coin: &EthCoin, ctx: &MmArc) -> Option<Stri | |
|
||
pub(super) async fn eth_account_db_id(coin: &EthCoin) -> Option<String> { | ||
match coin.derivation_method() { | ||
DerivationMethod::HDWallet(hd_wallet) => hd_wallet | ||
.get_enabled_address() | ||
.await | ||
.map(|addr| dhash160(addr.pubkey().as_bytes()).to_string()), | ||
DerivationMethod::HDWallet(hd_wallet) => hd_wallet.get_enabled_address().await.map(|addr| { | ||
// Skip the first byte of the uncompressed public key before converting to the eth address. | ||
let pubkey = Public::from_slice(&addr.pubkey().as_bytes()[1..]); | ||
public_to_address(&pubkey).to_string() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think the below would be much simpler than what you implemented let address = display_eth_address(&addr.address());
address.trim_start_matches("0x").to_string() |
||
}), | ||
_ => None, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -460,21 +460,21 @@ async fn init_db_migration_watcher_loop(ctx: MmArc) { | |||||
let mut migrations = HashSet::new(); | ||||||
let mut receiver = ctx | ||||||
.init_db_migration_watcher() | ||||||
.expect("db_m igration_watcher initialization failed"); | ||||||
.expect("db_migration_watcher initialization failed"); | ||||||
|
||||||
while let Some(db_id) = receiver.next().await { | ||||||
if migrations.contains(&db_id) { | ||||||
debug!("{} migrated, skipping migration..", db_id); | ||||||
continue; | ||||||
} | ||||||
|
||||||
// run db migration for db_id if new activated pubkey is unique. | ||||||
// run db migration for new db_id. | ||||||
if let Err(err) = run_db_migration_impl(&ctx, Some(&db_id), None).await { | ||||||
error!("{err:?}"); | ||||||
continue; | ||||||
}; | ||||||
|
||||||
// insert new db_id to migration list | ||||||
// insert new db_id to migrated list | ||||||
migrations.insert(db_id.to_owned()); | ||||||
|
||||||
// Fetch and extend ctx.coins_needed_for_kick_start from new intialized db. | ||||||
|
@@ -500,6 +500,15 @@ async fn run_db_migration_impl(ctx: &MmArc, db_id: Option<&str>, shared_db_id: O | |||||
} | ||||||
|
||||||
pub async fn lp_init_continue(ctx: MmArc) -> MmInitResult<()> { | ||||||
#[cfg(not(target_arch = "wasm32"))] | ||||||
{ | ||||||
let dbdir = ctx.dbdir(None); | ||||||
fs::create_dir_all(&dbdir).map_to_mm(|e| MmInitError::ErrorCreatingDbDir { | ||||||
path: dbdir.clone(), | ||||||
error: e.to_string(), | ||||||
})?; | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be before komodo-defi-framework/mm2src/mm2_main/src/lp_native_dex.rs Lines 553 to 554 in 1675a53
You don't need to create the default db dir, only the global one. We probably also need to ensure_dir_is_writable , just in case.
|
||||||
|
||||||
init_ordermatch_context(&ctx)?; | ||||||
init_p2p(ctx.clone()).await?; | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here