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: add receipt action for using global contract code #12749

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

pugachAG
Copy link
Contributor

This PR is similar to #12737, but for using global contracts.

Part of #12716.

@pugachAG pugachAG requested a review from a team as a code owner January 16, 2025 16:11
@pugachAG pugachAG force-pushed the add-use-global-contract-action branch from 56b2cc7 to 805c06e Compare January 16, 2025 16:12
@@ -126,7 +126,7 @@ impl ReceiptPreparationPipeline {
for (action_index, action) in actions.iter().enumerate() {
let account_id = account_id.clone();
match action {
Action::DeployContract(_) => {
Action::DeployContract(_) | Action::UseGlobalContract(_) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @nagisa

Copy link
Contributor

@shreyan-gupta shreyan-gupta left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -270,6 +306,7 @@ pub enum Action {
DeleteAccount(DeleteAccountAction),
Delegate(Box<delegate::SignedDelegateAction>),
DeployGlobalContract(DeployGlobalContractAction),
UseGlobalContract(Box<UseGlobalContractAction>),
Copy link
Contributor

Choose a reason for hiding this comment

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

Was wondering when do we use a Box vs when not? Example DeployGlobalContract doesn't have a Box

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is static assert below:

const _: () = assert!(
    // 1 word for tag plus the largest variant `DeployContractAction` which is a 3-word `Vec`.
    // The `<=` check covers platforms that have pointers smaller than 8 bytes as well as random
    // freak nightlies that somehow find a way to pack everything into one less word.
    std::mem::size_of::<Action>() <= 32,
    "Action <= 32 bytes for performance reasons, see #9451"
);

UseGlobalContract {
code_hash: CryptoHash,
},
UseGlobalContractByAccountId {
Copy link
Contributor

Choose a reason for hiding this comment

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

Checking if it's fine to have two separate enums here while we have just one in Action::UseGlobalContract?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my understanding it is OK, since Action is our internal representation while ActionView is public API. So I decided to have single Action because it is more concise. Having separate ActionView for deploying by account id avoids overcomplicating public api with choosing the identifier.

@pugachAG pugachAG force-pushed the add-use-global-contract-action branch from 805c06e to 8dfb3dd Compare January 16, 2025 19:57
@pugachAG pugachAG enabled auto-merge January 16, 2025 19:57
@pugachAG pugachAG added this pull request to the merge queue Jan 16, 2025
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 0% with 52 lines in your changes missing coverage. Please review.

Project coverage is 70.63%. Comparing base (0a57709) to head (8dfb3dd).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
runtime/runtime/src/verifier.rs 0.00% 18 Missing ⚠️
core/primitives/src/views.rs 0.00% 13 Missing ⚠️
runtime/runtime/src/actions.rs 0.00% 9 Missing ⚠️
core/primitives/src/action/mod.rs 0.00% 6 Missing ⚠️
runtime/runtime/src/lib.rs 0.00% 3 Missing ⚠️
chain/rosetta-rpc/src/adapters/mod.rs 0.00% 2 Missing ⚠️
tools/state-viewer/src/contract_accounts.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12749      +/-   ##
==========================================
- Coverage   70.69%   70.63%   -0.07%     
==========================================
  Files         848      849       +1     
  Lines      174376   174470      +94     
  Branches   174376   174470      +94     
==========================================
- Hits       123280   123235      -45     
- Misses      45950    46086     +136     
- Partials     5146     5149       +3     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (-0.01%) ⬇️
db-migration 0.16% <0.00%> (-0.01%) ⬇️
genesis-check 1.35% <0.00%> (-0.01%) ⬇️
linux 69.14% <0.00%> (-0.06%) ⬇️
linux-nightly 70.22% <0.00%> (-0.05%) ⬇️
pytests 1.65% <0.00%> (-0.01%) ⬇️
sanity-checks 1.46% <0.00%> (-0.01%) ⬇️
unittests 70.46% <0.00%> (-0.07%) ⬇️
upgradability 0.20% <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.

Merged via the queue into master with commit 8067cb6 Jan 16, 2025
26 of 28 checks passed
@pugachAG pugachAG deleted the add-use-global-contract-action branch January 16, 2025 20:44
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