Merge pull request #10048 from ethereum/develop

Merge develop into breaking
This commit is contained in:
chriseth 2020-10-15 17:30:11 +02:00 committed by GitHub
commit 00fb152316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 523 additions and 201 deletions

View File

@ -2,7 +2,7 @@ $ErrorActionPreference = "Stop"
cd "$PSScriptRoot\.." cd "$PSScriptRoot\.."
if ("$Env:FORCE_RELEASE") { if ("$Env:FORCE_RELEASE" -Or "$Env:CIRCLE_TAG") {
New-Item prerelease.txt -type file New-Item prerelease.txt -type file
Write-Host "Building release version." Write-Host "Building release version."
} }

View File

@ -481,7 +481,7 @@ jobs:
steps: steps:
- checkout - checkout
- run: *run_build - run: *run_build
- persist_to_workspace: *artifacts_build_dir - persist_to_workspace: *artifacts_executables
t_ubu_codecov: t_ubu_codecov:
<<: *test_ubuntu2004 <<: *test_ubuntu2004
@ -574,12 +574,14 @@ jobs:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- dependencies-osx-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum ".circleci/osx_install_dependencies.sh" }} - dependencies-osx-{{ checksum ".circleci/osx_install_dependencies.sh" }}
# DO NOT EDIT between here and save_cache, but rather edit ./circleci/osx_install_dependencies.sh
# WARNING! If you do edit anything here instead, remember to invalidate the cache manually.
- run: - run:
name: Install build dependencies name: Install build dependencies
command: ./.circleci/osx_install_dependencies.sh command: ./.circleci/osx_install_dependencies.sh
- save_cache: - save_cache:
key: dependencies-osx-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum ".circleci/osx_install_dependencies.sh" }} key: dependencies-osx-{{ checksum ".circleci/osx_install_dependencies.sh" }}
paths: paths:
- /usr/local/bin - /usr/local/bin
- /usr/local/sbin - /usr/local/sbin
@ -590,7 +592,12 @@ jobs:
- run: *run_build - run: *run_build
- store_artifacts: *artifacts_solc - store_artifacts: *artifacts_solc
- store_artifacts: *artifacts_tools - store_artifacts: *artifacts_tools
- persist_to_workspace: *artifacts_build_dir - persist_to_workspace:
root: .
paths:
- build/solc/solc
- build/test/soltest
- build/test/tools/solfuzzer
t_osx_soltest: t_osx_soltest:
macos: macos:
@ -603,9 +610,9 @@ jobs:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- dependencies-osx-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum ".circleci/osx_install_dependencies.sh" }} - dependencies-osx-{{ checksum ".circleci/osx_install_dependencies.sh" }}
- attach_workspace: - attach_workspace:
at: build at: .
- run: *run_soltest - run: *run_soltest
- store_test_results: *store_test_results - store_test_results: *store_test_results
- store_artifacts: *artifacts_test_results - store_artifacts: *artifacts_test_results
@ -619,9 +626,9 @@ jobs:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- dependencies-osx-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum ".circleci/osx_install_dependencies.sh" }} - dependencies-osx-{{ checksum ".circleci/osx_install_dependencies.sh" }}
- attach_workspace: - attach_workspace:
at: build at: .
- run: *run_cmdline_tests - run: *run_cmdline_tests
- store_artifacts: *artifacts_test_results - store_artifacts: *artifacts_test_results
@ -902,14 +909,14 @@ jobs:
- restore_cache: - restore_cache:
keys: keys:
- dependencies-win-{{ checksum "scripts/install_deps.ps1" }} - dependencies-win-{{ checksum "scripts/install_deps.ps1" }}
- run: # DO NOT EDIT between here and save_cache, but rather edit .\scripts\install_deps.ps1
# WARNING! If you do edit anything here instead, remember to invalidate the cache manually. - run:
name: "Installing dependencies" name: "Installing dependencies"
command: if ( -not (Test-Path .\deps\boost) ) { .\scripts\install_deps.ps1 } command: .\scripts\install_deps.ps1
- save_cache: - save_cache:
key: dependencies-win-{{ checksum "scripts/install_deps.ps1" }} key: dependencies-win-{{ checksum "scripts/install_deps.ps1" }}
paths: paths:
- .\deps\boost - .\deps
- .\deps\cmake
- run: - run:
name: "Building solidity" name: "Building solidity"
command: .circleci/build_win.ps1 command: .circleci/build_win.ps1
@ -917,7 +924,11 @@ jobs:
name: "Run solc.exe to make sure build was successful." name: "Run solc.exe to make sure build was successful."
command: .\build\solc\Release\solc.exe --version command: .\build\solc\Release\solc.exe --version
- store_artifacts: *artifact_solc_windows - store_artifacts: *artifact_solc_windows
- persist_to_workspace: *artifacts_build_dir - persist_to_workspace:
root: build
paths:
- .\solc\*\solc.exe
- .\test\*\soltest.exe
b_win_release: b_win_release:
<<: *b_win <<: *b_win
@ -943,6 +954,81 @@ jobs:
t_win_release: t_win_release:
<<: *t_win <<: *t_win
b_bytecode_ubu:
docker:
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
steps:
- checkout
- attach_workspace:
at: build
- run: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-ubuntu.txt
- store_artifacts:
path: report.txt
- persist_to_workspace:
root: .
paths:
- bytecode-report-ubuntu.txt
b_bytecode_osx:
macos:
xcode: "11.0.0"
environment:
TERM: xterm
steps:
- checkout
- attach_workspace:
at: .
- run: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-osx.txt
- store_artifacts:
path: report.txt
- persist_to_workspace:
root: .
paths:
- bytecode-report-osx.txt
b_bytecode_win:
executor:
name: win/default
shell: cmd.exe
steps:
- checkout
- attach_workspace:
at: build
- run: python scripts\isolate_tests.py test\
- run: python scripts\bytecodecompare\prepare_report.py build\solc\Release\solc.exe
- run: cp report.txt bytecode-report-windows.txt
- store_artifacts:
path: report.txt
- persist_to_workspace:
root: .
paths:
- bytecode-report-windows.txt
b_bytecode_ems:
docker:
- image: circleci/node:10
environment:
SOLC_EMSCRIPTEN: "On"
steps:
- checkout
- attach_workspace:
at: emscripten_build/libsolc
- run: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-emscripten.txt
- store_artifacts:
path: report.txt
- persist_to_workspace:
root: .
paths:
- bytecode-report-emscripten.txt
t_bytecode_compare:
docker:
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
steps:
- attach_workspace:
at: .
- run: diff --report-identical-files --from-file bytecode-report-emscripten.txt bytecode-report-ubuntu.txt bytecode-report-osx.txt bytecode-report-windows.txt
workflows: workflows:
version: 2 version: 2
@ -1000,6 +1086,26 @@ workflows:
- t_win: *workflow_win - t_win: *workflow_win
- t_win_release: *workflow_win_release - t_win_release: *workflow_win_release
# Bytecode comparison:
- b_bytecode_ubu:
requires:
- b_ubu
- b_bytecode_win:
requires:
- b_win
- b_bytecode_osx:
requires:
- b_osx
- b_bytecode_ems:
requires:
- b_ems
- t_bytecode_compare:
requires:
- b_bytecode_ubu
- b_bytecode_win
- b_bytecode_osx
- b_bytecode_ems
nightly: nightly:
triggers: triggers:

