Skip to content

Commit

Permalink
Merge branch 'master' into docs/v0.4.1b1
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper authored Jan 20, 2025
2 parents b6060b5 + 4d693b7 commit 1a92b67
Show file tree
Hide file tree
Showing 144 changed files with 7,899 additions and 1,381 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Bug Report
about: Any general feedback or bug reports about the Vyper Compiler. No new features proposals.
labels: ["needs triage"]
---

### Version Information
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/vip.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Vyper Improvement Proposal (VIP)
about: This is the suggested template for new VIPs.
labels: ["needs triage"]
---
## Simple Summary
"If you can't explain it simply, you don't understand it well enough." Provide a simplified and layman-accessible explanation of the VIP.
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
# need to fetch unshallow so that setuptools_scm can infer the version
fetch-depth: 0

# debug
- name: Git shorthash
run: git rev-parse --short HEAD

- name: Python
uses: actions/setup-python@v5
with:
Expand All @@ -45,8 +49,9 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: vyper-${{ runner.os }}
path: dist/vyper.*

windows-build:
Expand All @@ -60,6 +65,10 @@ jobs:
# need to fetch unshallow so that setuptools_scm can infer the version
fetch-depth: 0

# debug
- name: Git shorthash
run: git rev-parse --short HEAD

- name: Python
uses: actions/setup-python@v5
with:
Expand All @@ -73,8 +82,9 @@ jobs:
./make.cmd freeze
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: vyper-${{ runner.os }}
path: dist/vyper.*

publish-release-assets:
Expand All @@ -84,14 +94,13 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: artifacts/
merge-multiple: true

- name: Upload assets
# fun - artifacts are downloaded into "artifact/".
# TODO: this needs to be tested when upgrading to upload-artifact v4
working-directory: artifacts/artifact
working-directory: artifacts
run: |
set -Eeuxo pipefail
for BIN_NAME in $(ls)
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
# docs: documentation
# test: test suite
# lang: language changes
# stdlib: changes to the stdlib
# ux: language changes (UX)
# parser: parser changes
# tool: integration
# ir: (old) IR/codegen changes
# codegen: lowering from vyper AST to codegen
Expand All @@ -43,7 +45,9 @@ jobs:
docs
test
lang
stdlib
ux
parser
tool
ir
codegen
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/release-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
# fetch unshallow so commit hash matches github release.
# see https://github.com/vyperlang/vyper/blob/8f9a8cac49aafb3fbc9dde78f0f6125c390c32f0/.github/workflows/build.yml#L27-L32
fetch-depth: 0

# debug
- name: Git shorthash
run: git rev-parse --short HEAD

- name: Python
uses: actions/setup-python@v5
Expand Down
97 changes: 85 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
# modes across all python versions - one is enough
- python-version: ["3.10", "310"]
- python-version: ["3.12", "312"]
- python-version: ["3.13", "313"]

# os-specific rules
- os: windows
Expand Down Expand Up @@ -148,16 +149,17 @@ jobs:
--evm-backend ${{ matrix.evm-backend || 'revm' }}
${{ matrix.debug && '--enable-compiler-debug-mode' || '' }}
${{ matrix.experimental-codegen && '--experimental-codegen' || '' }}
--cov-branch
--cov-report xml:coverage.xml
--cov-config=setup.cfg
--cov=vyper
tests/
- name: Upload Coverage
uses: codecov/codecov-action@v3
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
name: coverage-files-${{ github.job }}-${{ strategy.job-index }}
include-hidden-files: true
path: .coverage
if-no-files-found: error

core-tests-success:
if: always()
Expand Down Expand Up @@ -208,16 +210,17 @@ jobs:
--splits 120 \
--group ${{ matrix.group }} \
--splitting-algorithm least_duration \
--cov-branch \
--cov-report xml:coverage.xml \
--cov-config=setup.cfg \
--cov=vyper \
tests/
- name: Upload Coverage
uses: codecov/codecov-action@v3
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
name: coverage-files-${{ github.job }}-${{ strategy.job-index }}
include-hidden-files: true
path: .coverage
if-no-files-found: error

slow-tests-success:
if: always()
Expand All @@ -230,3 +233,73 @@ jobs:
- name: Check slow tests all succeeded
if: ${{ needs.fuzzing.result != 'success' }}
run: exit 1

