-
Notifications
You must be signed in to change notification settings - Fork 378
Parachains should charge for proof size weight #2326
Conversation
Use the trait directly instead of something that will have a blanket implementation for it. Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
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.
Some documentation typos/bad find/replace I think. But logic looks good.
// Map 10kb proof to 1 CENT. | ||
let p = super::currency::CENTS; | ||
let q = 10_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.
I suppose we don't have a reference on the Relay Chain.
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, since the relay chain has u64::MAX
as max block proof-size whereas parachains only have 5 MiB.
We will probably need some further adjustments to find the sweet-spot, but for now this should provide something that we can work with.
There are going to be changes in Substrate soon that increase the proof size of everything (until we have https://github.com/paritytech/substrate/issues/13501), so to prevent accidental fuckups i added the tests that 1K transfers fit in a block.
parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/constants.rs
Outdated
Show resolved
Hide resolved
parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/constants.rs
Outdated
Show resolved
Hide resolved
parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/constants.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: joe petrowski <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@@ -55,13 +56,45 @@ pub mod fee { | |||
/// - Setting it to `0` will essentially disable the weight fee. | |||
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. | |||
pub struct WeightToFee; | |||
impl WeightToFeePolynomial for WeightToFee { | |||
impl frame_support::weights::WeightToFee for WeightToFee { |
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.
Could be simplified by implementing WeightToFee
for Tuple
? or too many tuples impls? 🙈
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 we could do a simple maximum norm. In the long run i would rather make the traits 2D weight compatible in Substrate, so we wont need it.
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.
For now it is fine or? Since this targets 0.9.38.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.
Yeah nah, you would be confused if it is addition, or max or what.
I suppose we can provide some nice helpers at he substrate layer though:
struct RefTimeWeightCostPerMicroSec<Balance, Cost: Get<Balance>>(..);
impl WeightToFee for RefTimeConstPerMicroSec { .. }
struct ProofSizeWeightCostPerKByte<Balance, Cost: Get<Balance>>(..);
impl WeightToFee for RefTimeConstPerMicroSec { .. }
Or even a more generic:
struct CostPerUnit<Balance, Cost: Get<Balance>, Unit: ops::Div<Balance>>;
I think you can see where I am going with this. Just an idea
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.
For now it is fine or? Since this targets 0.9.38.1
Yeah fine for now. Perhaps a follow-up issue that you can mentor?
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.
End of the day, all runtimes want to express:
- I want x unit of balance per ref_time unit.
- I want y unit of balance per proof_size unit.
- Take the
max
of them.
Perhaps we can provide structs that easily let you express x and y the former two as Get
or const GENERIC
.
cc @xlc in case you want to review. |
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
bot merge |
Waiting for commit status. |
Merge cancelled due to error. Error: Checks failed for b6ca4b5 |
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
The label check here only allows me to set |
bot merge |
* master: Companion for #13624 (#2354) Introduce Fellowship into Collectives (#2186) NFTs 2.0 on Statemine (#2314) Bump assert_cmd from 2.0.8 to 2.0.10 (#2341) Bump clap from 4.1.8 to 4.1.11 (#2352) Companion for substrate #13312: Rename `Deterministic` to `Enforce` (#2350) [Companion #13634] keystore overhaul (iter) (#2345) Revert #2304 (#2349) Deprecate Currency: Companion for #12951 (#2334) Bump ci-linux image for rust 1.68 Always pass port to jsonrpsee WebSocket client (#2339) bump zombienet to v1.3.40 (#2348) Improve build times by disabling wasm-builder in `no_std` (#2308) Bump toml from 0.7.2 to 0.7.3 (#2340) Bump serde from 1.0.152 to 1.0.156 (#2329) Parachains should charge for proof size weight (#2326) dmp-queue: Store messages if already processed more than the maximum (#2343) [Companion #13615] Keystore overhaul (#2336) Bump quote from 1.0.23 to 1.0.26 (#2331)
Closes #2322, depends on paritytech/substrate#13612
Currently the parachains do not charge weight for the proof size component of call weights.
With this MR it will calculate one fee for ref-time and one for proof-size and choose the larger one. This affects all parachain runtimes. There are some sanity checks in place for Statemin*.
Eventually we went a more compact and automated implementation, but that would require breaking changes in Substrate, so skipping that for now.