Skip to content

Refactor ABI generation#2284

Merged
iamdefinitelyahuman merged 8 commits into
vyperlang:masterfrom
iamdefinitelyahuman:refactor-abi-dict
Jan 25, 2021
Merged

Refactor ABI generation#2284
iamdefinitelyahuman merged 8 commits into
vyperlang:masterfrom
iamdefinitelyahuman:refactor-abi-dict

Conversation

@iamdefinitelyahuman

Copy link
Copy Markdown
Contributor

What I did

Refactor the ABI generation logic to happen within the new type objects.

How I did it

  • Added the _metadata attribute to all node objects. This is an all-purpose dict for annotating nodes with information that doesn't strictly belong in the AST. For now it's being used very sparingly, but this is the approach I'm envisioning for passing type-check info into LLL gen. So good to discuss it now while there aren't many places to change it, if desired.
  • Add to_abi_dict methods to ContractFunction, Event and InterfacePrimitive objects. The logic is largely copied from the old EventSignature and FunctionSignature objects.
  • Generate an InterfacePrimitive from the top-level node during type checking, and add it to the _metadata so it can be used to build the ABI.
  • Minor bugfixes around canonical types and signatures
  • Remove the old, now ded code in signatures/

How to verify it

Run the test suite. There is already extensive coverage around ABI generation.

Cute Animal Picture

image

@codecov-io

codecov-io commented Jan 25, 2021

Copy link
Copy Markdown

Codecov Report

Merging #2284 (ed13879) into master (f8782e0) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2284      +/-   ##
==========================================
+ Coverage   85.42%   85.49%   +0.06%     
==========================================
  Files          84       84              
  Lines        8586     8583       -3     
  Branches     2078     2076       -2     
==========================================
+ Hits         7335     7338       +3     
+ Misses        748      745       -3     
+ Partials      503      500       -3     
Impacted Files Coverage Δ
vyper/signatures/function_signature.py 77.71% <ø> (-3.70%) ⬇️
vyper/ast/nodes.py 93.39% <100.00%> (+0.01%) ⬆️
vyper/compiler/output.py 100.00% <100.00%> (ø)
vyper/context/types/function.py 85.64% <100.00%> (+2.40%) ⬆️
vyper/context/types/indexable/sequence.py 84.50% <100.00%> (+0.92%) ⬆️
vyper/context/types/meta/event.py 76.36% <100.00%> (+0.89%) ⬆️
vyper/context/types/meta/interface.py 81.13% <100.00%> (+3.68%) ⬆️
vyper/context/validation/module.py 87.57% <100.00%> (+0.14%) ⬆️
vyper/signatures/event_signature.py 94.87% <100.00%> (-0.88%) ⬇️
vyper/signatures/sig_utils.py 100.00% <100.00%> (ø)
... and 1 more

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 f8782e0...ed13879. Read the comment docs.

@iamdefinitelyahuman iamdefinitelyahuman merged commit 69f0402 into vyperlang:master Jan 25, 2021
@iamdefinitelyahuman iamdefinitelyahuman deleted the refactor-abi-dict branch January 25, 2021 22:36
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