Skip to content
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

Add vesting precompile #661

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open

Add vesting precompile #661

wants to merge 44 commits into from

Conversation

luispdm
Copy link
Contributor

@luispdm luispdm commented Jul 9, 2024

#615

  • A minimal pallet called benchmark (at pallets/benchmark/src) is required to benchmark precompiles whose code is not included in this repo (i.e. the vesting pallet in this PR)
  • The benchmark pallet is included in the LAOS config but it doesn't have any extrinsics, so it cannot be used by anyone in production
  • Precompile code can be found at pallets/benchmark/src/precompiles/vesting

@luispdm luispdm linked an issue Jul 9, 2024 that may be closed by this pull request
@luispdm luispdm marked this pull request as ready for review July 12, 2024 10:28
Copy link
Contributor

@magecnion magecnion Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be more appropiate to name it pallet_vesting_precompile, something like that. It would be possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this but in the end I went with pallet_benchmark. Why? Because the command used to generate the weights targets all the extrinsics:

./target/release/laos \
  benchmark \
  pallet \
  --chain=dev \
  --steps=50 \
  --repeat=20 \
  --pallet=pallet_benchmark \
  --extrinsic="*" \
  --wasm-execution=compiled \
  --output=./runtime/laos/src/weights/

This means that when we add more precompiles' benchmarks, all the weights will go to the same file.

In case we want to separate the weights on a precompile basis, we'd have to run one command per precompile, listing all of the extrinsics of that precompile in the command (e.g. --extrinsic="fn1,fn2,fn3"...).
The drawback I see here is that we might forget some of the extrinsics when we run the command.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar thing to the other comment, the configuration is about vesting precompile. A renaming here would be needed I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree here. There's only one pallet with one config: benchmark. The pallet and the config include types for all of the required precompiles

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file usually serves as a default weights configuration for developers that use the pallet. In this case, benchmark pallet just helps us to run benchmarks for our precompiles. I think we can skip the creation of weights.rs file here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But such weights are used to register the cost of the call. E.g. in vest:

<Runtime as crate::Config>::WeightInfo::precompile_vest()

WeightInfo comes from crate::weights::WeightInfo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I was trying to think a way to prevent making default weights (i.e.: SubstrateWeight) public. Because no one needs them. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vesting precompile
4 participants