Skip to content

Subsidize adding an Ethereum compatible control key #2403

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

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

Conversation

shannonwells
Copy link
Collaborator

@shannonwells shannonwells commented May 12, 2025

Goal

The goal of this PR is to allow adding a second key to be a free subsidized capacity transaction under specific circumstances. This change reduces the capacity fee by about 70% when there is one key, and the new key is Ethereum-compatible.

Most of #2286

Discussion

Note on something easy to miss: the expiration block will default to 0, which means this feature is off by default, until the value is set to a block in the future. There is no on-chain monitoring of the usage of this feature.

Checklist

  • As Sudo or Council, can set the expiration block for the free subsidized key addition period.
  • Updated frequency-tx-payment SignedExtension to use a filter for the specific call
  • frequency-tx-payment uses an Msa call to determine eligibility
  • Updated Pallet Readme?
  • Unit Tests added?
  • e2e Tests added?
  • Benchmarks added?
  • Spec version incremented?

not applicable

- [ ] Design doc(s) updated?

@@ -46,5 +46,8 @@
"tsx": "^4.19.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.30.1"
},
"optionalDependencies": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needed for running e2e tests locally on Ubuntu

@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release and removed metadata-changed Metadata has changed since the latest full release labels May 13, 2025
@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label May 13, 2025
Copy link

codecov bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
common/primitives/src/msa.rs 87.95% <ø> (ø)
common/primitives/src/signatures.rs 77.94% <100.00%> (+0.82%) ⬆️
pallets/frequency-tx-payment/src/lib.rs 87.81% <100.00%> (+1.14%) ⬆️
pallets/msa/src/lib.rs 92.74% <100.00%> (+0.49%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shannonwells shannonwells marked this pull request as ready for review May 13, 2025 16:27
@shannonwells shannonwells requested a review from wilwade as a code owner May 13, 2025 16:27
@shannonwells shannonwells requested review from a team, mattheworris, enddynayn, aramikm, claireclark1 and JoeCap08055 and removed request for a team May 13, 2025 20:04
@shannonwells shannonwells force-pushed the feat/free-add_key-#2286 branch from ca3b553 to 844f53e Compare May 13, 2025 22:06
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented and removed metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels May 13, 2025
@shannonwells shannonwells requested a review from JoeCap08055 May 13, 2025 22:39
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented and removed metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels May 13, 2025
@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label May 21, 2025

/// Filters calls that match Msa::add_public_key_to_msa
pub trait GetAddKeyData<RuntimeCall, AccountId, MessageSourceId> {
/// If the xall matches Msa::add_public_key_to_msa, return the owner account id and msa id
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// If the xall matches Msa::add_public_key_to_msa, return the owner account id and msa id
/// If the call matches Msa::add_public_key_to_msa, return the owner account id and msa id

@github-actions github-actions bot removed the metadata-changed Metadata has changed since the latest full release label May 21, 2025
@shannonwells shannonwells marked this pull request as ready for review May 21, 2025 19:03
@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label May 21, 2025
@shannonwells shannonwells changed the title Add ability to adding an Ethereum compatible control key for free Subsidize adding an Ethereum compatible control key May 21, 2025
if eligible_call_weight.is_zero() {
0u32.into()
} else {
let reduction: Permill = Permill::from_percent(70u32);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See e2e test for how much this reduces cost.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think it might be helpful to have a comment about the weight reductions or percentages and such in here.

Overall is it fair to say that this reduces the fee to around 0.3 or a bit more for subsidized?

Copy link
Collaborator Author

@shannonwells shannonwells May 22, 2025

Choose a reason for hiding this comment

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

Yes, that's about right

signPayloadSr25519,
stakeToProvider,
} from '../scaffolding/helpers';
import { getUnifiedAddress, getUnifiedPublicKey } from '../scaffolding/ethereum';
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Unfortunately my pr merge caused a conflict here and you should use @frequency-chain/ethereum-utils for these functions

let withdraw_fee = ChargeFrqTransactionPayment::<Test>::from(0u64)
.withdraw_fee(&owner_id, &pay_with_capacity_add_public_key_call, &dispatch_info, 10)
.unwrap();
assert!(withdraw_fee.0.lt(&106_000_000u64));
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Might worth comparing the non-ethereum vs ethereum weights for the same call instead of using a magic number which might change in feature.

Copy link
Collaborator

Choose a reason for hiding this comment

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

if no additional functions are added or removed then maybe this should not get committed!?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oversight, thanks

if eligible_call_weight.is_zero() {
0u32.into()
} else {
let reduction: Permill = Permill::from_percent(70u32);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think it might be helpful to have a comment about the weight reductions or percentages and such in here.

Overall is it fair to say that this reduces the fee to around 0.3 or a bit more for subsidized?

Copy link
Collaborator

@mattheworris mattheworris left a comment

Choose a reason for hiding this comment

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

  • Read through changes.
    🚢 it!

@shannonwells shannonwells force-pushed the feat/free-add_key-#2286 branch from 2d60894 to 0ff2ee2 Compare May 23, 2025 01:39
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release and removed metadata-changed Metadata has changed since the latest full release labels May 23, 2025
Copy link
Collaborator

@JoeCap08055 JoeCap08055 left a comment

Choose a reason for hiding this comment

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

Nice work, approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metadata-changed Metadata has changed since the latest full release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants