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

Emit commit details on contract instantiation #183

Merged
merged 1 commit into from
Jun 28, 2024
Merged

Conversation

Thomasvdam
Copy link
Member

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.

@Thomasvdam Thomasvdam requested review from gluax and a team June 28, 2024 16:04
Copy link
Collaborator

@gluax gluax left a comment

Choose a reason for hiding this comment

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

Do we want a query method to check the version as well or is that overkill?

@hacheigriega
Copy link
Member

Do we want a query method to check the version as well or is that overkill?

We can do a raw query of the contract state, right?

@Thomasvdam
Copy link
Member Author

For that we would have to store it in the state. We can add that but it felt a little overkill for a debugging tool. Maybe with the config feature flag stuff we can only include it on dev builds?

@hacheigriega
Copy link
Member

My bad - I commented without reading the code first. I agree this is enough at least for now.

@Thomasvdam Thomasvdam merged commit e21618f into main Jun 28, 2024
2 checks passed
@Thomasvdam Thomasvdam deleted the chore/emit-build branch June 28, 2024 17:09
@gluax
Copy link
Collaborator

gluax commented Jun 28, 2024

I can add something that is for devnet only. When I look into #182.

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.

3 participants