View File

@ -16,6 +16,10 @@ Language Features:
### 0.7.4 (unreleased) ### 0.7.4 (unreleased)
Important Bugfixes:
* Code Generator: Fix data corruption bug when copying empty byte arrays from memory or calldata to storage.
Language Features: Language Features:
* Constants can be defined at file level. * Constants can be defined at file level.

View File

@ -1,4 +1,11 @@
[ [
{
"name": "EmptyByteArrayCopy",
"summary": "Copying an empty byte array (or string) from memory or calldata to storage can result in data corruption if the target array's length is increased subsequently without storing new data.",
"description": "The routine that copies byte arrays from memory or calldata to storage stores unrelated data from after the source array in the storage slot if the source array is empty. If the storage array's length is subsequently increased either by using ``.push()`` or by assigning to its ``.length`` attribute (only before 0.6.0), the newly created byte array elements will not be zero-initialized, but contain the unrelated data. You are not affected if you do not assign to ``.length`` and do not use ``.push()`` on byte arrays, or only use ``.push(<arg>)`` or manually initialize the new elements.",
"fixed": "0.7.4",
"severity": "medium"
},
{ {
"name": "DynamicArrayCleanup", "name": "DynamicArrayCleanup",
"summary": "When assigning a dynamically-sized array with types of size at most 16 bytes in storage causing the assigned array to shrink, some parts of deleted slots were not zeroed out.", "summary": "When assigning a dynamically-sized array with types of size at most 16 bytes in storage causing the assigned array to shrink, some parts of deleted slots were not zeroed out.",

View File

@ -1,6 +1,7 @@
{ {
"0.1.0": { "0.1.0": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ExpExponentCleanup", "ExpExponentCleanup",
"ZeroFunctionSelector", "ZeroFunctionSelector",
@ -20,6 +21,7 @@
}, },
"0.1.1": { "0.1.1": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ExpExponentCleanup", "ExpExponentCleanup",
"ZeroFunctionSelector", "ZeroFunctionSelector",
@ -39,6 +41,7 @@
}, },
"0.1.2": { "0.1.2": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ExpExponentCleanup", "ExpExponentCleanup",
"ZeroFunctionSelector", "ZeroFunctionSelector",
@ -58,6 +61,7 @@
}, },
"0.1.3": { "0.1.3": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ExpExponentCleanup", "ExpExponentCleanup",
"ZeroFunctionSelector", "ZeroFunctionSelector",
@ -77,6 +81,7 @@
}, },
"0.1.4": { "0.1.4": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ExpExponentCleanup", "ExpExponentCleanup",
"NestedArrayFunctionCallDecoder", "NestedArrayFunctionCallDecoder",
@ -97,6 +102,7 @@
}, },
"0.1.5": { "0.1.5": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ExpExponentCleanup", "ExpExponentCleanup",
"NestedArrayFunctionCallDecoder", "NestedArrayFunctionCallDecoder",
@ -117,6 +123,7 @@
}, },
"0.1.6": { "0.1.6": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"ExpExponentCleanup", "ExpExponentCleanup",
@ -139,6 +146,7 @@
}, },
"0.1.7": { "0.1.7": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"ExpExponentCleanup", "ExpExponentCleanup",
@ -161,6 +169,7 @@
}, },
"0.2.0": { "0.2.0": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -184,6 +193,7 @@
}, },
"0.2.1": { "0.2.1": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -207,6 +217,7 @@
}, },
"0.2.2": { "0.2.2": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -230,6 +241,7 @@
}, },
"0.3.0": { "0.3.0": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -255,6 +267,7 @@
}, },
"0.3.1": { "0.3.1": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -279,6 +292,7 @@
}, },
"0.3.2": { "0.3.2": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -303,6 +317,7 @@
}, },
"0.3.3": { "0.3.3": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -326,6 +341,7 @@
}, },
"0.3.4": { "0.3.4": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -349,6 +365,7 @@
}, },
"0.3.5": { "0.3.5": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -372,6 +389,7 @@
}, },
"0.3.6": { "0.3.6": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -393,6 +411,7 @@
}, },
"0.4.0": { "0.4.0": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -414,6 +433,7 @@
}, },
"0.4.1": { "0.4.1": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -435,6 +455,7 @@
}, },
"0.4.10": { "0.4.10": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -455,6 +476,7 @@
}, },
"0.4.11": { "0.4.11": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -474,6 +496,7 @@
}, },
"0.4.12": { "0.4.12": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -492,6 +515,7 @@
}, },
"0.4.13": { "0.4.13": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -510,6 +534,7 @@
}, },
"0.4.14": { "0.4.14": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -527,6 +552,7 @@
}, },
"0.4.15": { "0.4.15": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -543,6 +569,7 @@
}, },
"0.4.16": { "0.4.16": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -561,6 +588,7 @@
}, },
"0.4.17": { "0.4.17": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -580,6 +608,7 @@
}, },
"0.4.18": { "0.4.18": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -598,6 +627,7 @@
}, },
"0.4.19": { "0.4.19": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -617,6 +647,7 @@
}, },
"0.4.2": { "0.4.2": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -637,6 +668,7 @@
}, },
"0.4.20": { "0.4.20": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -656,6 +688,7 @@
}, },
"0.4.21": { "0.4.21": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -675,6 +708,7 @@
}, },
"0.4.22": { "0.4.22": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -694,6 +728,7 @@
}, },
"0.4.23": { "0.4.23": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -712,6 +747,7 @@
}, },
"0.4.24": { "0.4.24": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -730,6 +766,7 @@
}, },
"0.4.25": { "0.4.25": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -746,6 +783,7 @@
}, },
"0.4.26": { "0.4.26": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -759,6 +797,7 @@
}, },
"0.4.3": { "0.4.3": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -778,6 +817,7 @@
}, },
"0.4.4": { "0.4.4": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
"MemoryArrayCreationOverflow", "MemoryArrayCreationOverflow",
@ -796,6 +836,7 @@
}, },
"0.4.5": { "0.4.5": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -817,6 +858,7 @@
}, },
"0.4.6": { "0.4.6": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -837,6 +879,7 @@
}, },
"0.4.7": { "0.4.7": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -857,6 +900,7 @@
}, },
"0.4.8": { "0.4.8": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -877,6 +921,7 @@
}, },
"0.4.9": { "0.4.9": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -897,6 +942,7 @@
}, },
"0.5.0": { "0.5.0": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -913,6 +959,7 @@
}, },
"0.5.1": { "0.5.1": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -929,6 +976,7 @@
}, },
"0.5.10": { "0.5.10": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -941,6 +989,7 @@
}, },
"0.5.11": { "0.5.11": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -952,6 +1001,7 @@
}, },
"0.5.12": { "0.5.12": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -963,6 +1013,7 @@
}, },
"0.5.13": { "0.5.13": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -974,6 +1025,7 @@
}, },
"0.5.14": { "0.5.14": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
@ -987,6 +1039,7 @@
}, },
"0.5.15": { "0.5.15": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
@ -999,6 +1052,7 @@
}, },
"0.5.16": { "0.5.16": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
@ -1010,6 +1064,7 @@
}, },
"0.5.17": { "0.5.17": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
@ -1020,6 +1075,7 @@
}, },
"0.5.2": { "0.5.2": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1036,6 +1092,7 @@
}, },
"0.5.3": { "0.5.3": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1052,6 +1109,7 @@
}, },
"0.5.4": { "0.5.4": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1068,6 +1126,7 @@
}, },
"0.5.5": { "0.5.5": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1086,6 +1145,7 @@
}, },
"0.5.6": { "0.5.6": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1104,6 +1164,7 @@
}, },
"0.5.7": { "0.5.7": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1120,6 +1181,7 @@
}, },
"0.5.8": { "0.5.8": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1135,6 +1197,7 @@
}, },
"0.5.9": { "0.5.9": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"ImplicitConstructorCallvalueCheck", "ImplicitConstructorCallvalueCheck",
"TupleAssignmentMultiStackSlotComponents", "TupleAssignmentMultiStackSlotComponents",
@ -1149,6 +1212,7 @@
}, },
"0.6.0": { "0.6.0": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1161,6 +1225,7 @@
}, },
"0.6.1": { "0.6.1": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1172,24 +1237,28 @@
}, },
"0.6.10": { "0.6.10": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup" "DynamicArrayCleanup"
], ],
"released": "2020-06-11" "released": "2020-06-11"
}, },
"0.6.11": { "0.6.11": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup" "DynamicArrayCleanup"
], ],
"released": "2020-07-07" "released": "2020-07-07"
}, },
"0.6.12": { "0.6.12": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup" "DynamicArrayCleanup"
], ],
"released": "2020-07-22" "released": "2020-07-22"
}, },
"0.6.2": { "0.6.2": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1201,6 +1270,7 @@
}, },
"0.6.3": { "0.6.3": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1212,6 +1282,7 @@
}, },
"0.6.4": { "0.6.4": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1223,6 +1294,7 @@
}, },
"0.6.5": { "0.6.5": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1233,6 +1305,7 @@
}, },
"0.6.6": { "0.6.6": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1242,6 +1315,7 @@
}, },
"0.6.7": { "0.6.7": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"MissingEscapingInFormatting", "MissingEscapingInFormatting",
"ArraySliceDynamicallyEncodedBaseType", "ArraySliceDynamicallyEncodedBaseType",
@ -1251,12 +1325,14 @@
}, },
"0.6.8": { "0.6.8": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup" "DynamicArrayCleanup"
], ],
"released": "2020-05-14" "released": "2020-05-14"
}, },
"0.6.9": { "0.6.9": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"UsingForCalldata" "UsingForCalldata"
], ],
@ -1264,12 +1340,14 @@
}, },
"0.7.0": { "0.7.0": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup" "DynamicArrayCleanup"
], ],
"released": "2020-07-28" "released": "2020-07-28"
}, },
"0.7.1": { "0.7.1": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup", "DynamicArrayCleanup",
"FreeFunctionRedefinition" "FreeFunctionRedefinition"
], ],
@ -1277,12 +1355,15 @@
}, },
"0.7.2": { "0.7.2": {
"bugs": [ "bugs": [
"EmptyByteArrayCopy",
"DynamicArrayCleanup" "DynamicArrayCleanup"
], ],
"released": "2020-09-28" "released": "2020-09-28"
}, },
"0.7.3": { "0.7.3": {
"bugs": [], "bugs": [
"EmptyByteArrayCopy"
],
"released": "2020-10-07" "released": "2020-10-07"
} }
} }

