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
allocations optim #626
allocations optim #626
Conversation
Codecov Report
@@ Coverage Diff @@
## master #626 +/- ##
==========================================
- Coverage 89.42% 89.41% -0.01%
==========================================
Files 37 34 -3
Lines 6229 6234 +5
==========================================
+ Hits 5570 5574 +4
- Misses 659 660 +1
Continue to review full report at Codecov.
|
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.
LGTM and multiple times more efficient than our current implementation, So it's a go from me.
pallets/allocations/Cargo.toml
Outdated
pallet-emergency-shutdown = { default-features = false, path = "../emergency-shutdown" } | ||
scale-info = { version = "2.0.1", default-features = false, features = [ | ||
"derive", | ||
] } |
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.
only formatting.
pallets/allocations/Cargo.toml
Outdated
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } | ||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ | ||
"derive", | ||
] } |
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.
only formatting
support = { path = "../../support" } | ||
|
||
[dev-dependencies] | ||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.20" } | ||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.20" } |
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 only pallet-emergency-shutdown = { default-features = false, path = "../emergency-shutdown" }
was removed but there are lots of minor changes which hide this.
ret.push((account, T::ExistentialDeposit::get() * 10u32.into())); | ||
} | ||
|
||
ret.try_into().unwrap() |
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.
The unwrap
can be avoided with something like this:
type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
fn make_batch<T: Config>(b: u32) -> BoundedVec<(T::AccountId, BalanceOf<T>), T::MaxAllocs> {
let mut ret = BoundedVec::with_bounded_capacity(b as usize);
for i in 0..b {
let account = account("grantee", i, SEED);
let _ = ret.try_push((account, T::ExistentialDeposit::get() * 10u32.into()));
}
ret
}
}: _(RawOrigin::Signed(config.oracle.clone()), config.grantee.clone(), T::ExistentialDeposit::get() * 10u32.into(), vec![]) | ||
|
||
batch { | ||
let b in 1..T::MaxAllocs::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.
When a range starts at 1 and does not include the last element it looks suspicious, is this intended here?
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.
actually a batch len of 0, we'd throw an error since there are no allocations to perform
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 the last to call should be T::MaxAllocs::get()
or T::MaxAllocs::get()-1
?
9580fce
to
61c3b9f
Compare
61c3b9f
to
44aa064
Compare
Attempt to optimize the allocations pallet:
Transfer
events from thetransfer
calls for indexing in both Subscan and the Nodle App.batch
which will allow us to be much more efficient in batching allocations together VS our current approach of usingutility.batch_all
. Deprecateallocate
accordingly.When reviewing, pay attention to: