mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 14:31:05 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52bf16a383 | |||
| cf2fd2f1e8 | |||
| 5003f3e9ac | |||
| 431b5a2ce5 | |||
| ad3315346c | |||
| 516f79ee0f | |||
| 9f5443b6d6 | |||
| 0dafc779ce |
@@ -0,0 +1,165 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import requests
|
||||
|
||||
def validate_github_token():
|
||||
"""Validate that GITHUB_TOKEN environment variable is set."""
|
||||
if 'GITHUB_TOKEN' not in os.environ:
|
||||
print("Error: GITHUB_TOKEN environment variable is not set.")
|
||||
sys.exit(1)
|
||||
|
||||
def fetch_release_data(repo, tag):
|
||||
"""Fetch release data from GitHub API."""
|
||||
url = f"https://api.github.com/repos/{repo}/releases/tags/{tag}"
|
||||
headers = {
|
||||
'Authorization': f"Bearer {os.environ['GITHUB_TOKEN']}",
|
||||
'Accept': 'application/vnd.github+json',
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except requests.RequestException as e:
|
||||
print(f"Error fetching release data: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
def fetch_checksum_file(release_data):
|
||||
"""
|
||||
Fetch the checksum.txt file from the release assets
|
||||
and parse it into a dictionary mapping file names to their SHA256 checksums.
|
||||
"""
|
||||
checksums = {}
|
||||
|
||||
# Find the checksum.txt asset URL
|
||||
checksum_asset = None
|
||||
for asset in release_data['assets']:
|
||||
if asset['name'] == 'checksums.txt':
|
||||
checksum_asset = asset
|
||||
break
|
||||
|
||||
if not checksum_asset:
|
||||
print("Warning: checksum.txt file not found in release assets.")
|
||||
return checksums
|
||||
|
||||
# Download the checksum file
|
||||
headers = {
|
||||
'Authorization': f"Bearer {os.environ['GITHUB_TOKEN']}",
|
||||
'Accept': 'application/octet-stream'
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.get(checksum_asset['browser_download_url'], headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
# Parse checksum file
|
||||
for line in response.text.splitlines():
|
||||
if line.strip():
|
||||
checksum, filename = line.strip().split(None, 1)
|
||||
checksums[filename] = checksum
|
||||
|
||||
return checksums
|
||||
except requests.RequestException as e:
|
||||
print(f"Error fetching checksum file: {e}")
|
||||
return checksums
|
||||
except Exception as e:
|
||||
print(f"Error parsing checksum file: {e}")
|
||||
return checksums
|
||||
|
||||
def extract_build_hash(target_commitish):
|
||||
"""Extract the first 8 characters of the commit hash."""
|
||||
return f"commit.{target_commitish[:8]}"
|
||||
|
||||
def generate_asset_json(release_data, asset, checksums):
|
||||
"""Generate JSON for a specific asset."""
|
||||
version = release_data['tag_name'].lstrip('v')
|
||||
build = extract_build_hash(release_data['target_commitish'])
|
||||
long_version = f"{version}+{build}"
|
||||
|
||||
# Get SHA256 checksum if available
|
||||
sha256 = checksums.get(asset['name'], "")
|
||||
|
||||
return {
|
||||
"name": asset['name'],
|
||||
"version": version,
|
||||
"build": build,
|
||||
"longVersion": long_version,
|
||||
"url": asset['browser_download_url'],
|
||||
"sha256": sha256,
|
||||
"firstSolcVersion": os.environ.get("FIRST_SOLC_VERSION", ""),
|
||||
"lastSolcVersion": os.environ.get("LAST_SOLC_VERSION", "")
|
||||
}
|
||||
|
||||
def save_platform_json(platform_folder, asset_json, tag):
|
||||
"""Save asset JSON and update list.json for a specific platform."""
|
||||
# Create platform folder if it doesn't exist
|
||||
os.makedirs(platform_folder, exist_ok=True)
|
||||
|
||||
# Update or create list.json
|
||||
list_file_path = os.path.join(platform_folder, "list.json")
|
||||
|
||||
if os.path.exists(list_file_path):
|
||||
with open(list_file_path, 'r') as f:
|
||||
try:
|
||||
list_data = json.load(f)
|
||||
except json.JSONDecodeError:
|
||||
list_data = {"builds": [], "releases": {}, "latestRelease": ""}
|
||||
else:
|
||||
list_data = {"builds": [], "releases": {}, "latestRelease": ""}
|
||||
|
||||
# Remove any existing entry with the same path
|
||||
list_data['builds'] = [
|
||||
build for build in list_data['builds']
|
||||
if build['version'] != asset_json['version']
|
||||
]
|
||||
# Add the new build
|
||||
list_data['builds'].append(asset_json)
|
||||
|
||||
# Update releases
|
||||
version = asset_json['version']
|
||||
list_data['releases'][version] = f"{asset_json['name']}+{asset_json['longVersion']}"
|
||||
|
||||
# Update latest release
|
||||
list_data['latestRelease'] = version
|
||||
|
||||
with open(list_file_path, 'w') as f:
|
||||
json.dump(list_data, f, indent=4)
|
||||
|
||||
def main():
|
||||
# Validate arguments
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: python script.py <repo> <tag>")
|
||||
sys.exit(1)
|
||||
|
||||
repo, tag = sys.argv[1], sys.argv[2]
|
||||
|
||||
# Validate GitHub token
|
||||
validate_github_token()
|
||||
|
||||
# Fetch release data
|
||||
release_data = fetch_release_data(repo, tag)
|
||||
|
||||
# Fetch checksums
|
||||
checksums = fetch_checksum_file(release_data)
|
||||
|
||||
# Mapping of asset names to platform folders
|
||||
platform_mapping = {
|
||||
'resolc-x86_64-unknown-linux-musl': 'linux',
|
||||
'resolc-universal-apple-darwin': 'macos',
|
||||
'resolc-x86_64-pc-windows-msvc.exe': 'windows',
|
||||
'resolc_web.js': 'wasm'
|
||||
}
|
||||
|
||||
# Process each asset
|
||||
for asset in release_data['assets']:
|
||||
platform_name = platform_mapping.get(asset['name'])
|
||||
if platform_name:
|
||||
platform_folder = os.path.join(platform_name)
|
||||
asset_json = generate_asset_json(release_data, asset, checksums)
|
||||
save_platform_json(platform_folder, asset_json, tag)
|
||||
print(f"Processed {asset['name']} for {platform_name}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,64 @@
|
||||
name: Generate JSON for resolc-bin
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
generateJson:
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(github.event.release.tag_name, 'llvm') == false
|
||||
environment: tags
|
||||
env:
|
||||
# the token is needed for json_generator.py
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: tmp
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: paritytech/resolc-bin
|
||||
path: resolc-bin
|
||||
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ secrets.REVIVE_JSON_APP_ID }}
|
||||
private-key: ${{ secrets.REVIVE_JSON_APP_KEY }}
|
||||
owner: paritytech
|
||||
repositories: resolc-bin
|
||||
|
||||
- name: Generate json and push
|
||||
env:
|
||||
TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
APP_NAME: "paritytech-revive-json"
|
||||
Green: "\e[32m"
|
||||
NC: "\e[0m"
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y wget
|
||||
wget https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/resolc-x86_64-unknown-linux-musl
|
||||
chmod +x resolc-x86_64-unknown-linux-musl
|
||||
export FIRST_SOLC_VERSION=$(./resolc-x86_64-unknown-linux-musl --supported-solc-versions | cut -f 1 -d "," | tr -d ">=")
|
||||
export LAST_SOLC_VERSION=$(./resolc-x86_64-unknown-linux-musl --supported-solc-versions | cut -f 2 -d "," | tr -d "<=")
|
||||
|
||||
cd resolc-bin
|
||||
python ../tmp/.github/scripts/json_generator.py ${GITHUB_REPOSITORY} ${{ github.event.release.tag_name }}
|
||||
|
||||
echo "${Green}Add new remote with gh app token${NC}"
|
||||
git remote set-url origin $(git config remote.origin.url | sed "s/github.com/${APP_NAME}:${TOKEN}@github.com/g")
|
||||
|
||||
echo "${Green}Remove http section that causes issues with gh app auth token${NC}"
|
||||
sed -i.bak '/\[http/d' ./.git/config
|
||||
sed -i.bak '/extraheader/d' ./.git/config
|
||||
|
||||
git config user.email "ci@parity.io"
|
||||
git config user.name "${APP_NAME}"
|
||||
|
||||
git add .
|
||||
git commit -m "Update json"
|
||||
git push origin main
|
||||
|
||||
echo "::notice::info.list files were successfully published to https://github.com/paritytech/resolc-bin"
|
||||
@@ -1,11 +1,12 @@
|
||||
name: Release
|
||||
name: Build & Release
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
tags:
|
||||
- "v*"
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
types: [opened, synchronize, labeled, unlabeled]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
@@ -17,41 +18,44 @@ env:
|
||||
|
||||
jobs:
|
||||
check-version-changed:
|
||||
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'release-test')
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
CURRENT_TAG: ${{ github.ref_name }}
|
||||
outputs:
|
||||
TAG: ${{ steps.versions.outputs.TAG }}
|
||||
PKG_VER: ${{ steps.versions.outputs.PKG_VER }}
|
||||
RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check Versions
|
||||
# Check that tag and version in Cargo.toml match
|
||||
- name: Check versions
|
||||
id: versions
|
||||
run: |
|
||||
export CURRENT_TAG=$(git describe --tags --abbrev=0 --exclude "llvm-*")
|
||||
if [[ $CURRENT_TAG == 'main' ]];
|
||||
then
|
||||
echo "::notice::Tag $CURRENT_TAG is not a release tag, skipping the check in the main branch";
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $CURRENT_TAG != "v"* ]];
|
||||
then
|
||||
echo "::notice::Tag $CURRENT_TAG is not a release tag, skipping the check in a PR";
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export PKG_VER=v$(cat Cargo.toml | grep -A 5 package] | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d " ")
|
||||
echo "Current tag $CURRENT_TAG"
|
||||
echo "Package version $PKG_VER"
|
||||
#
|
||||
echo "PKG_VER=$PKG_VER" >> $GITHUB_OUTPUT
|
||||
if [[ $CURRENT_TAG == $PKG_VER ]];
|
||||
if [[ $CURRENT_TAG != $PKG_VER ]];
|
||||
then
|
||||
echo "Tag is up to date. Nothing to do.";
|
||||
export TAG=old;
|
||||
else
|
||||
echo "Tag was updated.";
|
||||
export TAG=new;
|
||||
echo "::error::Tag $CURRENT_TAG doesn't match package version $PKG_VER in Cargo.toml, please fix";
|
||||
exit 1
|
||||
fi
|
||||
echo "TAG=$TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
# Generating release notes early, in order to avoid checkout at the last step
|
||||
export RELEASE_NOTES="$(sed '/^## '${PKG_VER}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
|
||||
export RELEASE_NOTES="$(sed '/^## '${CURRENT_TAG}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
|
||||
|
||||
echo "Release notes:"
|
||||
echo "$RELEASE_NOTES"
|
||||
@@ -83,7 +87,6 @@ jobs:
|
||||
- target: x86_64-pc-windows-msvc
|
||||
type: native
|
||||
runner: windows-2022
|
||||
if: ${{ needs.check-version-changed.outputs.TAG == 'new' }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
needs: [check-version-changed]
|
||||
steps:
|
||||
@@ -137,9 +140,10 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
build-wasm:
|
||||
if: ${{ needs.check-version-changed.outputs.TAG == 'new' }}
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [check-version-changed]
|
||||
env:
|
||||
RELEASE_RESOLC_WASM_URI: https://github.com/paritytech/revive-workflow-test/releases/download/${{ github.ref_name }}/resolc.wasm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
@@ -226,11 +230,10 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
create-release:
|
||||
if: github.event_name != 'pull_request'
|
||||
if: startsWith(github.ref_name, 'v')
|
||||
needs: [check-version-changed, build-wasm]
|
||||
runs-on: macos-14
|
||||
permissions:
|
||||
contents: write
|
||||
environment: tags
|
||||
steps:
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -246,6 +249,21 @@ jobs:
|
||||
chmod +x resolc-x86_64-unknown-linux-musl
|
||||
chmod +x resolc-universal-apple-darwin
|
||||
|
||||
- name: Create sha-256 checksum
|
||||
run: |
|
||||
shasum -a 256 resolc-x86_64-unknown-linux-musl > checksums.txt
|
||||
shasum -a 256 resolc-universal-apple-darwin >> checksums.txt
|
||||
shasum -a 256 resolc-x86_64-pc-windows-msvc.exe >> checksums.txt
|
||||
shasum -a 256 resolc.js >> checksums.txt
|
||||
shasum -a 256 resolc.wasm >> checksums.txt
|
||||
shasum -a 256 resolc_web.js >> checksums.txt
|
||||
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ secrets.REVIVE_RELEASE_APP_ID }}
|
||||
private-key: ${{ secrets.REVIVE_RELEASE_APP_KEY }}
|
||||
|
||||
- name: create-release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
@@ -255,9 +273,10 @@ jobs:
|
||||
|
||||
## Note for macOS Users
|
||||
The macOS binary is unsigned and it needs to be made runnable using `xattr -c resolc-universal-apple-darwin`.
|
||||
tag_name: ${{ needs.check-version-changed.outputs.PKG_VER }}
|
||||
name: ${{ needs.check-version-changed.outputs.PKG_VER }}
|
||||
draft: true
|
||||
tag_name: ${{ github.ref_name }}
|
||||
name: ${{ github.ref_name }}
|
||||
prerelease: true
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
target_commitish: ${{ github.sha }}
|
||||
files: |
|
||||
resolc-x86_64-unknown-linux-musl
|
||||
@@ -266,3 +285,4 @@ jobs:
|
||||
resolc.js
|
||||
resolc.wasm
|
||||
resolc_web.js
|
||||
checksums.txt
|
||||
|
||||
+14
-1
@@ -6,6 +6,19 @@ This is a development pre-release.
|
||||
|
||||
Supported `polkadot-sdk` rev:`c29e72a8628835e34deb6aa7db9a78a2e4eabcee`
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
- Constructors avoid storing zero sized immutable data on exit.
|
||||
|
||||
## v0.1.0-dev.13
|
||||
|
||||
This is a development pre-release.
|
||||
|
||||
Supported `polkadot-sdk` rev:`c29e72a8628835e34deb6aa7db9a78a2e4eabcee`
|
||||
|
||||
### Added
|
||||
- Support for solc v0.8.29
|
||||
- Decouples the solc JSON-input-output type definitions from the Solidity fronted and expose them via a dedicated crate.
|
||||
@@ -14,7 +27,7 @@ Supported `polkadot-sdk` rev:`c29e72a8628835e34deb6aa7db9a78a2e4eabcee`
|
||||
|
||||
### Changed
|
||||
- Storage keys and values are big endian. This was a pre-mature optimization because for the contract itself it this is a no-op and thus not observable. However we should consider the storage layout as part of the contract ABI. The endianness of transient storage values are still kept as-is.
|
||||
- Runner `resolc` using webkit is no longer supported.
|
||||
- Running `resolc` using webkit is no longer supported.
|
||||
|
||||
### Fixed
|
||||
- A missing byte swap for the create2 salt value.
|
||||
|
||||
Generated
+17
-17
@@ -4553,7 +4553,7 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
|
||||
|
||||
[[package]]
|
||||
name = "lld-sys"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -8266,7 +8266,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-benchmarks"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"criterion",
|
||||
@@ -8278,18 +8278,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-build-utils"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
|
||||
[[package]]
|
||||
name = "revive-builtins"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"revive-build-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revive-common"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde",
|
||||
@@ -8299,7 +8299,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-differential"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"alloy-genesis",
|
||||
"alloy-primitives",
|
||||
@@ -8312,7 +8312,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-integration"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-sol-types",
|
||||
@@ -8328,7 +8328,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-linker"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"libc",
|
||||
@@ -8340,7 +8340,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-llvm-builder"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
@@ -8362,7 +8362,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-llvm-context"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hex",
|
||||
@@ -8384,7 +8384,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-runner"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"hex",
|
||||
@@ -8400,7 +8400,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-runtime-api"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"inkwell",
|
||||
@@ -8410,7 +8410,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-solc-json-interface"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"rayon",
|
||||
@@ -8422,7 +8422,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-solidity"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -8449,7 +8449,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revive-stdlib"
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
dependencies = [
|
||||
"inkwell",
|
||||
"revive-build-utils",
|
||||
@@ -11117,9 +11117,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.43.0"
|
||||
version = "1.44.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e"
|
||||
checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
|
||||
+15
-15
@@ -3,7 +3,7 @@ resolver = "2"
|
||||
members = ["crates/*"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0-dev.12"
|
||||
version = "0.1.0-dev.13"
|
||||
authors = [
|
||||
"Cyrill Leutwiler <cyrill@parity.io>",
|
||||
"Parity Technologies <admin@parity.io>",
|
||||
@@ -14,20 +14,20 @@ repository = "https://github.com/paritytech/revive"
|
||||
rust-version = "1.81.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
revive-benchmarks = { version = "0.1.0-dev.12", path = "crates/benchmarks" }
|
||||
revive-builtins = { version = "0.1.0-dev.12", path = "crates/builtins" }
|
||||
revive-common = { version = "0.1.0-dev.12", path = "crates/common" }
|
||||
revive-differential = { version = "0.1.0-dev.12", path = "crates/differential" }
|
||||
revive-integration = { version = "0.1.0-dev.12", path = "crates/integration" }
|
||||
revive-linker = { version = "0.1.0-dev.12", path = "crates/linker" }
|
||||
lld-sys = { version = "0.1.0-dev.12", path = "crates/lld-sys" }
|
||||
revive-llvm-context = { version = "0.1.0-dev.12", path = "crates/llvm-context" }
|
||||
revive-runtime-api = { version = "0.1.0-dev.12", path = "crates/runtime-api" }
|
||||
revive-runner = { version = "0.1.0-dev.12", path = "crates/runner" }
|
||||
revive-solc-json-interface = { version = "0.1.0-dev.12", path = "crates/solc-json-interface" }
|
||||
revive-solidity = { version = "0.1.0-dev.12", path = "crates/solidity" }
|
||||
revive-stdlib = { version = "0.1.0-dev.12", path = "crates/stdlib" }
|
||||
revive-build-utils = { version = "0.1.0-dev.12", path = "crates/build-utils" }
|
||||
revive-benchmarks = { version = "0.1.0-dev.13", path = "crates/benchmarks" }
|
||||
revive-builtins = { version = "0.1.0-dev.13", path = "crates/builtins" }
|
||||
revive-common = { version = "0.1.0-dev.13", path = "crates/common" }
|
||||
revive-differential = { version = "0.1.0-dev.13", path = "crates/differential" }
|
||||
revive-integration = { version = "0.1.0-dev.13", path = "crates/integration" }
|
||||
revive-linker = { version = "0.1.0-dev.13", path = "crates/linker" }
|
||||
lld-sys = { version = "0.1.0-dev.13", path = "crates/lld-sys" }
|
||||
revive-llvm-context = { version = "0.1.0-dev.13", path = "crates/llvm-context" }
|
||||
revive-runtime-api = { version = "0.1.0-dev.13", path = "crates/runtime-api" }
|
||||
revive-runner = { version = "0.1.0-dev.13", path = "crates/runner" }
|
||||
revive-solc-json-interface = { version = "0.1.0-dev.13", path = "crates/solc-json-interface" }
|
||||
revive-solidity = { version = "0.1.0-dev.13", path = "crates/solidity" }
|
||||
revive-stdlib = { version = "0.1.0-dev.13", path = "crates/stdlib" }
|
||||
revive-build-utils = { version = "0.1.0-dev.13", path = "crates/build-utils" }
|
||||
|
||||
hex = "0.4.3"
|
||||
cc = "1.2"
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ RUN make install-llvm-builder
|
||||
RUN revive-llvm --target-env musl clone
|
||||
RUN revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang
|
||||
|
||||
FROM messense/rust-musl-cross:x86_64-musl AS resolc-builder
|
||||
FROM messense/rust-musl-cross@sha256:68b86bc7cb2867259e6b233415a665ff4469c28b57763e78c3bfea1c68091561 AS resolc-builder
|
||||
WORKDIR /opt/revive
|
||||
|
||||
RUN apt update && \
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
install: install-bin install-npm
|
||||
|
||||
install-bin:
|
||||
cargo install --path crates/solidity
|
||||
cargo install --locked --path crates/solidity
|
||||
|
||||
install-npm:
|
||||
npm install && npm fund
|
||||
|
||||
+8
-5
@@ -4,11 +4,14 @@ Prior to the first stable release we neither have formal release processes nor d
|
||||
|
||||
To create a new pre-release:
|
||||
|
||||
1. Create a release PR which updates the `-dev.X` versions in the workspace `Cargo.toml` and updates the `CHANGELOG.md` accordingly. Add the `release-test` label to trigger the release workflows.
|
||||
2. If the CI passes, merge the release PR. The release workflow will attempt to build and publish a new release whenever the latest git tag does not match the cargo package version.
|
||||
3. Wait for the `Release` workflow to finish. If the workflow fails after the `build-linux-all` step, check if a tag has been created and delete it before restarting or pushing updates. Note: It's more convenient to debug the release workflow in a fork (the fork has to be under the `paritytech` org to access `parity-large` runners).
|
||||
4. Check draft release on [Releases page](https://github.com/paritytech/revive/releases) and publish (should contain `resolc.js`, `resolc.wasm`, `resolc-web.js`, and `resolc-static-linux` release assets)
|
||||
5. Update the [contract-docs](https://github.com/paritytech/contract-docs/) accordingly
|
||||
1. Create a release PR which updates the `-dev.X` versions in the workspace `Cargo.toml` and updates the `CHANGELOG.md` accordingly.
|
||||
2. If the CI passes, merge the release PR.
|
||||
3. Push a tag that has the same `-dev.X` version as in `Cargo.toml`
|
||||
4. The release workflow will attempt to build and publish a new pre-release if the latest tag does match the cargo package version.
|
||||
5. Wait for the `Release` workflow to finish. It should create the pre-release with the same `-dev.X` name.
|
||||
6. Check that pre-release was created on the [Releases page](https://github.com/paritytech/revive/releases) with all artifacts.
|
||||
7. After the release is published, another workflow should start automatically and update json files in https://github.com/paritytech/resolc-bin. Check the changes.
|
||||
8. Update the [contract-docs](https://github.com/paritytech/contract-docs/) accordingly
|
||||
|
||||
# LLVM release
|
||||
|
||||
|
||||
@@ -15,58 +15,58 @@
|
||||
|
||||
### Baseline
|
||||
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:--------|:------------------------|:-------------------------------- |
|
||||
| **`0`** | `3.36 us` (✅ **1.00x**) | `11.84 us` (❌ *3.52x slower*) |
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:--------|:-------------------------|:-------------------------------- |
|
||||
| **`0`** | `10.08 us` (✅ **1.00x**) | `10.32 us` (✅ **1.02x slower**) |
|
||||
|
||||
### OddPorduct
|
||||
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:-------------|:-------------------------|:-------------------------------- |
|
||||
| **`10000`** | `3.11 ms` (✅ **1.00x**) | `1.53 ms` (🚀 **2.03x faster**) |
|
||||
| **`100000`** | `30.70 ms` (✅ **1.00x**) | `15.54 ms` (🚀 **1.98x faster**) |
|
||||
| **`300000`** | `92.68 ms` (✅ **1.00x**) | `45.47 ms` (🚀 **2.04x faster**) |
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:-------------|:--------------------------|:-------------------------------- |
|
||||
| **`10000`** | `3.60 ms` (✅ **1.00x**) | `1.57 ms` (🚀 **2.28x faster**) |
|
||||
| **`100000`** | `34.72 ms` (✅ **1.00x**) | `14.82 ms` (🚀 **2.34x faster**) |
|
||||
| **`300000`** | `105.01 ms` (✅ **1.00x**) | `44.11 ms` (🚀 **2.38x faster**) |
|
||||
|
||||
### TriangleNumber
|
||||
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:-------------|:-------------------------|:-------------------------------- |
|
||||
| **`10000`** | `2.29 ms` (✅ **1.00x**) | `1.09 ms` (🚀 **2.11x faster**) |
|
||||
| **`100000`** | `22.84 ms` (✅ **1.00x**) | `10.66 ms` (🚀 **2.14x faster**) |
|
||||
| **`360000`** | `82.29 ms` (✅ **1.00x**) | `37.01 ms` (🚀 **2.22x faster**) |
|
||||
| **`10000`** | `2.43 ms` (✅ **1.00x**) | `1.12 ms` (🚀 **2.17x faster**) |
|
||||
| **`100000`** | `24.20 ms` (✅ **1.00x**) | `10.86 ms` (🚀 **2.23x faster**) |
|
||||
| **`360000`** | `88.69 ms` (✅ **1.00x**) | `38.46 ms` (🚀 **2.31x faster**) |
|
||||
|
||||
### FibonacciRecursive
|
||||
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:---------|:--------------------------|:--------------------------------- |
|
||||
| **`12`** | `135.67 us` (✅ **1.00x**) | `125.02 us` (✅ **1.09x faster**) |
|
||||
| **`16`** | `903.75 us` (✅ **1.00x**) | `762.79 us` (✅ **1.18x faster**) |
|
||||
| **`20`** | `6.12 ms` (✅ **1.00x**) | `4.96 ms` (✅ **1.23x faster**) |
|
||||
| **`24`** | `42.05 ms` (✅ **1.00x**) | `33.86 ms` (✅ **1.24x faster**) |
|
||||
| **`12`** | `144.17 us` (✅ **1.00x**) | `150.85 us` (✅ **1.05x slower**) |
|
||||
| **`16`** | `938.71 us` (✅ **1.00x**) | `922.11 us` (✅ **1.02x faster**) |
|
||||
| **`20`** | `6.54 ms` (✅ **1.00x**) | `6.20 ms` (✅ **1.05x faster**) |
|
||||
| **`24`** | `45.73 ms` (✅ **1.00x**) | `41.98 ms` (✅ **1.09x faster**) |
|
||||
|
||||
### FibonacciIterative
|
||||
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:----------|:-------------------------|:-------------------------------- |
|
||||
| **`64`** | `15.04 us` (✅ **1.00x**) | `29.45 us` (❌ *1.96x slower*) |
|
||||
| **`128`** | `26.36 us` (✅ **1.00x**) | `42.19 us` (❌ *1.60x slower*) |
|
||||
| **`256`** | `48.61 us` (✅ **1.00x**) | `65.71 us` (❌ *1.35x slower*) |
|
||||
| **`64`** | `23.00 us` (✅ **1.00x**) | `31.88 us` (❌ *1.39x slower*) |
|
||||
| **`128`** | `35.28 us` (✅ **1.00x**) | `42.43 us` (❌ *1.20x slower*) |
|
||||
| **`256`** | `60.12 us` (✅ **1.00x**) | `61.20 us` (✅ **1.02x slower**) |
|
||||
|
||||
### FibonacciBinet
|
||||
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:----------|:-------------------------|:-------------------------------- |
|
||||
| **`64`** | `15.22 us` (✅ **1.00x**) | `41.46 us` (❌ *2.72x slower*) |
|
||||
| **`128`** | `17.05 us` (✅ **1.00x**) | `42.84 us` (❌ *2.51x slower*) |
|
||||
| **`256`** | `19.00 us` (✅ **1.00x**) | `44.36 us` (❌ *2.34x slower*) |
|
||||
| **`64`** | `23.01 us` (✅ **1.00x**) | `47.74 us` (❌ *2.07x slower*) |
|
||||
| **`128`** | `25.44 us` (✅ **1.00x**) | `49.67 us` (❌ *1.95x slower*) |
|
||||
| **`256`** | `28.66 us` (✅ **1.00x**) | `53.01 us` (❌ *1.85x slower*) |
|
||||
|
||||
### SHA1
|
||||
|
||||
| | `EVM` | `PVMInterpreter` |
|
||||
|:----------|:--------------------------|:--------------------------------- |
|
||||
| **`1`** | `110.04 us` (✅ **1.00x**) | `216.11 us` (❌ *1.96x slower*) |
|
||||
| **`64`** | `209.04 us` (✅ **1.00x**) | `309.48 us` (❌ *1.48x slower*) |
|
||||
| **`512`** | `903.65 us` (✅ **1.00x**) | `980.49 us` (✅ **1.09x slower**) |
|
||||
| **`1`** | `135.87 us` (✅ **1.00x**) | `243.75 us` (❌ *1.79x slower*) |
|
||||
| **`64`** | `258.45 us` (✅ **1.00x**) | `355.70 us` (❌ *1.38x slower*) |
|
||||
| **`512`** | `1.10 ms` (✅ **1.00x**) | `1.09 ms` (✅ **1.01x faster**) |
|
||||
|
||||
---
|
||||
Made with [criterion-table](https://github.com/nu11ptr/criterion-table)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"Baseline": 1443,
|
||||
"Computation": 2788,
|
||||
"DivisionArithmetics": 9748,
|
||||
"ERC20": 19150,
|
||||
"Events": 2201,
|
||||
"FibonacciIterative": 2041,
|
||||
"Flipper": 2691,
|
||||
"SHA1": 8997
|
||||
"Baseline": 950,
|
||||
"Computation": 2262,
|
||||
"DivisionArithmetics": 8915,
|
||||
"ERC20": 17233,
|
||||
"Events": 1628,
|
||||
"FibonacciIterative": 1485,
|
||||
"Flipper": 2132,
|
||||
"SHA1": 8381
|
||||
}
|
||||
@@ -9,6 +9,9 @@ pub static XLEN: usize = revive_common::BIT_LENGTH_X32;
|
||||
/// The calldata size global variable name.
|
||||
pub static GLOBAL_CALLDATA_SIZE: &str = "calldatasize";
|
||||
|
||||
/// The spill buffer global variable name.
|
||||
pub static GLOBAL_ADDRESS_SPILL_BUFFER: &str = "address_spill_buffer";
|
||||
|
||||
/// The deployer call header size that consists of:
|
||||
/// - bytecode hash (32 bytes)
|
||||
pub const DEPLOYER_CALL_HEADER_SIZE: usize = revive_common::BYTE_LENGTH_WORD;
|
||||
|
||||
@@ -4,61 +4,98 @@
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Argument<'ctx> {
|
||||
/// The actual LLVM operand.
|
||||
pub value: inkwell::values::BasicValueEnum<'ctx>,
|
||||
pub value: Value<'ctx>,
|
||||
/// The original AST value. Used mostly for string literals.
|
||||
pub original: Option<String>,
|
||||
/// The preserved constant value, if available.
|
||||
pub constant: Option<num::BigUint>,
|
||||
}
|
||||
|
||||
/// The function argument can be either a pointer or a integer value.
|
||||
/// This disambiguation allows for lazy loading of variables.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Value<'ctx> {
|
||||
Register(inkwell::values::BasicValueEnum<'ctx>),
|
||||
Pointer {
|
||||
pointer: crate::polkavm::context::Pointer<'ctx>,
|
||||
id: String,
|
||||
},
|
||||
}
|
||||
|
||||
impl<'ctx> Argument<'ctx> {
|
||||
/// The calldata offset argument index.
|
||||
pub const ARGUMENT_INDEX_CALLDATA_OFFSET: usize = 0;
|
||||
|
||||
/// The calldata length argument index.
|
||||
pub const ARGUMENT_INDEX_CALLDATA_LENGTH: usize = 1;
|
||||
|
||||
/// A shortcut constructor.
|
||||
pub fn new(value: inkwell::values::BasicValueEnum<'ctx>) -> Self {
|
||||
/// A shortcut constructor for register arguments.
|
||||
pub fn value(value: inkwell::values::BasicValueEnum<'ctx>) -> Self {
|
||||
Self {
|
||||
value,
|
||||
value: Value::Register(value),
|
||||
original: None,
|
||||
constant: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// A shortcut constructor.
|
||||
pub fn new_with_original(
|
||||
value: inkwell::values::BasicValueEnum<'ctx>,
|
||||
original: String,
|
||||
) -> Self {
|
||||
/// A shortcut constructor for stack arguments.
|
||||
pub fn pointer(pointer: crate::polkavm::context::Pointer<'ctx>, id: String) -> Self {
|
||||
Self {
|
||||
value,
|
||||
original: Some(original),
|
||||
value: Value::Pointer { pointer, id },
|
||||
original: None,
|
||||
constant: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// A shortcut constructor.
|
||||
pub fn new_with_constant(
|
||||
value: inkwell::values::BasicValueEnum<'ctx>,
|
||||
constant: num::BigUint,
|
||||
) -> Self {
|
||||
Self {
|
||||
value,
|
||||
original: None,
|
||||
constant: Some(constant),
|
||||
}
|
||||
/// Set the original decleratation value.
|
||||
pub fn with_original(mut self, original: String) -> Self {
|
||||
self.original = Some(original);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the constant value.
|
||||
pub fn with_constant(mut self, constant: num::BigUint) -> Self {
|
||||
self.constant = Some(constant);
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns the inner LLVM value.
|
||||
pub fn to_llvm(&self) -> inkwell::values::BasicValueEnum<'ctx> {
|
||||
self.value
|
||||
///
|
||||
/// Panics if `self` is a pointer argument.
|
||||
pub fn _to_llvm_value(&self) -> inkwell::values::BasicValueEnum<'ctx> {
|
||||
match &self.value {
|
||||
Value::Register(value) => *value,
|
||||
Value::Pointer { .. } => unreachable!("invalid register value access"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Access the underlying value.
|
||||
///
|
||||
/// Will emit a stack load if `self` is a pointer argument.
|
||||
pub fn access<D: crate::polkavm::Dependency + Clone>(
|
||||
&self,
|
||||
context: &crate::polkavm::context::Context<'ctx, D>,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>> {
|
||||
match &self.value {
|
||||
Value::Register(value) => Ok(*value),
|
||||
Value::Pointer { pointer, id } => context.build_load(*pointer, id),
|
||||
}
|
||||
}
|
||||
|
||||
/// Access the underlying value.
|
||||
///
|
||||
/// Will emit a stack load if `self` is a pointer argument.
|
||||
pub fn as_pointer<D: crate::polkavm::Dependency + Clone>(
|
||||
&self,
|
||||
context: &crate::polkavm::context::Context<'ctx, D>,
|
||||
) -> anyhow::Result<crate::polkavm::context::Pointer<'ctx>> {
|
||||
match &self.value {
|
||||
Value::Register(value) => {
|
||||
let pointer = context.build_alloca_at_entry(context.word_type(), "pvm_arg");
|
||||
context.build_store(pointer, *value)?;
|
||||
Ok(pointer)
|
||||
}
|
||||
Value::Pointer { pointer, .. } => Ok(*pointer),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> From<inkwell::values::BasicValueEnum<'ctx>> for Argument<'ctx> {
|
||||
fn from(value: inkwell::values::BasicValueEnum<'ctx>) -> Self {
|
||||
Self::new(value)
|
||||
Self::value(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,14 @@ impl Entry {
|
||||
context.xlen_type().get_undef(),
|
||||
);
|
||||
|
||||
let address_type = context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS);
|
||||
context.set_global(
|
||||
crate::polkavm::GLOBAL_ADDRESS_SPILL_BUFFER,
|
||||
address_type,
|
||||
AddressSpace::Stack,
|
||||
address_type.const_zero(),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -750,7 +750,9 @@ where
|
||||
address: inkwell::values::IntValue<'ctx>,
|
||||
) -> anyhow::Result<Pointer<'ctx>> {
|
||||
let address_type = self.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS);
|
||||
let address_pointer = self.build_alloca_at_entry(address_type, "address_pointer");
|
||||
let address_pointer = self
|
||||
.get_global(crate::polkavm::GLOBAL_ADDRESS_SPILL_BUFFER)?
|
||||
.into();
|
||||
let address_truncated =
|
||||
self.builder()
|
||||
.build_int_truncate(address, address_type, "address_truncated")?;
|
||||
@@ -771,27 +773,49 @@ where
|
||||
.into())
|
||||
}
|
||||
|
||||
/// Builds a stack load instruction.
|
||||
/// Builds a stack load instruction with a direct assignment.
|
||||
/// Sets the alignment to 256 bits for the stack and 1 bit for the heap, parent, and child.
|
||||
pub fn build_load(
|
||||
pub fn build_load_assign(
|
||||
&self,
|
||||
pointer: Pointer<'ctx>,
|
||||
name: &str,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>> {
|
||||
assignment_pointer: &mut Option<inkwell::values::PointerValue<'ctx>>,
|
||||
) -> anyhow::Result<Option<inkwell::values::BasicValueEnum<'ctx>>> {
|
||||
match pointer.address_space {
|
||||
AddressSpace::Heap => {
|
||||
let name = <PolkaVMLoadHeapWordFunction as RuntimeFunction<D>>::NAME;
|
||||
let declaration =
|
||||
<PolkaVMLoadHeapWordFunction as RuntimeFunction<D>>::declaration(self);
|
||||
let arguments = [self
|
||||
.builder()
|
||||
.build_ptr_to_int(pointer.value, self.xlen_type(), "offset_ptrtoint")?
|
||||
.as_basic_value_enum()];
|
||||
Ok(self
|
||||
.build_call(declaration, &arguments, "heap_load")
|
||||
.unwrap_or_else(|| {
|
||||
panic!("revive runtime function {name} should return a value")
|
||||
}))
|
||||
match assignment_pointer.take() {
|
||||
Some(assignment_pointer) => {
|
||||
let arguments = [
|
||||
self.builder()
|
||||
.build_ptr_to_int(
|
||||
pointer.value,
|
||||
self.xlen_type(),
|
||||
"offset_ptrtoint",
|
||||
)?
|
||||
.as_basic_value_enum(),
|
||||
assignment_pointer.into(),
|
||||
];
|
||||
self.build_call(declaration, &arguments, "heap_load");
|
||||
Ok(None)
|
||||
}
|
||||
None => {
|
||||
let pointer = self.build_alloca_at_entry(self.word_type(), "pointer");
|
||||
let arguments = [
|
||||
self.builder()
|
||||
.build_ptr_to_int(
|
||||
pointer.value,
|
||||
self.xlen_type(),
|
||||
"offset_ptrtoint",
|
||||
)?
|
||||
.as_basic_value_enum(),
|
||||
pointer.value.into(),
|
||||
];
|
||||
self.build_call(declaration, &arguments, "heap_load");
|
||||
Ok(Some(self.build_load(pointer, "storage_value")?))
|
||||
}
|
||||
}
|
||||
}
|
||||
AddressSpace::Stack => {
|
||||
let value = self
|
||||
@@ -804,11 +828,23 @@ where
|
||||
.set_alignment(revive_common::BYTE_LENGTH_STACK_ALIGN as u32)
|
||||
.expect("Alignment is valid");
|
||||
|
||||
Ok(value)
|
||||
Ok(Some(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a stack load instruction.
|
||||
/// Sets the alignment to 256 bits for the stack and 1 bit for the heap, parent, and child.
|
||||
pub fn build_load(
|
||||
&self,
|
||||
pointer: Pointer<'ctx>,
|
||||
name: &str,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>> {
|
||||
Ok(self
|
||||
.build_load_assign(pointer, name, &mut None)?
|
||||
.expect("without an assignment pointer loads return a value"))
|
||||
}
|
||||
|
||||
/// Builds a stack store instruction.
|
||||
/// Sets the alignment to 256 bits for the stack and 1 bit for the heap, parent, and child.
|
||||
pub fn build_store<V>(&self, pointer: Pointer<'ctx>, value: V) -> anyhow::Result<()>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
use inkwell::values::BasicValueEnum;
|
||||
|
||||
use crate::polkavm::context::address_space::AddressSpace;
|
||||
use crate::polkavm::context::pointer::Pointer;
|
||||
use crate::polkavm::context::runtime::RuntimeFunction;
|
||||
use crate::polkavm::context::Context;
|
||||
use crate::polkavm::Dependency;
|
||||
@@ -17,9 +19,13 @@ where
|
||||
const NAME: &'static str = "__revive_load_heap_word";
|
||||
|
||||
fn r#type<'ctx>(context: &Context<'ctx, D>) -> inkwell::types::FunctionType<'ctx> {
|
||||
context
|
||||
.word_type()
|
||||
.fn_type(&[context.xlen_type().into()], false)
|
||||
context.void_type().fn_type(
|
||||
&[
|
||||
context.xlen_type().into(),
|
||||
context.llvm().ptr_type(Default::default()).into(),
|
||||
],
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
fn emit_body<'ctx>(
|
||||
@@ -27,6 +33,7 @@ where
|
||||
context: &mut Context<'ctx, D>,
|
||||
) -> anyhow::Result<Option<BasicValueEnum<'ctx>>> {
|
||||
let offset = Self::paramater(context, 0).into_int_value();
|
||||
let assignment_pointer = Self::paramater(context, 1).into_pointer_value();
|
||||
let length = context
|
||||
.xlen_type()
|
||||
.const_int(revive_common::BYTE_LENGTH_WORD as u64, false);
|
||||
@@ -42,7 +49,11 @@ where
|
||||
.expect("Alignment is valid");
|
||||
|
||||
let swapped_value = context.build_byte_swap(value)?;
|
||||
Ok(Some(swapped_value))
|
||||
context.build_store(
|
||||
Pointer::new(context.word_type(), AddressSpace::Stack, assignment_pointer),
|
||||
swapped_value,
|
||||
)?;
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
use inkwell::values::BasicValueEnum;
|
||||
|
||||
use crate::polkavm::context::address_space::AddressSpace;
|
||||
use crate::polkavm::context::pointer::Pointer;
|
||||
use crate::polkavm::context::runtime::RuntimeFunction;
|
||||
use crate::polkavm::context::Context;
|
||||
use crate::polkavm::Dependency;
|
||||
@@ -17,20 +19,27 @@ where
|
||||
const NAME: &'static str = "__revive_load_storage_word";
|
||||
|
||||
fn r#type<'ctx>(context: &Context<'ctx, D>) -> inkwell::types::FunctionType<'ctx> {
|
||||
context
|
||||
.word_type()
|
||||
.fn_type(&[context.word_type().into()], false)
|
||||
context.void_type().fn_type(
|
||||
&[
|
||||
context.llvm().ptr_type(Default::default()).into(),
|
||||
context.llvm().ptr_type(Default::default()).into(),
|
||||
],
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
fn emit_body<'ctx>(
|
||||
&self,
|
||||
context: &mut Context<'ctx, D>,
|
||||
) -> anyhow::Result<Option<BasicValueEnum<'ctx>>> {
|
||||
Ok(Some(emit_load(
|
||||
context,
|
||||
Self::paramater(context, 0),
|
||||
false,
|
||||
)?))
|
||||
let key = Self::paramater(context, 0);
|
||||
let assignment_pointer = Self::paramater(context, 1).into_pointer_value();
|
||||
let value = emit_load(context, key, false)?;
|
||||
context.build_store(
|
||||
Pointer::new(context.word_type(), AddressSpace::Stack, assignment_pointer),
|
||||
value,
|
||||
)?;
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +68,7 @@ where
|
||||
fn r#type<'ctx>(context: &Context<'ctx, D>) -> inkwell::types::FunctionType<'ctx> {
|
||||
context
|
||||
.word_type()
|
||||
.fn_type(&[context.word_type().into()], false)
|
||||
.fn_type(&[context.llvm().ptr_type(Default::default()).into()], false)
|
||||
}
|
||||
|
||||
fn emit_body<'ctx>(
|
||||
@@ -94,7 +103,10 @@ where
|
||||
|
||||
fn r#type<'ctx>(context: &Context<'ctx, D>) -> inkwell::types::FunctionType<'ctx> {
|
||||
context.void_type().fn_type(
|
||||
&[context.word_type().into(), context.word_type().into()],
|
||||
&[
|
||||
context.llvm().ptr_type(Default::default()).into(),
|
||||
context.llvm().ptr_type(Default::default()).into(),
|
||||
],
|
||||
false,
|
||||
)
|
||||
}
|
||||
@@ -138,7 +150,10 @@ where
|
||||
|
||||
fn r#type<'ctx>(context: &Context<'ctx, D>) -> inkwell::types::FunctionType<'ctx> {
|
||||
context.void_type().fn_type(
|
||||
&[context.word_type().into(), context.word_type().into()],
|
||||
&[
|
||||
context.llvm().ptr_type(Default::default()).into(),
|
||||
context.llvm().ptr_type(Default::default()).into(),
|
||||
],
|
||||
false,
|
||||
)
|
||||
}
|
||||
@@ -173,9 +188,17 @@ where
|
||||
|
||||
fn emit_load<'ctx, D: Dependency + Clone>(
|
||||
context: &mut Context<'ctx, D>,
|
||||
mut key: BasicValueEnum<'ctx>,
|
||||
key: BasicValueEnum<'ctx>,
|
||||
transient: bool,
|
||||
) -> anyhow::Result<BasicValueEnum<'ctx>> {
|
||||
let mut key = context.build_load(
|
||||
super::Pointer::new(
|
||||
context.word_type(),
|
||||
Default::default(),
|
||||
key.into_pointer_value(),
|
||||
),
|
||||
"key",
|
||||
)?;
|
||||
if !transient {
|
||||
key = context.build_byte_swap(key)?;
|
||||
}
|
||||
@@ -217,10 +240,26 @@ fn emit_load<'ctx, D: Dependency + Clone>(
|
||||
|
||||
fn emit_store<'ctx, D: Dependency + Clone>(
|
||||
context: &mut Context<'ctx, D>,
|
||||
mut key: BasicValueEnum<'ctx>,
|
||||
mut value: BasicValueEnum<'ctx>,
|
||||
key: BasicValueEnum<'ctx>,
|
||||
value: BasicValueEnum<'ctx>,
|
||||
transient: bool,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut key = context.build_load(
|
||||
super::Pointer::new(
|
||||
context.word_type(),
|
||||
Default::default(),
|
||||
key.into_pointer_value(),
|
||||
),
|
||||
"key",
|
||||
)?;
|
||||
let mut value = context.build_load(
|
||||
super::Pointer::new(
|
||||
context.word_type(),
|
||||
Default::default(),
|
||||
value.into_pointer_value(),
|
||||
),
|
||||
"key",
|
||||
)?;
|
||||
if !transient {
|
||||
key = context.build_byte_swap(key)?;
|
||||
value = context.build_byte_swap(value)?;
|
||||
|
||||
@@ -63,7 +63,6 @@ where
|
||||
let non_overflow_block = context.append_basic_block("shift_left_non_overflow");
|
||||
let join_block = context.append_basic_block("shift_left_join");
|
||||
|
||||
let result_pointer = context.build_alloca(context.word_type(), "shift_left_result_pointer");
|
||||
let condition_is_overflow = context.builder().build_int_compare(
|
||||
inkwell::IntPredicate::UGT,
|
||||
shift,
|
||||
@@ -73,7 +72,6 @@ where
|
||||
context.build_conditional_branch(condition_is_overflow, overflow_block, non_overflow_block)?;
|
||||
|
||||
context.set_basic_block(overflow_block);
|
||||
context.build_store(result_pointer, context.word_const(0))?;
|
||||
context.build_unconditional_branch(join_block);
|
||||
|
||||
context.set_basic_block(non_overflow_block);
|
||||
@@ -81,11 +79,17 @@ where
|
||||
context
|
||||
.builder()
|
||||
.build_left_shift(value, shift, "shift_left_non_overflow_result")?;
|
||||
context.build_store(result_pointer, value)?;
|
||||
context.build_unconditional_branch(join_block);
|
||||
|
||||
context.set_basic_block(join_block);
|
||||
context.build_load(result_pointer, "shift_left_result")
|
||||
let result = context
|
||||
.builder()
|
||||
.build_phi(context.word_type(), "shift_left_value")?;
|
||||
result.add_incoming(&[
|
||||
(&value, non_overflow_block),
|
||||
(&context.word_const(0), overflow_block),
|
||||
]);
|
||||
Ok(result.as_basic_value())
|
||||
}
|
||||
|
||||
/// Translates the bitwise shift right.
|
||||
@@ -101,7 +105,6 @@ where
|
||||
let non_overflow_block = context.append_basic_block("shift_right_non_overflow");
|
||||
let join_block = context.append_basic_block("shift_right_join");
|
||||
|
||||
let result_pointer = context.build_alloca(context.word_type(), "shift_right_result_pointer");
|
||||
let condition_is_overflow = context.builder().build_int_compare(
|
||||
inkwell::IntPredicate::UGT,
|
||||
shift,
|
||||
@@ -111,7 +114,6 @@ where
|
||||
context.build_conditional_branch(condition_is_overflow, overflow_block, non_overflow_block)?;
|
||||
|
||||
context.set_basic_block(overflow_block);
|
||||
context.build_store(result_pointer, context.word_const(0))?;
|
||||
context.build_unconditional_branch(join_block);
|
||||
|
||||
context.set_basic_block(non_overflow_block);
|
||||
@@ -121,11 +123,17 @@ where
|
||||
false,
|
||||
"shift_right_non_overflow_result",
|
||||
)?;
|
||||
context.build_store(result_pointer, value)?;
|
||||
context.build_unconditional_branch(join_block);
|
||||
|
||||
context.set_basic_block(join_block);
|
||||
context.build_load(result_pointer, "shift_right_result")
|
||||
let result = context
|
||||
.builder()
|
||||
.build_phi(context.word_type(), "shift_right_value")?;
|
||||
result.add_incoming(&[
|
||||
(&value, non_overflow_block),
|
||||
(&context.word_const(0), overflow_block),
|
||||
]);
|
||||
Ok(result.as_basic_value())
|
||||
}
|
||||
|
||||
/// Translates the arithmetic bitwise shift right.
|
||||
@@ -145,8 +153,6 @@ where
|
||||
let non_overflow_block = context.append_basic_block("shift_right_arithmetic_non_overflow");
|
||||
let join_block = context.append_basic_block("shift_right_arithmetic_join");
|
||||
|
||||
let result_pointer =
|
||||
context.build_alloca(context.word_type(), "shift_right_arithmetic_result_pointer");
|
||||
let condition_is_overflow = context.builder().build_int_compare(
|
||||
inkwell::IntPredicate::UGT,
|
||||
shift,
|
||||
@@ -174,11 +180,9 @@ where
|
||||
)?;
|
||||
|
||||
context.set_basic_block(overflow_positive_block);
|
||||
context.build_store(result_pointer, context.word_const(0))?;
|
||||
context.build_unconditional_branch(join_block);
|
||||
|
||||
context.set_basic_block(overflow_negative_block);
|
||||
context.build_store(result_pointer, context.word_type().const_all_ones())?;
|
||||
context.build_unconditional_branch(join_block);
|
||||
|
||||
context.set_basic_block(non_overflow_block);
|
||||
@@ -188,11 +192,21 @@ where
|
||||
true,
|
||||
"shift_right_arithmetic_non_overflow_result",
|
||||
)?;
|
||||
context.build_store(result_pointer, value)?;
|
||||
context.build_unconditional_branch(join_block);
|
||||
|
||||
context.set_basic_block(join_block);
|
||||
context.build_load(result_pointer, "shift_right_arithmetic_result")
|
||||
let result = context
|
||||
.builder()
|
||||
.build_phi(context.word_type(), "shift_arithmetic_right_value")?;
|
||||
result.add_incoming(&[
|
||||
(&value, non_overflow_block),
|
||||
(
|
||||
&context.word_type().const_all_ones(),
|
||||
overflow_negative_block,
|
||||
),
|
||||
(&context.word_const(0), overflow_block),
|
||||
]);
|
||||
Ok(result.as_basic_value())
|
||||
}
|
||||
|
||||
/// Translates the `byte` instruction, extracting the byte of `operand_2`
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use inkwell::values::BasicValue;
|
||||
|
||||
use crate::polkavm::context::pointer::Pointer;
|
||||
use crate::polkavm::context::Context;
|
||||
use crate::polkavm::Dependency;
|
||||
|
||||
@@ -49,7 +50,9 @@ where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let address_type = context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS);
|
||||
let address_pointer = context.build_alloca_at_entry(address_type, "origin_address");
|
||||
let address_pointer: Pointer<'_> = context
|
||||
.get_global(crate::polkavm::GLOBAL_ADDRESS_SPILL_BUFFER)?
|
||||
.into();
|
||||
context.build_store(address_pointer, address_type.const_zero())?;
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::ORIGIN,
|
||||
@@ -97,13 +100,13 @@ where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let output_pointer = context.build_alloca_at_entry(context.word_type(), "blockhash_out_ptr");
|
||||
let index_ptr = context.build_alloca_at_entry(context.word_type(), "blockhash_index_ptr");
|
||||
context.build_store(index_ptr, index)?;
|
||||
let index_pointer = context.build_alloca_at_entry(context.word_type(), "blockhash_index_ptr");
|
||||
context.build_store(index_pointer, index)?;
|
||||
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::BLOCK_HASH,
|
||||
&[
|
||||
index_ptr.to_int(context).into(),
|
||||
index_pointer.to_int(context).into(),
|
||||
output_pointer.to_int(context).into(),
|
||||
],
|
||||
);
|
||||
@@ -127,10 +130,9 @@ pub fn coinbase<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let pointer = context.build_alloca_at_entry(
|
||||
context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS),
|
||||
"coinbase_output",
|
||||
);
|
||||
let pointer: Pointer<'_> = context
|
||||
.get_global(crate::polkavm::GLOBAL_ADDRESS_SPILL_BUFFER)?
|
||||
.into();
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::BLOCK_AUTHOR,
|
||||
&[pointer.to_int(context).into()],
|
||||
@@ -155,10 +157,9 @@ pub fn address<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let pointer = context.build_alloca_at_entry(
|
||||
context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS),
|
||||
"address_output",
|
||||
);
|
||||
let pointer: Pointer<'_> = context
|
||||
.get_global(crate::polkavm::GLOBAL_ADDRESS_SPILL_BUFFER)?
|
||||
.into();
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::ADDRESS,
|
||||
&[pointer.to_int(context).into()],
|
||||
@@ -173,10 +174,9 @@ pub fn caller<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let pointer = context.build_alloca_at_entry(
|
||||
context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS),
|
||||
"address_output",
|
||||
);
|
||||
let pointer: Pointer<'_> = context
|
||||
.get_global(crate::polkavm::GLOBAL_ADDRESS_SPILL_BUFFER)?
|
||||
.into();
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::CALLER,
|
||||
&[pointer.to_int(context).into()],
|
||||
|
||||
@@ -119,10 +119,8 @@ where
|
||||
_ => error,
|
||||
})?;
|
||||
if contract_path.as_str() == parent {
|
||||
return Ok(Argument::new_with_constant(
|
||||
context.word_const(0).as_basic_value_enum(),
|
||||
num::BigUint::zero(),
|
||||
));
|
||||
return Ok(Argument::value(context.word_const(0).as_basic_value_enum())
|
||||
.with_constant(num::BigUint::zero()));
|
||||
} else if identifier.ends_with("_deployed") && code_type == CodeType::Runtime {
|
||||
anyhow::bail!("type({}).runtimeCode is not supported", identifier);
|
||||
}
|
||||
@@ -131,7 +129,7 @@ where
|
||||
let hash_value = context
|
||||
.word_const_str_hex(hash_string.as_str())
|
||||
.as_basic_value_enum();
|
||||
Ok(Argument::new_with_original(hash_value, hash_string))
|
||||
Ok(Argument::value(hash_value).with_original(hash_string))
|
||||
}
|
||||
|
||||
/// Translates the deploy call header size instruction. the header consists of
|
||||
@@ -160,10 +158,8 @@ where
|
||||
_ => error,
|
||||
})?;
|
||||
if contract_path.as_str() == parent {
|
||||
return Ok(Argument::new_with_constant(
|
||||
context.word_const(0).as_basic_value_enum(),
|
||||
num::BigUint::zero(),
|
||||
));
|
||||
return Ok(Argument::value(context.word_const(0).as_basic_value_enum())
|
||||
.with_constant(num::BigUint::zero()));
|
||||
} else if identifier.ends_with("_deployed") && code_type == CodeType::Runtime {
|
||||
anyhow::bail!("type({}).runtimeCode is not supported", identifier);
|
||||
}
|
||||
@@ -172,5 +168,5 @@ where
|
||||
let size_value = context
|
||||
.word_const(crate::polkavm::DEPLOYER_CALL_HEADER_SIZE as u64)
|
||||
.as_basic_value_enum();
|
||||
Ok(Argument::new_with_constant(size_value, size_bigint))
|
||||
Ok(Argument::value(size_value).with_constant(size_bigint))
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub fn value<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let output_pointer = context.build_alloca(context.value_type(), "value_transferred");
|
||||
let output_pointer = context.build_alloca_at_entry(context.value_type(), "value_transferred");
|
||||
context.build_store(output_pointer, context.word_const(0))?;
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::VALUE_TRANSFERRED,
|
||||
@@ -46,8 +46,7 @@ where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let address_pointer = context.build_address_argument_store(address)?;
|
||||
|
||||
let balance_pointer = context.build_alloca(context.word_type(), "balance_pointer");
|
||||
let balance_pointer = context.build_alloca_at_entry(context.word_type(), "balance_pointer");
|
||||
let balance = context.builder().build_ptr_to_int(
|
||||
balance_pointer.value,
|
||||
context.xlen_type(),
|
||||
@@ -69,7 +68,7 @@ pub fn self_balance<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let balance_pointer = context.build_alloca(context.word_type(), "balance_pointer");
|
||||
let balance_pointer = context.build_alloca_at_entry(context.word_type(), "balance_pointer");
|
||||
let balance = context.builder().build_ptr_to_int(
|
||||
balance_pointer.value,
|
||||
context.xlen_type(),
|
||||
|
||||
@@ -29,7 +29,8 @@ where
|
||||
pub fn load<'ctx, D>(
|
||||
context: &mut Context<'ctx, D>,
|
||||
offset: inkwell::values::IntValue<'ctx>,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
assignment_pointer: &mut Option<inkwell::values::PointerValue<'ctx>>,
|
||||
) -> anyhow::Result<Option<inkwell::values::BasicValueEnum<'ctx>>>
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
@@ -40,7 +41,7 @@ where
|
||||
offset,
|
||||
"memory_load_pointer",
|
||||
);
|
||||
context.build_load(pointer, "memory_load_result")
|
||||
context.build_load_assign(pointer, "memory_load_result", assignment_pointer)
|
||||
}
|
||||
|
||||
/// Translates the `mstore` instruction.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use crate::polkavm::context::runtime::RuntimeFunction;
|
||||
use crate::polkavm::context::Context;
|
||||
use crate::polkavm::Dependency;
|
||||
use crate::PolkaVMArgument;
|
||||
use crate::PolkaVMLoadStorageWordFunction;
|
||||
use crate::PolkaVMLoadTransientStorageWordFunction;
|
||||
use crate::PolkaVMStoreStorageWordFunction;
|
||||
@@ -11,30 +12,49 @@ use crate::PolkaVMStoreTransientStorageWordFunction;
|
||||
/// Translates the storage load.
|
||||
pub fn load<'ctx, D>(
|
||||
context: &mut Context<'ctx, D>,
|
||||
position: inkwell::values::IntValue<'ctx>,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
position: &PolkaVMArgument<'ctx>,
|
||||
assignment_pointer: &mut Option<inkwell::values::PointerValue<'ctx>>,
|
||||
) -> anyhow::Result<Option<inkwell::values::BasicValueEnum<'ctx>>>
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let name = <PolkaVMLoadStorageWordFunction as RuntimeFunction<D>>::NAME;
|
||||
let _name = <PolkaVMLoadStorageWordFunction as RuntimeFunction<D>>::NAME;
|
||||
let declaration = <PolkaVMLoadStorageWordFunction as RuntimeFunction<D>>::declaration(context);
|
||||
let arguments = [position.into()];
|
||||
Ok(context
|
||||
.build_call(declaration, &arguments, "storage_load")
|
||||
.unwrap_or_else(|| panic!("runtime function {name} should return a value")))
|
||||
match assignment_pointer.take() {
|
||||
Some(assignment_pointer) => {
|
||||
let arguments = [
|
||||
position.as_pointer(context)?.value.into(),
|
||||
assignment_pointer.into(),
|
||||
];
|
||||
context.build_call(declaration, &arguments, "storage_load");
|
||||
Ok(None)
|
||||
}
|
||||
None => {
|
||||
let pointer = context.build_alloca_at_entry(context.word_type(), "pointer");
|
||||
let arguments = [
|
||||
position.as_pointer(context)?.value.into(),
|
||||
pointer.value.into(),
|
||||
];
|
||||
context.build_call(declaration, &arguments, "storage_load");
|
||||
Ok(Some(context.build_load(pointer, "storage_value")?))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Translates the storage store.
|
||||
pub fn store<'ctx, D>(
|
||||
context: &mut Context<'ctx, D>,
|
||||
position: inkwell::values::IntValue<'ctx>,
|
||||
value: inkwell::values::IntValue<'ctx>,
|
||||
position: &PolkaVMArgument<'ctx>,
|
||||
value: &PolkaVMArgument<'ctx>,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let declaration = <PolkaVMStoreStorageWordFunction as RuntimeFunction<D>>::declaration(context);
|
||||
let arguments = [position.into(), value.into()];
|
||||
let arguments = [
|
||||
position.as_pointer(context)?.value.into(),
|
||||
value.as_pointer(context)?.value.into(),
|
||||
];
|
||||
context.build_call(declaration, &arguments, "storage_store");
|
||||
Ok(())
|
||||
}
|
||||
@@ -42,13 +62,13 @@ where
|
||||
/// Translates the transient storage load.
|
||||
pub fn transient_load<'ctx, D>(
|
||||
context: &mut Context<'ctx, D>,
|
||||
position: inkwell::values::IntValue<'ctx>,
|
||||
position: &PolkaVMArgument<'ctx>,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let name = <PolkaVMLoadTransientStorageWordFunction as RuntimeFunction<D>>::NAME;
|
||||
let arguments = [position.into()];
|
||||
let arguments = [position.as_pointer(context)?.value.into()];
|
||||
let declaration =
|
||||
<PolkaVMLoadTransientStorageWordFunction as RuntimeFunction<D>>::declaration(context);
|
||||
Ok(context
|
||||
@@ -59,15 +79,18 @@ where
|
||||
/// Translates the transient storage store.
|
||||
pub fn transient_store<'ctx, D>(
|
||||
context: &mut Context<'ctx, D>,
|
||||
position: inkwell::values::IntValue<'ctx>,
|
||||
value: inkwell::values::IntValue<'ctx>,
|
||||
position: &PolkaVMArgument<'ctx>,
|
||||
value: &PolkaVMArgument<'ctx>,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let declaration =
|
||||
<PolkaVMStoreTransientStorageWordFunction as RuntimeFunction<D>>::declaration(context);
|
||||
let arguments = [position.into(), value.into()];
|
||||
let arguments = [
|
||||
position.as_pointer(context)?.value.into(),
|
||||
value.as_pointer(context)?.value.into(),
|
||||
];
|
||||
context.build_call(declaration, &arguments, "transient_storage_store");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ pub fn build_solidity_with_options(
|
||||
SolcStandardJsonInputSettingsSelection::new_required(),
|
||||
SolcStandardJsonInputSettingsOptimizer::new(
|
||||
solc_optimizer_enabled,
|
||||
None,
|
||||
optimizer_settings.middle_end_as_string().chars().last(),
|
||||
&solc_version.default,
|
||||
false,
|
||||
),
|
||||
@@ -102,16 +102,21 @@ pub fn build_solidity_with_options(
|
||||
|
||||
let mut output = solc.standard_json(input, None, vec![], None)?;
|
||||
|
||||
let debug_config = revive_llvm_context::DebugConfig::new(
|
||||
None,
|
||||
optimizer_settings.middle_end_as_string() != "z",
|
||||
);
|
||||
|
||||
let project = Project::try_from_standard_json_output(
|
||||
&output,
|
||||
sources,
|
||||
libraries,
|
||||
&solc_version,
|
||||
&DEBUG_CONFIG,
|
||||
&debug_config,
|
||||
)?;
|
||||
|
||||
let build: crate::Build =
|
||||
project.compile(optimizer_settings, false, DEBUG_CONFIG, Default::default())?;
|
||||
project.compile(optimizer_settings, false, debug_config, Default::default())?;
|
||||
build.write_to_standard_json(&mut output, &solc_version)?;
|
||||
|
||||
Ok(output)
|
||||
|
||||
@@ -121,11 +121,6 @@ where
|
||||
) -> anyhow::Result<()> {
|
||||
context.set_debug_location(self.location.line, 0, None)?;
|
||||
|
||||
let value = match self.initializer.into_llvm(context)? {
|
||||
Some(value) => value,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
if self.bindings.len() == 1 {
|
||||
let identifier = self.bindings.remove(0);
|
||||
let pointer = context
|
||||
@@ -139,13 +134,31 @@ where
|
||||
identifier.inner,
|
||||
)
|
||||
})?;
|
||||
context.build_store(pointer, value.to_llvm())?;
|
||||
|
||||
let mut assignment_pointer = Some(pointer.value);
|
||||
let value = match self
|
||||
.initializer
|
||||
.into_llvm(context, &mut assignment_pointer)?
|
||||
{
|
||||
Some(value) => value,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
if assignment_pointer.is_some() {
|
||||
context.build_store(pointer, value.access(context)?)?;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let llvm_type = value.to_llvm().into_struct_value().get_type();
|
||||
let value = match self.initializer.into_llvm(context, &mut None)? {
|
||||
Some(value) => value,
|
||||
None => return Ok(()),
|
||||
};
|
||||
let value = value.access(context)?;
|
||||
let llvm_type = value.into_struct_value().get_type();
|
||||
let tuple_pointer = context.build_alloca(llvm_type, "assignment_pointer");
|
||||
context.build_store(tuple_pointer, value.to_llvm())?;
|
||||
context.build_store(tuple_pointer, value)?;
|
||||
|
||||
for (index, binding) in self.bindings.into_iter().enumerate() {
|
||||
context.set_debug_location(self.location.line, 0, None)?;
|
||||
|
||||
@@ -184,7 +184,7 @@ where
|
||||
block.into_llvm(context)?;
|
||||
}
|
||||
Statement::Expression(expression) => {
|
||||
expression.into_llvm(context)?;
|
||||
expression.into_llvm(context, &mut None)?;
|
||||
}
|
||||
Statement::VariableDeclaration(statement) => statement.into_llvm(context)?,
|
||||
Statement::Assignment(statement) => statement.into_llvm(context)?,
|
||||
|
||||
@@ -118,6 +118,7 @@ impl FunctionCall {
|
||||
pub fn into_llvm<'ctx, D>(
|
||||
mut self,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
assignment_pointer: &mut Option<inkwell::values::PointerValue<'ctx>>,
|
||||
) -> anyhow::Result<Option<inkwell::values::BasicValueEnum<'ctx>>>
|
||||
where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
@@ -128,7 +129,10 @@ impl FunctionCall {
|
||||
Name::UserDefined(name) => {
|
||||
let mut values = Vec::with_capacity(self.arguments.len());
|
||||
for argument in self.arguments.into_iter().rev() {
|
||||
let value = argument.into_llvm(context)?.expect("Always exists").value;
|
||||
let value = argument
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.access(context)?;
|
||||
values.push(value);
|
||||
}
|
||||
values.reverse();
|
||||
@@ -413,8 +417,8 @@ impl FunctionCall {
|
||||
revive_llvm_context::polkavm_evm_memory::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
assignment_pointer,
|
||||
)
|
||||
.map(Some)
|
||||
}
|
||||
Name::MStore => {
|
||||
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
|
||||
@@ -461,36 +465,33 @@ impl FunctionCall {
|
||||
}
|
||||
|
||||
Name::SLoad => {
|
||||
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
|
||||
let arguments = self.pop_arguments::<D, 1>(context)?;
|
||||
revive_llvm_context::polkavm_evm_storage::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
&arguments[0],
|
||||
assignment_pointer,
|
||||
)
|
||||
.map(Some)
|
||||
}
|
||||
Name::SStore => {
|
||||
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
|
||||
let arguments = self.pop_arguments::<D, 2>(context)?;
|
||||
revive_llvm_context::polkavm_evm_storage::store(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
&arguments[0],
|
||||
&arguments[1],
|
||||
)
|
||||
.map(|_| None)
|
||||
}
|
||||
Name::TLoad => {
|
||||
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
|
||||
revive_llvm_context::polkavm_evm_storage::transient_load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
.map(Some)
|
||||
let arguments = self.pop_arguments::<D, 1>(context)?;
|
||||
revive_llvm_context::polkavm_evm_storage::transient_load(context, &arguments[0])
|
||||
.map(Some)
|
||||
}
|
||||
Name::TStore => {
|
||||
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
|
||||
let arguments = self.pop_arguments::<D, 2>(context)?;
|
||||
revive_llvm_context::polkavm_evm_storage::transient_store(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
&arguments[0],
|
||||
&arguments[1],
|
||||
)
|
||||
.map(|_| None)
|
||||
}
|
||||
@@ -514,7 +515,7 @@ impl FunctionCall {
|
||||
let offset = context.solidity_mut().allocate_immutable(key.as_str())
|
||||
/ revive_common::BYTE_LENGTH_WORD;
|
||||
let index = context.xlen_type().const_int(offset as u64, false);
|
||||
let value = arguments[2].value.into_int_value();
|
||||
let value = arguments[2].access(context)?.into_int_value();
|
||||
revive_llvm_context::polkavm_evm_immutable::store(context, index, value)
|
||||
.map(|_| None)
|
||||
}
|
||||
@@ -720,13 +721,13 @@ impl FunctionCall {
|
||||
Name::Call => {
|
||||
let arguments = self.pop_arguments::<D, 7>(context)?;
|
||||
|
||||
let gas = arguments[0].value.into_int_value();
|
||||
let address = arguments[1].value.into_int_value();
|
||||
let value = arguments[2].value.into_int_value();
|
||||
let input_offset = arguments[3].value.into_int_value();
|
||||
let input_size = arguments[4].value.into_int_value();
|
||||
let output_offset = arguments[5].value.into_int_value();
|
||||
let output_size = arguments[6].value.into_int_value();
|
||||
let gas = arguments[0].access(context)?.into_int_value();
|
||||
let address = arguments[1].access(context)?.into_int_value();
|
||||
let value = arguments[2].access(context)?.into_int_value();
|
||||
let input_offset = arguments[3].access(context)?.into_int_value();
|
||||
let input_size = arguments[4].access(context)?.into_int_value();
|
||||
let output_offset = arguments[5].access(context)?.into_int_value();
|
||||
let output_size = arguments[6].access(context)?.into_int_value();
|
||||
|
||||
let simulation_address: Vec<Option<num::BigUint>> = arguments
|
||||
.into_iter()
|
||||
@@ -750,12 +751,12 @@ impl FunctionCall {
|
||||
Name::StaticCall => {
|
||||
let arguments = self.pop_arguments::<D, 6>(context)?;
|
||||
|
||||
let gas = arguments[0].value.into_int_value();
|
||||
let address = arguments[1].value.into_int_value();
|
||||
let input_offset = arguments[2].value.into_int_value();
|
||||
let input_size = arguments[3].value.into_int_value();
|
||||
let output_offset = arguments[4].value.into_int_value();
|
||||
let output_size = arguments[5].value.into_int_value();
|
||||
let gas = arguments[0].access(context)?.into_int_value();
|
||||
let address = arguments[1].access(context)?.into_int_value();
|
||||
let input_offset = arguments[2].access(context)?.into_int_value();
|
||||
let input_size = arguments[3].access(context)?.into_int_value();
|
||||
let output_offset = arguments[4].access(context)?.into_int_value();
|
||||
let output_size = arguments[5].access(context)?.into_int_value();
|
||||
|
||||
let simulation_address: Vec<Option<num::BigUint>> = arguments
|
||||
.into_iter()
|
||||
@@ -779,12 +780,12 @@ impl FunctionCall {
|
||||
Name::DelegateCall => {
|
||||
let arguments = self.pop_arguments::<D, 6>(context)?;
|
||||
|
||||
let gas = arguments[0].value.into_int_value();
|
||||
let address = arguments[1].value.into_int_value();
|
||||
let input_offset = arguments[2].value.into_int_value();
|
||||
let input_size = arguments[3].value.into_int_value();
|
||||
let output_offset = arguments[4].value.into_int_value();
|
||||
let output_size = arguments[5].value.into_int_value();
|
||||
let gas = arguments[0].access(context)?.into_int_value();
|
||||
let address = arguments[1].access(context)?.into_int_value();
|
||||
let input_offset = arguments[2].access(context)?.into_int_value();
|
||||
let input_size = arguments[3].access(context)?.into_int_value();
|
||||
let output_offset = arguments[4].access(context)?.into_int_value();
|
||||
let output_size = arguments[5].access(context)?.into_int_value();
|
||||
|
||||
let simulation_address: Vec<Option<num::BigUint>> = arguments
|
||||
.into_iter()
|
||||
@@ -845,7 +846,8 @@ impl FunctionCall {
|
||||
})?;
|
||||
|
||||
revive_llvm_context::polkavm_evm_create::contract_hash(context, identifier)
|
||||
.map(|argument| Some(argument.value))
|
||||
.and_then(|argument| argument.access(context))
|
||||
.map(Some)
|
||||
}
|
||||
Name::DataSize => {
|
||||
let mut arguments = self.pop_arguments::<D, 1>(context)?;
|
||||
@@ -855,7 +857,8 @@ impl FunctionCall {
|
||||
})?;
|
||||
|
||||
revive_llvm_context::polkavm_evm_create::header_size(context, identifier)
|
||||
.map(|argument| Some(argument.value))
|
||||
.and_then(|argument| argument.access(context))
|
||||
.map(Some)
|
||||
}
|
||||
Name::DataCopy => {
|
||||
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
|
||||
@@ -989,7 +992,12 @@ impl FunctionCall {
|
||||
{
|
||||
let mut arguments = Vec::with_capacity(N);
|
||||
for expression in self.arguments.drain(0..N).rev() {
|
||||
arguments.push(expression.into_llvm(context)?.expect("Always exists").value);
|
||||
arguments.push(
|
||||
expression
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.access(context)?,
|
||||
);
|
||||
}
|
||||
arguments.reverse();
|
||||
|
||||
@@ -1006,7 +1014,11 @@ impl FunctionCall {
|
||||
{
|
||||
let mut arguments = Vec::with_capacity(N);
|
||||
for expression in self.arguments.drain(0..N).rev() {
|
||||
arguments.push(expression.into_llvm(context)?.expect("Always exists"));
|
||||
arguments.push(
|
||||
expression
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists"),
|
||||
);
|
||||
}
|
||||
arguments.reverse();
|
||||
|
||||
|
||||
@@ -97,9 +97,7 @@ impl Literal {
|
||||
BooleanLiteral::True => num::BigUint::one(),
|
||||
};
|
||||
|
||||
Ok(revive_llvm_context::PolkaVMArgument::new_with_constant(
|
||||
value, constant,
|
||||
))
|
||||
Ok(revive_llvm_context::PolkaVMArgument::value(value).with_constant(constant))
|
||||
}
|
||||
LexicalLiteral::Integer(inner) => {
|
||||
let r#type = self.yul_type.unwrap_or_default().into_llvm(context);
|
||||
@@ -127,9 +125,7 @@ impl Literal {
|
||||
}
|
||||
.expect("Always valid");
|
||||
|
||||
Ok(revive_llvm_context::PolkaVMArgument::new_with_constant(
|
||||
value, constant,
|
||||
))
|
||||
Ok(revive_llvm_context::PolkaVMArgument::value(value).with_constant(constant))
|
||||
}
|
||||
LexicalLiteral::String(inner) => {
|
||||
let string = inner.inner;
|
||||
@@ -200,10 +196,10 @@ impl Literal {
|
||||
};
|
||||
|
||||
if hex_string.len() > revive_common::BYTE_LENGTH_WORD * 2 {
|
||||
return Ok(revive_llvm_context::PolkaVMArgument::new_with_original(
|
||||
return Ok(revive_llvm_context::PolkaVMArgument::value(
|
||||
r#type.const_zero().as_basic_value_enum(),
|
||||
string,
|
||||
));
|
||||
)
|
||||
.with_original(string));
|
||||
}
|
||||
|
||||
if hex_string.len() < revive_common::BYTE_LENGTH_WORD * 2 {
|
||||
@@ -220,9 +216,7 @@ impl Literal {
|
||||
)
|
||||
.expect("The value is valid")
|
||||
.as_basic_value_enum();
|
||||
Ok(revive_llvm_context::PolkaVMArgument::new_with_original(
|
||||
value, string,
|
||||
))
|
||||
Ok(revive_llvm_context::PolkaVMArgument::value(value).with_original(string))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ impl Expression {
|
||||
pub fn into_llvm<'ctx, D>(
|
||||
self,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
assignment_pointer: &mut Option<inkwell::values::PointerValue<'ctx>>,
|
||||
) -> anyhow::Result<Option<revive_llvm_context::PolkaVMArgument<'ctx>>>
|
||||
where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
@@ -119,36 +120,28 @@ impl Expression {
|
||||
})
|
||||
.map(Some),
|
||||
Self::Identifier(identifier) => {
|
||||
let id = identifier.inner;
|
||||
|
||||
let pointer = context
|
||||
.current_function()
|
||||
.borrow()
|
||||
.get_stack_pointer(identifier.inner.as_str())
|
||||
.get_stack_pointer(&id)
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"{} Undeclared variable `{}`",
|
||||
identifier.location,
|
||||
identifier.inner,
|
||||
)
|
||||
anyhow::anyhow!("{} Undeclared variable `{}`", identifier.location, id)
|
||||
})?;
|
||||
|
||||
let constant = context
|
||||
.current_function()
|
||||
.borrow()
|
||||
.yul()
|
||||
.get_constant(identifier.inner.as_str());
|
||||
let constant = context.current_function().borrow().yul().get_constant(&id);
|
||||
|
||||
let value = context.build_load(pointer, identifier.inner.as_str())?;
|
||||
let argument = revive_llvm_context::PolkaVMArgument::pointer(pointer, id);
|
||||
|
||||
match constant {
|
||||
Some(constant) => Ok(Some(
|
||||
revive_llvm_context::PolkaVMArgument::new_with_constant(value, constant),
|
||||
)),
|
||||
None => Ok(Some(value.into())),
|
||||
}
|
||||
Ok(Some(match constant {
|
||||
Some(constant) => argument.with_constant(constant),
|
||||
_ => argument,
|
||||
}))
|
||||
}
|
||||
Self::FunctionCall(call) => Ok(call
|
||||
.into_llvm(context)?
|
||||
.map(revive_llvm_context::PolkaVMArgument::new)),
|
||||
.into_llvm(context, assignment_pointer)?
|
||||
.map(revive_llvm_context::PolkaVMArgument::value)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ where
|
||||
context.set_basic_block(condition_block);
|
||||
let condition = self
|
||||
.condition
|
||||
.into_llvm(context)?
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.to_llvm()
|
||||
.access(context)?
|
||||
.into_int_value();
|
||||
let condition = context.builder().build_int_z_extend_or_bit_cast(
|
||||
condition,
|
||||
|
||||
@@ -55,9 +55,9 @@ where
|
||||
fn into_llvm(self, context: &mut revive_llvm_context::PolkaVMContext<D>) -> anyhow::Result<()> {
|
||||
let condition = self
|
||||
.condition
|
||||
.into_llvm(context)?
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.to_llvm()
|
||||
.access(context)?
|
||||
.into_int_value();
|
||||
let condition = context.builder().build_int_z_extend_or_bit_cast(
|
||||
condition,
|
||||
|
||||
@@ -123,7 +123,7 @@ where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(self, context: &mut revive_llvm_context::PolkaVMContext<D>) -> anyhow::Result<()> {
|
||||
let scrutinee = self.expression.into_llvm(context)?;
|
||||
let scrutinee = self.expression.into_llvm(context, &mut None)?;
|
||||
|
||||
if self.cases.is_empty() {
|
||||
if let Some(block) = self.default {
|
||||
@@ -137,7 +137,7 @@ where
|
||||
|
||||
let mut branches = Vec::with_capacity(self.cases.len());
|
||||
for (index, case) in self.cases.into_iter().enumerate() {
|
||||
let constant = case.literal.into_llvm(context)?.to_llvm();
|
||||
let constant = case.literal.into_llvm(context)?.access(context)?;
|
||||
|
||||
let expression_block = context
|
||||
.append_basic_block(format!("switch_case_branch_{}_block", index + 1).as_str());
|
||||
@@ -161,7 +161,10 @@ where
|
||||
|
||||
context.set_basic_block(current_block);
|
||||
context.builder().build_switch(
|
||||
scrutinee.expect("Always exists").to_llvm().into_int_value(),
|
||||
scrutinee
|
||||
.expect("Always exists")
|
||||
.access(context)?
|
||||
.into_int_value(),
|
||||
default_block,
|
||||
branches.as_slice(),
|
||||
)?;
|
||||
|
||||
@@ -110,8 +110,9 @@ where
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(identifier.inner.clone(), pointer);
|
||||
|
||||
let mut assignment_pointer = Some(pointer.value);
|
||||
let value = if let Some(expression) = self.expression {
|
||||
match expression.into_llvm(context)? {
|
||||
match expression.into_llvm(context, &mut assignment_pointer)? {
|
||||
Some(mut value) => {
|
||||
if let Some(constant) = value.constant.take() {
|
||||
context
|
||||
@@ -121,14 +122,16 @@ where
|
||||
.insert_constant(identifier.inner.clone(), constant);
|
||||
}
|
||||
|
||||
value.to_llvm()
|
||||
value.access(context)?
|
||||
}
|
||||
None => r#type.const_zero().as_basic_value_enum(),
|
||||
}
|
||||
} else {
|
||||
r#type.const_zero().as_basic_value_enum()
|
||||
};
|
||||
context.build_store(pointer, value)?;
|
||||
if assignment_pointer.is_some() {
|
||||
context.build_store(pointer, value)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -156,7 +159,7 @@ where
|
||||
None => return Ok(()),
|
||||
};
|
||||
let location = expression.location();
|
||||
let expression = match expression.into_llvm(context)? {
|
||||
let expression = match expression.into_llvm(context, &mut None)? {
|
||||
Some(expression) => expression,
|
||||
None => return Ok(()),
|
||||
};
|
||||
@@ -175,7 +178,8 @@ where
|
||||
.collect::<Vec<inkwell::types::BasicTypeEnum<'ctx>>>()
|
||||
.as_slice(),
|
||||
);
|
||||
if expression.value.get_type() != llvm_type.as_basic_type_enum() {
|
||||
let value = expression.access(context)?;
|
||||
if value.get_type() != llvm_type.as_basic_type_enum() {
|
||||
anyhow::bail!(
|
||||
"{} Assignment to {:?} received an invalid number of arguments",
|
||||
location,
|
||||
@@ -183,7 +187,7 @@ where
|
||||
);
|
||||
}
|
||||
let pointer = context.build_alloca(llvm_type, "bindings_pointer");
|
||||
context.build_store(pointer, expression.to_llvm())?;
|
||||
context.build_store(pointer, value)?;
|
||||
|
||||
for (index, binding) in self.bindings.into_iter().enumerate() {
|
||||
let pointer = context.build_gep(
|
||||
|
||||
+2
-1
@@ -4,7 +4,8 @@ const { minify } = require("terser");
|
||||
|
||||
const SOLJSON_URI =
|
||||
"https://binaries.soliditylang.org/wasm/soljson-v0.8.29+commit.ab55807c.js";
|
||||
const RESOLC_WASM_URI = "http://127.0.0.1:8080/resolc.wasm";
|
||||
const RESOLC_WASM_URI =
|
||||
process.env.RELEASE_RESOLC_WASM_URI || "http://127.0.0.1:8080/resolc.wasm";
|
||||
const RESOLC_WASM_TARGET_DIR = path.join(
|
||||
__dirname,
|
||||
"../target/wasm32-unknown-emscripten/release",
|
||||
|
||||
Reference in New Issue
Block a user