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

feat: global contract usage #12886

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open

feat: global contract usage #12886

wants to merge 50 commits into from

Conversation

stedfn
Copy link
Contributor

@stedfn stedfn commented Feb 7, 2025

The PR adds testing and support for the UseGlobalContract action. Part of #12716

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 86.20690% with 24 lines in your changes missing coverage. Please review.

Project coverage is 70.65%. Comparing base (e8bbcfb) to head (41239c1).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
runtime/runtime/src/actions.rs 54.83% 12 Missing and 2 partials ⚠️
core/primitives/src/errors.rs 0.00% 4 Missing ⚠️
runtime/runtime/src/lib.rs 88.00% 0 Missing and 3 partials ⚠️
chain/chain-primitives/src/error.rs 0.00% 1 Missing ⚠️
chain/chain/src/runtime/mod.rs 0.00% 1 Missing ⚠️
integration-tests/src/user/runtime_user.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12886      +/-   ##
==========================================
+ Coverage   70.53%   70.65%   +0.12%     
==========================================
  Files         851      851              
  Lines      174921   175143     +222     
  Branches   174921   175143     +222     
==========================================
+ Hits       123374   123752     +378     
+ Misses      46420    46248     -172     
- Partials     5127     5143      +16     
Flag Coverage Δ
backward-compatibility 0.36% <0.00%> (-0.01%) ⬇️
db-migration 0.36% <0.00%> (-0.01%) ⬇️
genesis-check 1.42% <0.00%> (-0.01%) ⬇️
linux 70.29% <8.04%> (-0.10%) ⬇️
linux-nightly 70.30% <86.20%> (+0.14%) ⬆️
pytests 1.73% <0.00%> (-0.01%) ⬇️
sanity-checks 1.54% <0.00%> (-0.01%) ⬇️
unittests 70.49% <86.20%> (+0.12%) ⬆️
upgradability 0.36% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from stefan/global_contract_account_support to master February 10, 2025 09:08
@stedfn stedfn force-pushed the stefan/global_contract_usage branch from ac40cd9 to b4c4c2f Compare February 11, 2025 12:11
@stedfn stedfn changed the title [wip] feat: global contract usage feat: global contract usage Feb 13, 2025
@stedfn stedfn requested a review from pugachAG February 13, 2025 12:28
@stedfn stedfn marked this pull request as ready for review February 13, 2025 12:28
@stedfn stedfn requested a review from a team as a code owner February 13, 2025 12:28
runtime/runtime/src/actions.rs Show resolved Hide resolved
ReceiptEnum::GlobalContractDistribution(_)
| ReceiptEnum::Data(_)
| ReceiptEnum::PromiseResume(_) => 0,
ReceiptEnum::GlobalContractDistribution(contract_data) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Costs are charged as part of Action::DeployGlobalContract processing, why do we consider ReceiptEnum::GlobalContractDistribution 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.

the logic was that the action generates a single outgoing distribution receipt (which later gets cloned) that I can use for the check_balance calculation

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand why your approach works, the question is if this can be implemented by checking for successfully executed Action::DeployGlobalContract actions

Copy link
Contributor

Choose a reason for hiding this comment

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

it seems like accessing action execution result isn't straightforward, so we can keep using your approach for now

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 think the alternative is adding a new field in BalanceStats for gas burnt by global actions

runtime/runtime/src/lib.rs Outdated Show resolved Hide resolved
core/store/src/trie/update.rs Outdated Show resolved Hide resolved
integration-tests/src/test_loop/utils/transactions.rs Outdated Show resolved Hide resolved
integration-tests/src/test_loop/utils/transactions.rs Outdated Show resolved Hide resolved
integration-tests/src/test_loop/utils/transactions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
total_receipts_cost(config, receipts)
};
let receipts_cost =
|receipts: &[Receipt], is_outgoing: bool| -> Result<Balance, IntegerOverflowError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is very convoluted and invasive way of doing that, I suggest moving it outside of total_receipts_cost to a dedicated method, something like fn global_contract_deploy_costs(config: &RuntimeConfig, outgoing_receipts: &[Receipt])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a field in BalanceStats for gas burnt by global actions, let me know if the approach is better

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.

2 participants