Skip to content

Commit

Permalink
chore: v0.3.0 release (#2473)
Browse files Browse the repository at this point in the history
* add a test for struct side effects

* chore: write v0.3.0 release notes, bump version
  • Loading branch information
charles-cooper committed Oct 4, 2021
1 parent f120603 commit 8a23feb
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 1 deletion.
32 changes: 32 additions & 0 deletions docs/release-notes.rst
Expand Up @@ -3,6 +3,38 @@
Release Notes
#############

v0.3.0
*******

Date released: 2021-10-04

Breaking changes:

* Change ABI encoding of single-struct return values to be compatible with Solidity (`#2457 <https://github.com/vyperlang/vyper/pull/2457>`_)
* Drop Python 3.6 support (`#2462 <https://github.com/vyperlang/vyper/pull/2462>`_)

Non-breaking changes and improvements:

* Rewrite internal calling convention (`#2447 <https://github.com/vyperlang/vyper/pull/2447>`_)
* Allow any ABI-encodable type as function arguments and return types (`#2154 <https://github.com/vyperlang/vyper/issues/2154>`_, `#2190 <https://github.com/vyperlang/vyper/issues/2190>`_)
* Add support for deterministic deployment of minimal proxies using CREATE2 (`#2460 <https://github.com/vyperlang/vyper/pull/2460>`_)
* Optimize code for certain copies (`#2468 <https://github.com/vyperlang/vyper/pull/2468>`_)
* Add -o CLI flag to redirect output to a file (`#2452 <https://github.com/vyperlang/vyper/pull/2452>`_)
* Other docs updates (`#2450 <https://github.com/vyperlang/vyper/pull/2450>`_)

Fixes:

* _abi_encode builtin evaluates arguments multiple times (`#2459 <https://github.com/vyperlang/vyper/issues/2459>`_)
* ABI length is too short for nested tuples (`#2458 <https://github.com/vyperlang/vyper/issues/2458>`_)
* Returndata is not clamped for certain numeric types (`#2454 <https://github.com/vyperlang/vyper/issues/2454>`_)
* __default__ functions do not respect nonreentrancy keys (`#2455 <https://github.com/vyperlang/vyper/issues/2455>`_)
* Clamps for bytestrings in initcode are broken (`#2456 <https://github.com/vyperlang/vyper/issues/2456>`_)
* Missing clamps for decimal args in external functions (`GHSA-c7pr-343r-5c46 <https://github.com/vyperlang/vyper/security/advisories/GHSA-c7pr-343r-5c46>`_)
* Memory corruption when returning a literal struct with a private function call inside of it (`GHSA-xv8x-pr4h-73jv <https://github.com/vyperlang/vyper/security/advisories/GHSA-xv8x-pr4h-73jv>`_)

Special thanks to contributions from @skellet0r and @benjyz for this release!


v0.2.16
*******

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

__version__ = "0.2.16"
__version__ = "0.3.0"

extras_require = {
"test": [
Expand Down
188 changes: 188 additions & 0 deletions tests/parser/functions/test_return_struct.py
Expand Up @@ -84,3 +84,191 @@ def pub6() -> Foo:
assert c.pub4() == (7, 8)
assert c.pub5(foo) == foo
assert c.pub6() == foo

def test_self_call_in_return_struct(get_contract):
code = """
struct Foo:
a: uint256
b: uint256
c: uint256
d: uint256
e: uint256
@internal
def _foo() -> uint256:
a: uint256[10] = [6,7,8,9,10,11,12,13,14,15]
return 3
@external
def foo() -> Foo:
return Foo({a:1, b:2, c:self._foo(), d:4, e:5})
"""

c = get_contract(code)

assert c.foo() == (1, 2, 3, 4, 5)


def test_call_in_call(get_contract):
code = """
struct Foo:
a: uint256
b: uint256
c: uint256
d: uint256
e: uint256
@internal
def _foo(a: uint256, b: uint256, c: uint256) -> Foo:
return Foo({a:1, b:a, c:b, d:c, e:5})
@internal
def _foo2() -> uint256:
a: uint256[10] = [6,7,8,9,10,11,12,13,15,16]
return 4
@external
def foo() -> Foo:
return self._foo(2, 3, self._foo2())
"""

c = get_contract(code)

assert c.foo() == (1, 2, 3, 4, 5)


def test_nested_calls_in_struct_return(get_contract):
code = """
struct Foo:
a: uint256
b: uint256
c: uint256
d: uint256
e: uint256
struct Bar:
a: uint256
b: uint256
@internal
def _bar(a: uint256, b: uint256, c: uint256) -> Bar:
return Bar({a:415, b:3})
@internal
def _foo2(a: uint256) -> uint256:
b: uint256[10] = [6,7,8,9,10,11,12,13,14,15]
return 99
@internal
def _foo3(a: uint256, b: uint256) -> uint256:
c: uint256[10] = [14,15,16,17,18,19,20,21,22,23]
return 42
@internal
def _foo4() -> uint256:
c: uint256[10] = [14,15,16,17,18,19,20,21,22,23]
return 4
@external
def foo() -> Foo:
return Foo({
a:1,
b:2,
c:self._bar(6, 7, self._foo2(self._foo3(9, 11))).b,
d:self._foo4(),
e:5
})
"""

c = get_contract(code)

assert c.foo() == (1, 2, 3, 4, 5)


def test_external_call_in_return_struct(get_contract):
code = """
struct Bar:
a: uint256
b: uint256
@view
@external
def bar() -> Bar:
return Bar({a:3, b:4})
"""

code2 = """
struct Foo:
a: uint256
b: uint256
c: uint256
d: uint256
e: uint256
struct Bar:
a: uint256
b: uint256
interface IBar:
def bar() -> Bar: view
@external
def foo(addr: address) -> Foo:
return Foo({
a:1,
b:2,
c:IBar(addr).bar().a,
d:4,
e:5
})
"""

c = get_contract(code)
c2 = get_contract(code2)

assert c2.foo(c.address) == (1, 2, 3, 4, 5)


def test_nested_external_call_in_return_struct(get_contract):
code = """
struct Bar:
a: uint256
b: uint256
@view
@external
def bar() -> Bar:
return Bar({a:3, b:4})
@view
@external
def baz(x: uint256) -> uint256:
return x+1
"""

code2 = """
struct Foo:
a: uint256
b: uint256
c: uint256
d: uint256
e: uint256
struct Bar:
a: uint256
b: uint256
interface IBar:
def bar() -> Bar: view
def baz(a: uint256) -> uint256: view
@external
def foo(addr: address) -> Foo:
return Foo({
a:1,
b:2,
c:IBar(addr).bar().a,
d:4,
e:IBar(addr).baz(IBar(addr).bar().b)
})
"""

c = get_contract(code)
c2 = get_contract(code2)

assert c2.foo(c.address) == (1, 2, 3, 4, 5)

0 comments on commit 8a23feb

Please sign in to comment.