View File

@ -4,3 +4,32 @@ Solidity IR-based Codegen Changes
This section highlights the main differences between the old and the IR-based codegen, This section highlights the main differences between the old and the IR-based codegen,
along with the reasoning behind the changes and how to update affected code. along with the reasoning behind the changes and how to update affected code.
Semantic Only Changes
=====================
This section lists the changes that are semantic-only, thus potentially
hiding new and different behavior in existing code.
* When storage structs are deleted, every storage slot that contains a member of the struct is set to zero entirely. Formally, padding space was left untouched.
Consequently, if the padding space within a struct is used to store data (e.g. in the context of a contract upgrade), you have to be aware that ``delete`` will now also clear the added member (while it wouldn't have been cleared in the past).
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0;
contract C {
struct S {
uint64 y;
uint64 z;
}
S s;
function f() public {
// ...
delete s;
// s occupies only first 16 bytes of the 32 bytes slot
// delete will write zero to the full slot
}
}
We have the same behavior for implicit delete, for example when array of structs is shortened.

View File

@ -256,7 +256,7 @@ struct ExpressionAnnotation: ASTAnnotation
/// Whether the expression is an lvalue that is only assigned. /// Whether the expression is an lvalue that is only assigned.
/// Would be false for --, ++, delete, +=, -=, .... /// Would be false for --, ++, delete, +=, -=, ....
/// Only relevant if isLvalue == true /// Only relevant if isLvalue == true
bool lValueOfOrdinaryAssignment; bool lValueOfOrdinaryAssignment = false;
/// Types and - if given - names of arguments if the expr. is a function /// Types and - if given - names of arguments if the expr. is a function
/// that is called, used for overload resolution /// that is called, used for overload resolution

View File

@ -125,6 +125,15 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons
// special case for short byte arrays: Store them together with their length. // special case for short byte arrays: Store them together with their length.
if (_targetType.isByteArray()) if (_targetType.isByteArray())
{ {
// stack: target_ref target_data_end source_length target_data_pos source_ref
_context << Instruction::DUP3;
evmasm::AssemblyItem nonEmptyByteArray = _context.appendConditionalJump();
// Empty source, just zero out the main slot.
_context << u256(0) << Instruction::DUP6 << Instruction::SSTORE;
_context.appendJumpTo(copyLoopEndWithoutByteOffset);
_context << nonEmptyByteArray;
// Non-empty source.
// stack: target_ref target_data_end source_length target_data_pos source_ref // stack: target_ref target_data_end source_length target_data_pos source_ref
_context << Instruction::DUP3 << u256(31) << Instruction::LT; _context << Instruction::DUP3 << u256(31) << Instruction::LT;
evmasm::AssemblyItem longByteArray = _context.appendConditionalJump(); evmasm::AssemblyItem longByteArray = _context.appendConditionalJump();

View File

@ -1266,9 +1266,21 @@ string YulUtilFunctions::clearStorageStructFunction(StructType const& _type)
MemberList::MemberMap structMembers = _type.nativeMembers(nullptr); MemberList::MemberMap structMembers = _type.nativeMembers(nullptr);
vector<map<string, string>> memberSetValues; vector<map<string, string>> memberSetValues;
set<u256> slotsCleared;
for (auto const& member: structMembers) for (auto const& member: structMembers)
if (member.type->storageBytes() < 32)
{
auto const& slotDiff = _type.storageOffsetsOfMember(member.name).first;
if (!slotsCleared.count(slotDiff))
{
memberSetValues.emplace_back().emplace("clearMember", "sstore(add(slot, " + slotDiff.str() + "), 0)");
slotsCleared.emplace(slotDiff);
}
}
else
{ {
auto const& [memberSlotDiff, memberStorageOffset] = _type.storageOffsetsOfMember(member.name); auto const& [memberSlotDiff, memberStorageOffset] = _type.storageOffsetsOfMember(member.name);
solAssert(memberStorageOffset == 0, "");
memberSetValues.emplace_back().emplace("clearMember", Whiskers(R"( memberSetValues.emplace_back().emplace("clearMember", Whiskers(R"(
<setZero>(add(slot, <memberSlotDiff>), <memberStorageOffset>) <setZero>(add(slot, <memberSlotDiff>), <memberStorageOffset>)

View File

@ -27,13 +27,6 @@
set -e set -e
if [[ "${TRAVIS_PULL_REQUEST_BRANCH}" != "" ]]; then
# Variable is set to the branch's name iff current job is a pull request,
# or is set to empty string if it is a push build.
echo "Skipping bytecode comparison."
exit 0
fi
REPO_ROOT="$(dirname "$0")"/../.. REPO_ROOT="$(dirname "$0")"/../..
if test -z "$1"; then if test -z "$1"; then
@ -120,34 +113,7 @@ EOF
$REPO_ROOT/scripts/bytecodecompare/prepare_report.py $REPO_ROOT/$BUILD_DIR/solc/solc $REPO_ROOT/scripts/bytecodecompare/prepare_report.py $REPO_ROOT/$BUILD_DIR/solc/solc
fi fi
if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ] cp report.txt $REPO_ROOT
then
openssl aes-256-cbc -K $encrypted_60701c962b9c_key -iv $encrypted_60701c962b9c_iv -in "$REPO_ROOT"/scripts/bytecodecompare/deploy_key.enc -out deploy_key -d
chmod 600 deploy_key
eval `ssh-agent -s`
ssh-add deploy_key
git clone --depth 2 git@github.com:ethereum/solidity-test-bytecode.git
cd solidity-test-bytecode
git config user.name "travis"
git config user.email "chris@ethereum.org"
git clean -f -d -x
DIRNAME=$(cd "$REPO_ROOT" && git show -s --format="%cd-%H" --date="format:%Y-%m-%d-%H-%M")
mkdir -p "$DIRNAME"
REPORT="$DIRNAME/$ZIP_SUFFIX.txt"
cp ../report.txt "$REPORT"
# Only push if adding actually worked, i.e. there were changes.
if git add "$REPORT" && git commit -a -m "Added report $REPORT"
then
git pull --rebase
git push origin
else
echo "Adding report failed, it might already exist in the repository."
fi
else
echo "Not storing bytecode because the keys are not available."
fi
) )
rm -rf "$TMPDIR" rm -rf "$TMPDIR"
echo "Storebytecode finished." echo "Storebytecode finished."

View File

@ -5,7 +5,7 @@ ROOTDIR="$(dirname "$0")/../.."
cd "${ROOTDIR}" cd "${ROOTDIR}"
# shellcheck disable=SC2166 # shellcheck disable=SC2166
if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n >prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" >prerelease.txt; fi if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n >prerelease.txt; fi
if [ -n "$CIRCLE_SHA1" ] if [ -n "$CIRCLE_SHA1" ]
then then
echo -n "$CIRCLE_SHA1" >commit_hash.txt echo -n "$CIRCLE_SHA1" >commit_hash.txt

View File

@ -5,17 +5,6 @@ ROOTDIR="/root/project"
BUILDDIR="${ROOTDIR}/build" BUILDDIR="${ROOTDIR}/build"
mkdir -p "${BUILDDIR}" && mkdir -p "$BUILDDIR/deps" mkdir -p "${BUILDDIR}" && mkdir -p "$BUILDDIR/deps"
ANTLRJAR="${ROOTDIR}/build/deps/antlr4.8.jar"
ANTLRJAR_URI="https://www.antlr.org/download/antlr-4.8-complete.jar"
download_antlr4()
{
if [[ ! -e "${ANTLRJAR}" ]]
then
wget -O "${ANTLRJAR}" "${ANTLRJAR_URI}"
fi
}
generate_protobuf_bindings() generate_protobuf_bindings()
{ {
cd "${ROOTDIR}"/test/tools/ossfuzz cd "${ROOTDIR}"/test/tools/ossfuzz
@ -26,21 +15,6 @@ generate_protobuf_bindings()
done done
} }
generate_antlr4_bindings()
{
cd "${ROOTDIR}"
# Replace boolean with bool to suit c++ syntax
sed -i 's/boolean /bool /g' docs/grammar/Solidity.g4
# Generate antlr4 visitor/parser/lexer c++ bindings
java -jar "${ANTLRJAR}" -Dlanguage=Cpp \
-Xexact-output-dir -package solidity::test::fuzzer -o test/tools/ossfuzz \
-no-listener -visitor docs/grammar/SolidityLexer.g4 docs/grammar/Solidity.g4
# Delete unnecessary autogen files
rm -f "${ROOTDIR}"/test/tools/ossfuzz/Solidity*Visitor.cpp \
"${ROOTDIR}"/test/tools/ossfuzz/Solidity*.interp \
"${ROOTDIR}"/test/tools/ossfuzz/Solidity*.tokens
}
build_fuzzers() build_fuzzers()
{ {
cd "${BUILDDIR}" cd "${BUILDDIR}"
@ -49,7 +23,5 @@ build_fuzzers()
make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j 4 make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j 4
} }
download_antlr4
generate_protobuf_bindings generate_protobuf_bindings
generate_antlr4_bindings
build_fuzzers build_fuzzers

View File

@ -1,3 +1,4 @@
if ( -not (Test-Path "$PSScriptRoot\..\deps\boost") ) {
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
# Needed for Invoke-WebRequest to work via CI. # Needed for Invoke-WebRequest to work via CI.
@ -16,3 +17,4 @@ cd boost_1_74_0
.\b2 -j4 -d0 link=static runtime-link=static variant=release threading=multi address-model=64 --with-filesystem --with-system --with-program_options --with-test --prefix="$PSScriptRoot\..\deps\boost" install .\b2 -j4 -d0 link=static runtime-link=static variant=release threading=multi address-model=64 --with-filesystem --with-system --with-program_options --with-test --prefix="$PSScriptRoot\..\deps\boost" install
if ( -not $? ) { throw "Error building boost." } if ( -not $? ) { throw "Error building boost." }
cd .. cd ..
}

View File

@ -622,6 +622,8 @@ BOOST_AUTO_TEST_CASE(for_loop_break_continue)
} }
} }
)"; )";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode); compileAndRun(sourceCode);
auto breakContinue = [](u256 const& n) -> u256 auto breakContinue = [](u256 const& n) -> u256
@ -643,6 +645,7 @@ BOOST_AUTO_TEST_CASE(for_loop_break_continue)
}; };
testContractAgainstCppOnRange("f(uint256)", breakContinue, 0, 10); testContractAgainstCppOnRange("f(uint256)", breakContinue, 0, 10);
);
} }
BOOST_AUTO_TEST_CASE(calling_other_functions) BOOST_AUTO_TEST_CASE(calling_other_functions)
@ -663,8 +666,6 @@ BOOST_AUTO_TEST_CASE(calling_other_functions)
} }
} }
)"; )";
compileAndRun(sourceCode);
auto evenStep_cpp = [](u256 const& n) -> u256 auto evenStep_cpp = [](u256 const& n) -> u256
{ {
return n / 2; return n / 2;
@ -687,12 +688,16 @@ BOOST_AUTO_TEST_CASE(calling_other_functions)
} }
return y; return y;
}; };
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(0)); testContractAgainstCpp("run(uint256)", collatz_cpp, u256(0));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(1)); testContractAgainstCpp("run(uint256)", collatz_cpp, u256(1));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(2)); testContractAgainstCpp("run(uint256)", collatz_cpp, u256(2));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(8)); testContractAgainstCpp("run(uint256)", collatz_cpp, u256(8));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(127)); testContractAgainstCpp("run(uint256)", collatz_cpp, u256(127));
)
} }
BOOST_AUTO_TEST_CASE(many_local_variables) BOOST_AUTO_TEST_CASE(many_local_variables)
@ -706,10 +711,6 @@ BOOST_AUTO_TEST_CASE(many_local_variables)
} }
} }
)"; )";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
auto f = [](u256 const& x1, u256 const& x2, u256 const& x3) -> u256 auto f = [](u256 const& x1, u256 const& x2, u256 const& x3) -> u256
{ {
u256 a = 0x1; u256 a = 0x1;
@ -718,6 +719,10 @@ BOOST_AUTO_TEST_CASE(many_local_variables)
u256 y = a + b + c + x1 + x2 + x3; u256 y = a + b + c + x1 + x2 + x3;
return y + b + x2; return y + b + x2;
}; };
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("run(uint256,uint256,uint256)", f, u256(0x1000), u256(0x10000), u256(0x100000)); testContractAgainstCpp("run(uint256,uint256,uint256)", f, u256(0x1000), u256(0x10000), u256(0x100000));
) )
} }
@ -823,12 +828,15 @@ BOOST_AUTO_TEST_CASE(small_signed_types)
} }
} }
)"; )";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode); compileAndRun(sourceCode);
auto small_signed_types_cpp = []() -> u256 auto small_signed_types_cpp = []() -> u256
{ {
return -int32_t(10) * -int64_t(20); return -int32_t(10) * -int64_t(20);
}; };
testContractAgainstCpp("run()", small_signed_types_cpp); testContractAgainstCpp("run()", small_signed_types_cpp);
);
} }
BOOST_AUTO_TEST_CASE(compound_assign) BOOST_AUTO_TEST_CASE(compound_assign)
@ -1154,10 +1162,13 @@ BOOST_AUTO_TEST_CASE(uncalled_blockhash)
} }
} }
)"; )";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(code, 0, "C"); compileAndRun(code, 0, "C");
bytes result = callContractFunction("f()"); bytes result = callContractFunction("f()");
BOOST_REQUIRE_EQUAL(result.size(), 32); BOOST_REQUIRE_EQUAL(result.size(), 32);
BOOST_CHECK(result[0] != 0 || result[1] != 0 || result[2] != 0); BOOST_CHECK(result[0] != 0 || result[1] != 0 || result[2] != 0);
)
} }
BOOST_AUTO_TEST_CASE(log0) BOOST_AUTO_TEST_CASE(log0)
@ -1325,6 +1336,8 @@ BOOST_AUTO_TEST_CASE(keccak256)
} }
} }
)"; )";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode); compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> u256 auto f = [&](u256 const& _x) -> u256
{ {
@ -1333,6 +1346,7 @@ BOOST_AUTO_TEST_CASE(keccak256)
testContractAgainstCpp("a(bytes32)", f, u256(4)); testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5)); testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1)); testContractAgainstCpp("a(bytes32)", f, u256(-1));
);
} }
BOOST_AUTO_TEST_CASE(sha256) BOOST_AUTO_TEST_CASE(sha256)
@ -1344,7 +1358,6 @@ BOOST_AUTO_TEST_CASE(sha256)
} }
} }
)"; )";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes auto f = [&](u256 const& _x) -> bytes
{ {
if (_x == u256(4)) if (_x == u256(4))
@ -1355,9 +1368,13 @@ BOOST_AUTO_TEST_CASE(sha256)
return fromHex("af9613760f72635fbdb44a5a0a63c39f12af30f950a6ee5c971be188e89c4051"); return fromHex("af9613760f72635fbdb44a5a0a63c39f12af30f950a6ee5c971be188e89c4051");
return fromHex(""); return fromHex("");
}; };
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4)); testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5)); testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1)); testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
} }
BOOST_AUTO_TEST_CASE(ripemd) BOOST_AUTO_TEST_CASE(ripemd)
@ -1369,7 +1386,6 @@ BOOST_AUTO_TEST_CASE(ripemd)
} }
} }
)"; )";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes auto f = [&](u256 const& _x) -> bytes
{ {
if (_x == u256(4)) if (_x == u256(4))
@ -1380,9 +1396,13 @@ BOOST_AUTO_TEST_CASE(ripemd)
return fromHex("1cf4e77f5966e13e109703cd8a0df7ceda7f3dc3000000000000000000000000"); return fromHex("1cf4e77f5966e13e109703cd8a0df7ceda7f3dc3000000000000000000000000");
return fromHex(""); return fromHex("");
}; };
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4)); testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5)); testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1)); testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
} }
BOOST_AUTO_TEST_CASE(packed_keccak256) BOOST_AUTO_TEST_CASE(packed_keccak256)
@ -1396,7 +1416,6 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
} }
} }
)"; )";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> u256 auto f = [&](u256 const& _x) -> u256
{ {
return util::keccak256( return util::keccak256(
@ -1407,9 +1426,13 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
toBigEndian(u256(256)) toBigEndian(u256(256))
); );
}; };
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4)); testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5)); testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1)); testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
} }
BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types) BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
@ -1428,6 +1451,8 @@ BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
} }
} }
)"; )";
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode); compileAndRun(sourceCode);
// Strangely, arrays are encoded with intra-element padding. // Strangely, arrays are encoded with intra-element padding.
ABI_CHECK(callContractFunction("f()"), encodeArgs( ABI_CHECK(callContractFunction("f()"), encodeArgs(
@ -1435,6 +1460,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
util::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))), util::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
util::keccak256(fromHex(m_contractAddress.hex() + "26121ff0")) util::keccak256(fromHex(m_contractAddress.hex() + "26121ff0"))
)); ));
)
} }
BOOST_AUTO_TEST_CASE(packed_sha256) BOOST_AUTO_TEST_CASE(packed_sha256)
@ -1448,7 +1474,6 @@ BOOST_AUTO_TEST_CASE(packed_sha256)
} }
} }
)"; )";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes auto f = [&](u256 const& _x) -> bytes
{ {
if (_x == u256(4)) if (_x == u256(4))
@ -1459,9 +1484,13 @@ BOOST_AUTO_TEST_CASE(packed_sha256)
return fromHex("f14def4d07cd185ddd8b10a81b2238326196a38867e6e6adbcc956dc913488c7"); return fromHex("f14def4d07cd185ddd8b10a81b2238326196a38867e6e6adbcc956dc913488c7");
return fromHex(""); return fromHex("");
}; };
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4)); testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5)); testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1)); testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
} }
BOOST_AUTO_TEST_CASE(packed_ripemd160) BOOST_AUTO_TEST_CASE(packed_ripemd160)
@ -1475,7 +1504,6 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160)
} }
} }
)"; )";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes auto f = [&](u256 const& _x) -> bytes
{ {
if (_x == u256(4)) if (_x == u256(4))
@ -1486,9 +1514,13 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160)
return fromHex("c0a2e4b1f3ff766a9a0089e7a410391730872495000000000000000000000000"); return fromHex("c0a2e4b1f3ff766a9a0089e7a410391730872495000000000000000000000000");
return fromHex(""); return fromHex("");
}; };
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4)); testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5)); testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1)); testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls) BOOST_AUTO_TEST_CASE(inter_contract_calls)

