-
Notifications
You must be signed in to change notification settings - Fork 707
feat: add rpc query for viewing global contract code #13547
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13547 +/- ##
===========================================
+ Coverage 1.62% 69.49% +67.86%
===========================================
Files 660 855 +195
Lines 114960 167998 +53038
Branches 114960 167998 +53038
===========================================
+ Hits 1873 116747 +114874
+ Misses 113031 46481 -66550
- Partials 56 4770 +4714
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5dfe82a
to
47978a7
Compare
hey, sorry, I'm OOO tomorrow and I won't be able to review it today, if you need a fast review please ask someone else, otherwise I'll have a look next week. |
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
#[error( | ||
"Global contract code with identifier {identifier:?} has never been observed on the node" | ||
)] | ||
NoGlobalContractCode { | ||
identifier: near_primitives::action::GlobalContractIdentifier, | ||
block_height: near_primitives::types::BlockHeight, | ||
block_hash: near_primitives::hash::CryptoHash, | ||
}, |
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.
This is duplicated, does it need to be?
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.
unfortunately yes, I was also annoyed by this
| QueryRequest::ViewGlobalContractCodeByAccountId { .. } => { | ||
// for global contract queries we can use any shard_id, so just take the first one | ||
let shard_ids = self.epoch_manager.shard_ids(&epoch_id)?; | ||
Ok(*shard_ids.iter().next().expect("at least one shard should always exist")) |
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.
cc @staffik Just musing - this will be fun when we move to single shard tracking RPC
6910ea6
to
f13a8a5
Compare
This PR adds
QueryRequest
for retrieving global contract code. This is needed becauseViewCode
query only allows retrieving contracted used as part of the specified accounts. Global contracts deployed separately, so we need to have a dedicated view query.2 separate enum variants are introduced for queries by hash (
ViewGlobalContractCode
) and by account id (ViewGlobalContractCodeByAccountId
) to have simple API and keep it consistent withDeployGlobalContract
/UseGlobalContract
actions.QueryResponseKind::ViewCode
is reused for the response.Also
QueryError::NoGlobalContractCode
error is introduced, similar toNoContractCode
.Closes #13531.