-
Couldn't load subscription status.
- Fork 2.7k
Adapt pallet-contracts to WeightV2
#12421
Conversation
|
Closes #12410 |
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, though I would really like to see some tests for the proof_size accounting
frame/contracts/src/tests.rs
Outdated
| // Drop previous events | ||
| initialize_block(2); | ||
|
|
||
| println!("--------------"); |
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.
Nit: is this intended?
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.
Nope. Some leftover. Thanks.
| /// Used by backwards compatible extrinsics. We cannot just set the proof to zero | ||
| /// or an old `Call` will just fail. | ||
| fn compat_weight(gas_limit: OldWeight) -> Weight { | ||
| Weight::from(gas_limit).set_proof_size(u64::from(T::MaxCodeLen::get()) * 2) |
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.
Dumb question: Is the MacCodeLen * 2 always a sufficient approximation of gas?
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.
Depends on how many contracts you call and how big they are in a single transaction. This is just a ad-hoc solution to support in-storage Calls that might exist in a Scheduler of some runtime. This is very niche. You should use the dry-run to come up with a proper value and don't rely on this.
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! Thanks for fixing this!
|
bot merge |
|
Error: "Check reviews" status is not passing for paritytech/cumulus#1726 |
|
bot merge |
* master: (42 commits) Adapt `pallet-contracts` to WeightV2 (#12421) Improved election pallet testing (#12327) Bump prost to 0.11+ (#12419) Use saturating add for alliance::disband witness data (#12418) [Fix] Rename VoterBagsList -> VoterList to match pdot (#12416) client/beefy: small code improvements (#12414) BEEFY: Simplify hashing for pallet-beefy-mmr (#12393) Add @koute to `docs/CODEOWNERS` and update stale paths (#12408) docs/CODEOWNERS: add @acatangiu as MMR owner (#12406) Remove unnecessary Clone trait bounds on CountedStorageMap (#12402) Fix `Weight::is_zero` (#12396) Beefy on-demand justifications as a custom RequestResponse protocol (#12124) Remove contracts RPCs (#12358) pallet-mmr: generate historical proofs (#12324) unsafe_pruning flag removed (#12385) Carry over where clauses defined in Config to Call and Hook (#12388) Properly set the max proof size weight on defaults and tests (#12383) BEEFY: impl TypeInfo for SignedCommitment (#12382) bounding staking: `BoundedElectionProvider` trait (#12362) New Pallet: Root offences (#11943) ...
* Replace contract access weight by proper PoV component * Return the whole weight struct from dry-runs * Fixup `seal_call` and `seal_instantiate` * Fix duplicate extrinsics * Remove ContractAccessWeight from runtime * Fix doc link * Remove leftover debugging output
A few changes were necessary to make
pallet-contractscompatible with the new weight.Remove
ContractAccessWeightThis was a workaround used to emulate the huge PoV impact generated by loading a contract. This is now replaced by setting the
proof_sizeto the size of the loaded contract. This is an underestimation but the whole system is just in place to prevent the worst offenders. Charging for anything else is missing anyways and will come later.Return the whole
Weightstruct from dry runsDry runs now include the
proof_sizeso that clients can use this to learn about how muchproof_sizea transaction will consume.Fix inter contract calls
seal_callandseal_instantiateallow only setting 1D weight. Eventually we need to add new versions of those. But the old versions need fixing, too. Current behavior is to setproof_sizeto0which is not a good default. It will prevent the callee to do anything useful. This PR sets theproof_sizeto "inherit" which allows it to use all of the remaining proof size from the overarching limit.Fix compatibility extrinsics
When adding the 2D weight we also added
*_old_weightcompat extrinsics to allow in-storage extrinsics to be still decoded. However, they also setproof_sizeto0which makes them useless. This PR sets some sensible default so they continue working. We also removed duplication in docs and code from them.cumulus companion: paritytech/cumulus#1726
Closes #12410