-
Notifications
You must be signed in to change notification settings - Fork 89
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
RC6 + update module weights #266
Conversation
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, some minor clarifications.
@vedhavyas following this:
Is it mandatory to pass this type to the runtime pallet? Wouldnt it use the default one if not passed?
|
@mikiquantum true! Updated now |
runtime/Cargo.toml
Outdated
substrate-pallet-multi-account = { version = "2.0.0-rc3-0", git = "https://github.com/centrifuge/substrate-pallet-multi-account", rev = "557b4da832a1d74ed286c3a3a4b20b7d80f47e05", default-features = false } | ||
chainbridge = { version = "0.0.1", git = "https://github.com/chainsafe/chainbridge-substrate.git", rev = "59fbb767de890b6dcb781fb9e6c4c84a967693ff" , default-features = false} | ||
substrate-pallet-multi-account = { version = "2.0.0-rc6", git = "https://github.com/centrifuge/substrate-pallet-multi-account", rev = "5b8d12bd0260551f18223001b2c5091ea92fc7d8", default-features = false } | ||
chainbridge = { version = "0.0.1", git = "https://github.com/vedhavyas/chainbridge-substrate.git", rev = "19df3f21889e60be286f532cd785d5d17ff61c4c" , default-features = false} |
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.
Will point to chain bridge once ChainSafe/chainbridge-substrate#64 is merged
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.
Thanks @vedhavyas , just left a few comments regarding weights. 👍
@@ -118,7 +118,7 @@ decl_module! { | |||
/// # <weight> | |||
/// minimal logic, also needs to be consume less block capacity + cheaper to make the pre-commits viable. | |||
/// # </weight> | |||
#[weight = 500_000] | |||
#[weight = 193_000_000] |
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.
Instead of constants, what do you think about using benchmarking as Substrate does to determine the time complexity, and using T::DbWeight::get().reads_writes(1, 1)
for storage access? See https://centrifuge.hackmd.io/Mb8IAGhHQ32DEl1GIoBkCQ#Action-items for details.
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.
T::DbWeight::get().reads_writes(1, 1)
implies we are doing only one read and one write for which is incorrect. Hence, I would like to keep our weights which were constant before as constants now to imply we are not considering the reads and writes but rather a chosen fixed weight @philipstanislaus
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.
@vedhavyas keeping the weights constant is a bad idea, since we most likely missprice our extrinsics compared to substrate. The issue with that is an attack vector – if you find a severely underpriced extrinsic, you could just send a load of them and the block can't be executed within the time limit (Not sure what happens then though?).
Could you create a ticket to run benchmarks and use the actual reads/writes? Maybe link to that issue: paritytech/substrate#6168
|
||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> { | ||
smallvec!(WeightToFeeCoefficient { | ||
coeff_integer: 315000, |
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 noticed that you came to a different weight to fee constant (315000) from my calculation (625000) – are you sure your calculation is correct? I haven’t looked into it yet, just want to make sure that our fees will not suddenly be much cheaper than before.
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.
Do verify this locally to ensure the fees are not lowered or made much cheaper than we are charging right now in mainnet @philipstanislaus
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.
@vedhavyas done, I confirmed locally that anchor commits and balance transfers stay roughly the same. Thanks!
impl_version: 0, | ||
apis: RUNTIME_API_VERSIONS, | ||
transaction_version: 0, | ||
transaction_version: 1, |
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.
Why did this change?
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.
It seems like this is the convention I saw in the node-template. i.e starting the transaction_verison from 1 - https://github.com/paritytech/substrate/blob/master/bin/node-template/runtime/src/lib.rs#L101 @philipstanislaus
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.
Thanks 👍
RC6 Changes from RC3:
TargetedFeeAdjustment
is removed and we are using the default one provided with RC6democracy
,balances
make full use of this feature. I have added the default weight values taken from the substrate node.SlashDefferedTime
must be less than theUnbondingTime
.SlashDefferedTime
to 6 days insteadWeight Changes
With RC3, weights in substrate pallets have changed and so does the WeightToFee calculations. We would need to adjust our own module and our pallet weights accordingly.
How are new weights calculated:
With the new weight changes, the extrinsic bytes fee will be significantly higher since we charge 1 Micro rad per byte.
So for a balance transfer of 1 rad, the extrinsic payload would be around 97 bytes i.e 97 Micro rad just for Byte fee. With adding the remaining BaseFee, WeightFee, we would be charging some around 300 Micro RAD. Right now, we charge 100 Micro RAD.
We can reduce the weight fee coefficient. Making it 0, means, ignoring the weight completely, would still lead to 97 Micro Rad. and that defeats the who purpose of having weights to extrinsic.
Most of the substrate's internal weights are set as per Reads and Writes to DB, and total processing time as well. In order to charge the extrinsic correctly and keeping the new fees in par with the current fees we charge, I have updated
These changes will give us more control over how we charge the extrinsic based on their weights rather than extrinsic payload bytes.
With these changes, we will charge around 101.641 Micro RAD for 1 RAD balance transfer. But as the RAD number increases, so does the number of bytes in the extrinsic, which leads to slight increase in fees.
Using the
balance.transfer
as the base, I have calculated our module weights, multi-account, and chain bridge weights accordingly so that we are charging around the same fee we charging right now on Mainnet.Anchor:
Since anchors commit and pre-commit, have the same extrinsic payload bytes, the fee will be similar. but extrinsic that contain huge bytes payload will change much higher.
An example would be
system.SetCode
. Seems like there are no fees charged for this extrinsic when I check the recent runtime upgrade we made from subscan(correct me if I'm wrong here). With this new weights, we will charging around632.358 milli RAD
.