coverage-report:
# Consolidate code coverage using `coverage combine` and
# call coverage report with fail-under=90
runs-on: ubuntu-latest
needs: [tests, fuzzing]

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"

- name: Install coverage
run: pip install coverage

- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage-files-*
path: coverage-files

- name: Combine coverage
run: |
coverage combine coverage-files/**/.coverage
- name: Coverage report
# coverage report and fail if coverage is too low
run: |
coverage report --fail-under=90
- name: Generate coverage.xml
run: |
coverage xml
- name: Upload coverage sqlite artifact
# upload coverage sqlite db for debugging
uses: actions/upload-artifact@v4
with:
name: coverage-sqlite
include-hidden-files: true
path: .coverage
if-no-files-found: error

- name: Upload coverage.xml
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
if-no-files-found: error

upload-coverage:
# upload coverage to the codecov app
runs-on: ubuntu-latest
needs: [coverage-report]

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: coverage-xml

- name: Upload Coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Build Status](https://github.com/vyperlang/vyper/workflows/Test/badge.svg)](https://github.com/vyperlang/vyper/actions/workflows/test.yml)
[![Documentation Status](https://readthedocs.org/projects/vyper/badge/?version=latest)](http://docs.vyperlang.org/en/latest/?badge=latest "ReadTheDocs")
[![Discord](https://img.shields.io/discord/969926564286459934.svg?label=%23vyper)](https://discord.gg/6tw7PTM7C2)
[![Telegram](https://img.shields.io/badge/Vyperholics🐍-Telegram-blue)](https://t.me/vyperlang)

[![PyPI](https://badge.fury.io/py/vyper.svg)](https://pypi.org/project/vyper "PyPI")
[![Docker](https://img.shields.io/docker/cloud/build/vyperlang/vyper)](https://hub.docker.com/r/vyperlang/vyper "DockerHub")
Expand Down Expand Up @@ -49,7 +50,7 @@ be a bit behind the latest version found in the master branch of this repository

```bash
make dev-init
python setup.py test
./quicktest.sh -m "not fuzzing"
```

## Developing (working on the compiler)
Expand Down
2 changes: 1 addition & 1 deletion docs/built-in-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ Utilities
>>> ExampleContract.foo()
0xa9059cbb

.. py:function:: abi_encode(*args, ensure_tuple: bool = True) -> Bytes[<depends on input>]
.. py:function:: abi_encode(*args, ensure_tuple: bool = True, method_id: Bytes[4] = None) -> Bytes[<depends on input>]
Takes a variable number of args as input, and returns the ABIv2-encoded bytestring. Used for packing arguments to raw_call, EIP712 and other cases where a consistent and efficient serialization method is needed.
Once this function has seen more use we provisionally plan to put it into the ``ethereum.abi`` namespace.
Expand Down
30 changes: 26 additions & 4 deletions docs/compiling-a-contract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Include the ``-f`` flag to specify which output formats to return. Use ``vyper -

.. code:: shell
$ vyper -f abi,abi_python,bytecode,bytecode_runtime,blueprint_bytecode,interface,external_interface,ast,annotated_ast,integrity,ir,ir_json,ir_runtime,asm,opcodes,opcodes_runtime,source_map,source_map_runtime,archive,solc_json,method_identifiers,userdoc,devdoc,metadata,combined_json,layout yourFileName.vy
$ vyper -f abi,abi_python,bb,bb_runtime,bytecode,bytecode_runtime,blueprint_bytecode,cfg,cfg_runtime,interface,external_interface,ast,annotated_ast,integrity,ir,ir_json,ir_runtime,asm,opcodes,opcodes_runtime,source_map,source_map_runtime,archive,solc_json,method_identifiers,userdoc,devdoc,metadata,combined_json,layout yourFileName.vy
.. note::
The ``opcodes`` and ``opcodes_runtime`` output of the compiler has been returning incorrect opcodes since ``0.2.0`` due to a lack of 0 padding (patched via `PR 3735 <https://github.com/vyperlang/vyper/pull/3735>`_). If you rely on these functions for debugging, please use the latest patched versions.
Expand Down Expand Up @@ -106,7 +106,7 @@ Online Compilers
Try VyperLang!
-----------------

`Try VyperLang! <https://try.vyperlang.org>`_ is a JupterHub instance hosted by the Vyper team as a sandbox for developing and testing contracts in Vyper. It requires github for login, and supports deployment via the browser.
`Try VyperLang! <https://try.vyperlang.org>`_ is a JupyterHub instance hosted by the Vyper team as a sandbox for developing and testing contracts in Vyper. It requires github for login, and supports deployment via the browser.

Remix IDE
---------
Expand Down Expand Up @@ -134,6 +134,11 @@ In codesize optimized mode, the compiler will try hard to minimize codesize by
* out-lining code, and
* using more loops for data copies.

Enabling Experimental Code Generation
===========================

When compiling, you can use the CLI flag ``--experimental-codegen`` or its alias ``--venom`` to activate the new `Venom IR <https://github.com/vyperlang/vyper/blob/master/vyper/venom/README.md>`_.
Venom IR is inspired by LLVM IR and enables new advanced analysis and optimizations.

.. _evm-version:

Expand Down Expand Up @@ -198,7 +203,7 @@ The following is a list of supported EVM versions, and changes in the compiler i
Integrity Hash
==============

To help tooling detect whether two builds are the same, Vyper provides the ``-f integrity`` output, which outputs the integrity hash of a contract. The integrity hash is recursively defined as the sha256 of the source code with the integrity hashes of its dependencies (imports).
To help tooling detect whether two builds are the same, Vyper provides the ``-f integrity`` output, which outputs the integrity hash of a contract. The integrity hash is recursively defined as the sha256 of the source code with the integrity hashes of its dependencies (imports) and storage layout overrides (if provided).

.. _vyper-archives:

Expand All @@ -214,15 +219,17 @@ A Vyper archive is a compileable bundle of input sources and settings. Technical
├── compilation_targets
├── compiler_version
├── integrity
├── settings.json
├── searchpaths
└── settings.json
└── storage_layout.json [OPTIONAL]

* ``cli_settings.txt`` is a text representation of the settings that were used on the compilation run that generated this archive.
* ``compilation_targets`` is a newline separated list of compilation targets. Currently only one compilation is supported
* ``compiler_version`` is a text representation of the compiler version used to generate this archive
* ``integrity`` is the :ref:`integrity hash <integrity-hash>` of the input contract
* ``searchpaths`` is a newline-separated list of the search paths used on this compilation run
* ``settings.json`` is a json representation of the settings used on this compilation run. It is 1:1 with ``cli_settings.txt``, but both are provided as they are convenient for different workflows (typically, manually vs automated).
* ``storage_layout.json`` is a json representation of the storage layout overrides to be used on this compilation run. It is optional.

A Vyper archive file can be produced by requesting the ``-f archive`` output format. The compiler can also produce the archive in base64 encoded form using the ``--base64`` flag. The Vyper compiler can accept both ``.vyz`` and base64-encoded Vyper archives directly as input.

Expand Down Expand Up @@ -276,6 +283,14 @@ The following example describes the expected input format of ``vyper-json``. (Co
}
},
// Optional
// Storage layout overrides for the contracts that are compiled
"storage_layout_overrides": {
"contracts/foo.vy": {
"a": {"type": "uint256", "slot": 1, "n_slots": 1},
"b": {"type": "uint256", "slot": 0, "n_slots": 1},
}
},
// Optional
"settings": {
"evmVersion": "cancun", // EVM version to compile for. Can be london, paris, shanghai or cancun (default).
// optional, optimization mode
Expand Down Expand Up @@ -359,6 +374,13 @@ The following example describes the output format of ``vyper-json``. Comments ar
"formattedMessage": "line 5:11 Unsupported type conversion: int128 to bool"
}
],
// Optional: not present if there are no storage layout overrides
"storage_layout_overrides": {
"contracts/foo.vy": {
"a": {"type": "uint256", "slot": 1, "n_slots": 1},
"b": {"type": "uint256", "slot": 0, "n_slots": 1},
}
},
// This contains the file-level outputs. Can be limited/filtered by the outputSelection settings.
"sources": {
"source_file.vy": {
Expand Down
Loading

0 comments on commit 1a92b67

Please sign in to comment.