-
Notifications
You must be signed in to change notification settings - Fork 15
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: store prewitnessed deposits with id #4496
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4496 +/- ##
======================================
- Coverage 73% 72% -0%
======================================
Files 401 401
Lines 66210 66580 +370
Branches 66210 66580 +370
======================================
+ Hits 48089 48261 +172
- Misses 15802 15977 +175
- Partials 2319 2342 +23 ☔ View full report in Codecov by Sentry. |
c192a5b
to
06ad2f8
Compare
06ad2f8
to
5ad7814
Compare
Dm'd this to Jamie, but thought I'd post here for visibility too: pub enum RawOrigin {
HistoricalActiveEpochWitnessThreshold,
CurrentEpochWitnessThreshold,
} Then we can add PrewitnessThreshold or something. What this does is call the extrinsic it wraps, with the PrewitnessThreshold origin - we do something like this already, see dispatch_call in the witness lib.rs . Then inside the process_deposits extrinisc it can do a check if origin is prewitness else if origin is witness etc. This then keeps the nice CFE structure and makes it clear that there's one set of data we witness (the process_deposits extrinsic). And the rest of the SC is pretty much the same. The two paths can be pulled into separate functions for easier testing and benchmarking and what not. |
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.
Looks good, let me know when it's cleaned up for a final look over
- Added cleanup when witnessed - Added another test
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.
Nice work, few minor comments
|
||
#[block] | ||
{ | ||
let _old_deposits = PrewitnessedDeposits::<T, I>::clear_prefix(0, u32::MAX, None); |
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.
Better to pull the benchmarked part into a function rather than effectively duping this here and where it's actually called in the running code
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.
and then we can add a simple check that they were removed too
Be good if @msgmaxim can review this too - as he'll be building off it, make sure the assumptions are aligned |
@@ -566,12 +590,15 @@ pub mod pallet { | |||
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> { | |||
/// Recycle addresses if we can | |||
fn on_idle(_n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight { | |||
let read_write_weight = | |||
frame_support::weights::constants::RocksDbWeight::get().reads_writes(1, 1); | |||
let mut used_weight = Weight::zero(); |
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.
I know can_and_cannot_recycle
already existed, but can we rename it to something resembling what it does a bit closer? How about take_recyclable_addresses
? Also the maximum_recyclable_number
paramter could be renamed to maximum_blocks_to_recycle
(for example, right now it is not clear whether we are talking about addreses or blocks). can_recycle
can also be renamed to addresses_to_recycle
so it doesn't look like a boolean.
frame_support::weights::constants::RocksDbWeight::get().reads_writes(1, 1); | ||
let mut used_weight = Weight::zero(); | ||
|
||
let cleanup_weight = frame_support::weights::constants::RocksDbWeight::get() |
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.
Should this be recycle_weigth_per_block
? Also, maybe we could comments where reads_writes(2, 2)
comes from?
@@ -582,6 +609,10 @@ pub mod pallet { | |||
T::ChainTracking::get_block_height(), | |||
) | |||
}); | |||
used_weight = used_weight.saturating_add( |
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.
Does reading n
elements really counts as n
reads? I'm sure, but I would imagine this is more to do with how many lookups by key we do (1 in this case) rather than the size of the data read. (If we do need to count elements, should this be can_recycle
elements written, or the number of elements left?)
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.
This used_weight
addition is not just for the above mutate, it is for the for loop below, thats why it uses n
read/writes. Ill add a comment.
}); | ||
|
||
let deposit_channel_details = | ||
DepositChannelLookup::<T, I>::get(deposit_address.clone()) |
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.
You can use a reference here.
} | ||
// Cleanup the deposit data |
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.
Does having items here indicate that a deposit was pre-witnessed, but never fully witnessed? I wonder if we want to log this somehow.
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.
Yes it does. I think it might only matter if it was boosted.
assert_eq!( | ||
PrewitnessedDeposits::<Test>::get(channel_id, prewitnessed_deposit_id), | ||
Some(PrewitnessedDeposit { asset: ASSET, amount: DEPOSIT_AMOUNT, deposit_address }) | ||
); |
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.
Is the test until here exactly copies handle_prewitness_deposit
? If so, maybe the first test is redundant? Alternatively, maybe you could extract some of the common code into a helper function?
BlockHeightProvider::<MockEthereum>::set_block_height(expiry_block); | ||
|
||
// Run the cleanup | ||
IngressEgress::on_idle(1, Weight::MAX); |
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.
Looks like 1
isn't used in on_idle
, but it is meant to be block height, which you are setting to expiry_block
, so I think it would be more correct to use expiry_block
here too.
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.
expiry_block
is the eth block, but the 1
is the SC block. So it does not need to be the same value. I will set it to default to show that it does not matter for the test.
deposit_details: (), | ||
}; | ||
let deposit_witnesses = vec![deposit_detail.clone()]; | ||
assert_ok!(IngressEgress::add_prewitnessed_deposits(deposit_witnesses.clone())); |
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.
We could cover more logic if we use deposit with different amounts and check that the correct one gets removed.
3cd3bde
to
89aa3e2
Compare
…ero-liquidity * origin/main: fix: disable try-state checks (#4576) chore: debug solana in CI 🐛 (#4580) refactor: pass tx_ref as an extrinsic parameter (#4579) fix: remove bounded balance check (#4575) Solana: update image to latest tag (#4574) feat: add boost lp account to bouncer and fund it on setup_swaps (#4552) feat: Expose tx_hash on BroadcastSuccess event (#4561) feat: Relative Slippage Limits (PRO-1207) (#4547) chore: disable localnet solana in CI ⏱️ (#4569) feat: store prewitnessed deposits with id (#4496) Feat: Scheduled Swaps Subscription (#4525) # Conflicts: # state-chain/pallets/cf-pools/src/tests.rs
…utxo * origin/main: feat: expose command for broker fee withdrawal (#4581) Chore/fix arbitrum deployment (#4570) Added Range order pool price to the pool_price_v2 rpc call (#4548) fix: just check that the balance after is greater than before (#4587) chore: add origin to ccm failed (#4586) fix: runtime upgrade state check uses AllPalletsWithoutSystem (#4583) chore: add zellic audit to repo (#4585) fix: disable try-state checks (#4576) chore: debug solana in CI 🐛 (#4580) refactor: pass tx_ref as an extrinsic parameter (#4579) fix: remove bounded balance check (#4575) Solana: update image to latest tag (#4574) feat: add boost lp account to bouncer and fund it on setup_swaps (#4552) feat: Expose tx_hash on BroadcastSuccess event (#4561) feat: Relative Slippage Limits (PRO-1207) (#4547) chore: disable localnet solana in CI ⏱️ (#4569) feat: store prewitnessed deposits with id (#4496) Feat: Scheduled Swaps Subscription (#4525)
Pull Request
Closes: PRO-1141
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
process_deposits
extrinsic anymore due to issues with the origin. Instead they just call theprocess_deposit_witnesses
function directly.