View File

@ -0,0 +1,28 @@
contract C {
bytes data;
bytes otherData;
function fromMemory() public returns (byte) {
bytes memory t;
uint[2] memory x;
x[0] = type(uint).max;
data = t;
data.push();
return data[0];
}
function fromCalldata(bytes calldata x) public returns (byte) {
data = x;
data.push();
return data[0];
}
function fromStorage() public returns (byte) {
// zero-length but dirty higher order bits
assembly { sstore(otherData.slot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) }
data = otherData;
data.push();
return data[0];
}
}
// ----
// fromMemory() -> 0x00
// fromCalldata(bytes): 0x40, 0x60, 0x00, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
// fromStorage() -> 0x00

View File

@ -0,0 +1,35 @@
contract C {
struct S {
uint32 a;
S[] x;
}
S s;
function f() public returns (uint256 r1, uint256 r2, uint256 r3) {
assembly {
// 2 ** 150 - 1
sstore(s.slot, 1427247692705959881058285969449495136382746623)
}
s.a = 1;
s.x.push(); s.x.push();
S storage ptr1 = s.x[0];
S storage ptr2 = s.x[1];
assembly {
// 2 ** 150 - 1
sstore(ptr1.slot, 1427247692705959881058285969449495136382746623)
sstore(ptr2.slot, 1427247692705959881058285969449495136382746623)
}
s.x[0].a = 2; s.x[1].a = 3;
delete s;
assert(s.a == 0);
assert(s.x.length == 0);
assembly {
r1 := sload(s.slot)
r2 := sload(ptr1.slot)
r3 := sload(ptr2.slot)
}
}
}
// ====
// compileViaYul: true
// ----
// f() -> 0, 0, 0

