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

feat: create_from_factory and create_copy_of #2895

Merged
merged 31 commits into from
Jun 14, 2022

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jun 5, 2022

What I did

add create_from_factory and create_copy_of builtins

  • create_copy_of copies the runtime code at the given address
  • create_from_factory treats the code at given address as initcode, and tacks on the varargs so that the constructor interprets them as constructor arguments.
  • renames create_forwarder_to to create_minimal_proxy_to (still allows the old name as a deprecated alias)

fixes #1362, fixes #773, fixes #2893, fixes #2890, closes #2883

also added _has_varargs flag to SimpleBuiltinFunction. builtins now need a bit of refactoring, but saving that for a follow-up PR.

open question: should we revert if extcodesize of the target contract is 0? thinking yes reverts if extcodesize of target contract is 0.

How I did it

some mucking around with assembly

How to verify it

check tests

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Jun 5, 2022

This pull request introduces 49 alerts when merging 60323b6 into 90e3d20 - view on LGTM.com

new alerts:

  • 27 for Unused import
  • 16 for Unused local variable
  • 3 for Variable defined multiple times
  • 2 for Wrong number of arguments in a call
  • 1 for Unreachable code

create_copy_of is required since there isn't really an ergonomic way to
get a bytestring with the bytecode of a contract (and even if there
were, it would over-allocate memory)
@charles-cooper charles-cooper force-pushed the create_zoo branch 2 times, most recently from f2972d0 to c9ba77b Compare June 9, 2022 22:37
create_copy_of and create_with_code_of. delete raw create() function
@charles-cooper charles-cooper changed the title zoo of create functions feat: create_with_code_of and create_copy_of Jun 10, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2022

Codecov Report

Merging #2895 (f0e8a75) into master (b8dea0c) will decrease coverage by 0.52%.
The diff coverage is 96.42%.

@@            Coverage Diff             @@
##           master    #2895      +/-   ##
==========================================
- Coverage   88.05%   87.53%   -0.53%     
==========================================
  Files          95       95              
  Lines       10442    10575     +133     
  Branches     2512     2532      +20     
==========================================
+ Hits         9195     9257      +62     
- Misses        790      848      +58     
- Partials      457      470      +13     
Impacted Files Coverage Δ
vyper/codegen/ir_node.py 91.79% <91.66%> (-0.64%) ⬇️
vyper/builtin_functions/functions.py 88.75% <95.37%> (-3.29%) ⬇️
vyper/ast/validation.py 79.16% <100.00%> (+1.38%) ⬆️
vyper/builtin_functions/signatures.py 95.00% <100.00%> (+5.00%) ⬆️
vyper/codegen/context.py 89.74% <100.00%> (+0.26%) ⬆️
vyper/codegen/core.py 84.58% <100.00%> (+0.11%) ⬆️
vyper/codegen/keccak256_helper.py 81.81% <100.00%> (-1.52%) ⬇️
vyper/ir/optimizer.py 91.85% <100.00%> (+0.12%) ⬆️
vyper/utils.py 87.91% <100.00%> (+0.76%) ⬆️
vyper/semantics/types/value/numeric.py 80.45% <0.00%> (-4.60%) ⬇️
... and 12 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 b8dea0c...f0e8a75. Read the comment docs.

@charles-cooper charles-cooper marked this pull request as ready for review June 10, 2022 05:11
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good

docs/built-in-functions.rst Outdated Show resolved Hide resolved
docs/built-in-functions.rst Outdated Show resolved Hide resolved
docs/built-in-functions.rst Outdated Show resolved Hide resolved
docs/built-in-functions.rst Outdated Show resolved Hide resolved
docs/built-in-functions.rst Outdated Show resolved Hide resolved
docs/built-in-functions.rst Outdated Show resolved Hide resolved
docs/built-in-functions.rst Outdated Show resolved Hide resolved
@charles-cooper charles-cooper changed the title feat: create_with_code_of and create_copy_of feat: create_from_factory and create_copy_of Jun 11, 2022
docs/built-in-functions.rst Outdated Show resolved Hide resolved
docs/built-in-functions.rst Outdated Show resolved Hide resolved
@charles-cooper charles-cooper merged commit 2adc34f into vyperlang:master Jun 14, 2022
@charles-cooper charles-cooper deleted the create_zoo branch June 14, 2022 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants