Emit commit details on contract instantiation #183
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This should make it easier to figure out 'where' a contract was built from.
Explanation of Changes
I emitted it during the instantiation so we don't have to allocate extra state storage for it, but that does mean we can only see the details in the tx/endblock where the contract was actually instantiated.
It would probably be better to only embed this info for debug builds, and if we do that we can probably keep it in state and retrieve it with a query. That's beyond my Rust capabilities though. Also didn't want to spend too much time on this in case we decide it's not useful. :)
Sources used to figure out how to achieve this:
rust-lang/rust-analyzer#13751
https://github.com/near/nearcore/blob/master/neard/build.rs
Testing
Deployed and instantiated on devnet: https://sedaprotocol.github.io/test-explorer/devnet/tx/ACF61782B4F718A70BC8A178748264D21579A89A5C43800DA3385CE9F443C651
Check the
tx_response.events[type=wasm].attributes[key=git_revision]
in the JSON view.Related PRs and Issues
None.