Skip to content

add vyper signature to bytecode - #2860

Merged
charles-cooper merged 6 commits into
vyperlang:masterfrom
charles-cooper:add_vyper_signature
May 23, 2022
Merged

add vyper signature to bytecode#2860
charles-cooper merged 6 commits into
vyperlang:masterfrom
charles-cooper:add_vyper_signature

Conversation

@charles-cooper

@charles-cooper charles-cooper commented May 19, 2022

Copy link
Copy Markdown
Member

What I did

add a vyper signature to vyper bytecode. this makes it easier to identify on block explorers
the format is VYPR + major, minor, patch. for instance, a vyper 0.3.4 signature will be

56595052000304

EDIT:

>>> sig = b"\xa1\x65vyper\x83".hex()
>>> version = "00" + "03" + "04"
>>> sig + version
'a165767970657283000304'

How I did it

How to verify it

compile a vyper contract and look at the end of the bytecode

Commit message

Description for the changelog

Cute Animal Picture

image

@charles-cooper
charles-cooper marked this pull request as ready for review May 19, 2022 20:49
@codecov-commenter

codecov-commenter commented May 19, 2022

Copy link
Copy Markdown

Codecov Report

Merging #2860 (62e399f) into master (3195701) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2860      +/-   ##
==========================================
+ Coverage   87.67%   87.68%   +0.01%     
==========================================
  Files          94       94              
  Lines       10183    10193      +10     
  Branches     2501     2503       +2     
==========================================
+ Hits         8928     8938      +10     
  Misses        790      790              
  Partials      465      465              
Impacted Files Coverage Δ
vyper/compiler/output.py 93.78% <100.00%> (ø)
vyper/compiler/phases.py 94.91% <100.00%> (ø)
vyper/ir/compile_ir.py 93.69% <100.00%> (+0.06%) ⬆️
vyper/semantics/validation/local.py 90.96% <0.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3195701...62e399f. Read the comment docs.

@fubuloubu fubuloubu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As much as I hate it:

  1. Probably should be a VIP
  2. Probably should align with Solidity's metadata system (but obviously without the OS-specific hash) so that decoders don't get borked up when trying to detect why there are extra unused bytes in Vyper contracts now

Comment thread vyper/ir/compile_ir.py Outdated
Co-authored-by: El De-dog-lo <3859395+fubuloubu@users.noreply.github.com>
@fubuloubu

Copy link
Copy Markdown
Contributor

Issue being raised looks like it's not exported as part of bytecode_runtime?

@charles-cooper

Copy link
Copy Markdown
Member Author

the new offset introduced a small bug with symbol resolver, should be fixed now

@charles-cooper
charles-cooper merged commit 8d86995 into vyperlang:master May 23, 2022
@charles-cooper
charles-cooper deleted the add_vyper_signature branch May 23, 2022 14:17
@pcaversaccio

Copy link
Copy Markdown
Member

@charles-cooper I just reviewed an article about Vyper from @cairoeth that still assumed that the format is VYPR + major, minor, patch since the description is like that. But the signature is calculated like that (for e.g. 0.3.7) if I read the code correctly:

>>> sig = b"\xa1\x65vyper\x83".hex()
>>> version = "00" + "03" + "07"
>>> sig + version
'a165767970657283000307'

Could you please update your description above so we don't get any confusion anymore?

@charles-cooper

Copy link
Copy Markdown
Member Author

@pcaversaccio edited!

@pcaversaccio

Copy link
Copy Markdown
Member

Thx!

@pcaversaccio

Copy link
Copy Markdown
Member

FWIW, the signature has been removed from the runtime bytecode and is added to the end of the init code for Vyper >=0.3.10 #3471.

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.

4 participants