View File

@ -0,0 +1,24 @@
contract C {
struct S {
uint64 y;
uint64 z;
}
S s;
function f() public returns (uint256 ret) {
assembly {
// 2 ** 150 - 1
sstore(s.slot, 1427247692705959881058285969449495136382746623)
}
s.y = 1; s.z = 2;
delete s;
assert(s.y == 0);
assert(s.z == 0);
assembly {
ret := sload(s.slot)
}
}
}
// ====
// compileViaYul: true
// ----
// f() -> 0

View File

@ -0,0 +1,29 @@
contract C {
struct S {
uint32 a;
uint32[3] b;
uint32[] x;
}
S s;
function f() public returns (uint256 ret) {
assembly {
// 2 ** 150 - 1
sstore(s.slot, 1427247692705959881058285969449495136382746623)
}
s.a = 1;
s.b[0] = 2; s.b[1] = 3;
s.x.push(4); s.x.push(5);
delete s;
assert(s.a == 0);
assert(s.b[0] == 0);
assert(s.b[1] == 0);
assert(s.x.length == 0);
assembly {
ret := sload(s.slot)
}
}
}
// ====
// compileViaYul: true
// ----
// f() -> 0

View File

@ -27,30 +27,16 @@ if (OSSFUZZ)
solc_opt_ossfuzz.cpp solc_opt_ossfuzz.cpp
../fuzzer_common.cpp ../fuzzer_common.cpp
../../TestCaseReader.cpp ../../TestCaseReader.cpp
SolidityLexer.cpp
SolidityParser.cpp
) )
target_compile_options(solc_opt_ossfuzz target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm)
PUBLIC
${COMPILE_OPTIONS} -Wno-extra-semi -Wno-unused-parameter
)
target_include_directories(solc_opt_ossfuzz PRIVATE /usr/include/antlr4-runtime)
target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm antlr4-runtime)
set_target_properties(solc_opt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) set_target_properties(solc_opt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
add_executable(solc_noopt_ossfuzz add_executable(solc_noopt_ossfuzz
solc_noopt_ossfuzz.cpp solc_noopt_ossfuzz.cpp
../fuzzer_common.cpp ../fuzzer_common.cpp
../../TestCaseReader.cpp ../../TestCaseReader.cpp
SolidityLexer.cpp
SolidityParser.cpp
) )
target_compile_options(solc_noopt_ossfuzz target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm)
PUBLIC
${COMPILE_OPTIONS} -Wno-extra-semi -Wno-unused-parameter
)
target_include_directories(solc_noopt_ossfuzz PRIVATE /usr/include/antlr4-runtime)
target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm antlr4-runtime)
set_target_properties(solc_noopt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE}) set_target_properties(solc_noopt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
add_executable(const_opt_ossfuzz const_opt_ossfuzz.cpp ../fuzzer_common.cpp) add_executable(const_opt_ossfuzz const_opt_ossfuzz.cpp ../fuzzer_common.cpp)