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\.."
if ("$Env:FORCE_RELEASE") {
if ("$Env:FORCE_RELEASE" -Or "$Env:CIRCLE_TAG") {
New-Item prerelease.txt -type file
Write-Host "Building release version."
}

View File

@ -481,7 +481,7 @@ jobs:
steps:
- checkout
- run: *run_build
- persist_to_workspace: *artifacts_build_dir
- persist_to_workspace: *artifacts_executables
t_ubu_codecov:
<<: *test_ubuntu2004
@ -574,12 +574,14 @@ jobs:
- checkout
- restore_cache:
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:
name: Install build dependencies
command: ./.circleci/osx_install_dependencies.sh
- 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:
- /usr/local/bin
- /usr/local/sbin
@ -590,7 +592,12 @@ jobs:
- run: *run_build
- store_artifacts: *artifacts_solc
- 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:
macos:
@ -603,9 +610,9 @@ jobs:
- checkout
- restore_cache:
keys:
- dependencies-osx-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum ".circleci/osx_install_dependencies.sh" }}
- dependencies-osx-{{ checksum ".circleci/osx_install_dependencies.sh" }}
- attach_workspace:
at: build
at: .
- run: *run_soltest
- store_test_results: *store_test_results
- store_artifacts: *artifacts_test_results
@ -619,9 +626,9 @@ jobs:
- checkout
- restore_cache:
keys:
- dependencies-osx-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum ".circleci/osx_install_dependencies.sh" }}
- dependencies-osx-{{ checksum ".circleci/osx_install_dependencies.sh" }}
- attach_workspace:
at: build
at: .
- run: *run_cmdline_tests
- store_artifacts: *artifacts_test_results
@ -902,14 +909,14 @@ jobs:
- restore_cache:
keys:
- 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"
command: if ( -not (Test-Path .\deps\boost) ) { .\scripts\install_deps.ps1 }
command: .\scripts\install_deps.ps1
- save_cache:
key: dependencies-win-{{ checksum "scripts/install_deps.ps1" }}
paths:
- .\deps\boost
- .\deps\cmake
- .\deps
- run:
name: "Building solidity"
command: .circleci/build_win.ps1
@ -917,7 +924,11 @@ jobs:
name: "Run solc.exe to make sure build was successful."
command: .\build\solc\Release\solc.exe --version
- 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
@ -943,6 +954,81 @@ jobs:
t_win_release:
<<: *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:
version: 2
@ -1000,6 +1086,26 @@ workflows:
- t_win: *workflow_win
- 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:
triggers:

View File

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

View File

@ -1266,19 +1266,31 @@ string YulUtilFunctions::clearStorageStructFunction(StructType const& _type)
MemberList::MemberMap structMembers = _type.nativeMembers(nullptr);
vector<map<string, string>> memberSetValues;
set<u256> slotsCleared;
for (auto const& member: structMembers)
{
auto const& [memberSlotDiff, memberStorageOffset] = _type.storageOffsetsOfMember(member.name);
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);
solAssert(memberStorageOffset == 0, "");
memberSetValues.emplace_back().emplace("clearMember", Whiskers(R"(
<setZero>(add(slot, <memberSlotDiff>), <memberStorageOffset>)
)")
("setZero", storageSetToZeroFunction(*member.type))
("memberSlotDiff", memberSlotDiff.str())
("memberStorageOffset", to_string(memberStorageOffset))
.render()
);
}
memberSetValues.emplace_back().emplace("clearMember", Whiskers(R"(
<setZero>(add(slot, <memberSlotDiff>), <memberStorageOffset>)
)")
("setZero", storageSetToZeroFunction(*member.type))
("memberSlotDiff", memberSlotDiff.str())
("memberStorageOffset", to_string(memberStorageOffset))
.render()
);
}
return Whiskers(R"(
function <functionName>(slot) {

View File

@ -27,13 +27,6 @@
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")"/../..
if test -z "$1"; then
@ -120,34 +113,7 @@ EOF
$REPO_ROOT/scripts/bytecodecompare/prepare_report.py $REPO_ROOT/$BUILD_DIR/solc/solc
fi
if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]
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
cp report.txt $REPO_ROOT
)
rm -rf "$TMPDIR"
echo "Storebytecode finished."
echo "Storebytecode finished."

View File

@ -5,7 +5,7 @@ ROOTDIR="$(dirname "$0")/../.."
cd "${ROOTDIR}"
# 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" ]
then
echo -n "$CIRCLE_SHA1" >commit_hash.txt

View File

@ -5,17 +5,6 @@ ROOTDIR="/root/project"
BUILDDIR="${ROOTDIR}/build"
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()
{
cd "${ROOTDIR}"/test/tools/ossfuzz
@ -26,21 +15,6 @@ generate_protobuf_bindings()
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()
{
cd "${BUILDDIR}"
@ -49,7 +23,5 @@ build_fuzzers()
make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j 4
}
download_antlr4
generate_protobuf_bindings
generate_antlr4_bindings
build_fuzzers
build_fuzzers

View File

@ -1,18 +1,20 @@
$ErrorActionPreference = "Stop"
if ( -not (Test-Path "$PSScriptRoot\..\deps\boost") ) {
$ErrorActionPreference = "Stop"
# Needed for Invoke-WebRequest to work via CI.
$progressPreference = "silentlyContinue"
# Needed for Invoke-WebRequest to work via CI.
$progressPreference = "silentlyContinue"
New-Item -ItemType Directory -Force -Path "$PSScriptRoot\..\deps"
New-Item -ItemType Directory -Force -Path "$PSScriptRoot\..\deps"
Invoke-WebRequest -URI "https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-win64-x64.zip" -OutFile cmake.zip
tar -xf cmake.zip
mv cmake-3.18.2-win64-x64 "$PSScriptRoot\..\deps\cmake"
Invoke-WebRequest -URI "https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-win64-x64.zip" -OutFile cmake.zip
tar -xf cmake.zip
mv cmake-3.18.2-win64-x64 "$PSScriptRoot\..\deps\cmake"
Invoke-WebRequest -URI "https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.zip" -OutFile boost.zip
tar -xf boost.zip
cd boost_1_74_0
.\bootstrap.bat
.\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." }
cd ..
Invoke-WebRequest -URI "https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.zip" -OutFile boost.zip
tar -xf boost.zip
cd boost_1_74_0
.\bootstrap.bat
.\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." }
cd ..
}

View File

@ -622,27 +622,30 @@ BOOST_AUTO_TEST_CASE(for_loop_break_continue)
}
}
)";
compileAndRun(sourceCode);
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
auto breakContinue = [](u256 const& n) -> u256
{
u256 i = 1;
u256 k = 0;
for (i *= 5; k < n; i *= 7)
auto breakContinue = [](u256 const& n) -> u256
{
k++;
i += 4;
if (n % 3 == 0)
break;
i += 9;
if (n % 2 == 0)
continue;
i += 19;
}
return i;
};
u256 i = 1;
u256 k = 0;
for (i *= 5; k < n; i *= 7)
{
k++;
i += 4;
if (n % 3 == 0)
break;
i += 9;
if (n % 2 == 0)
continue;
i += 19;
}
return i;
};
testContractAgainstCppOnRange("f(uint256)", breakContinue, 0, 10);
testContractAgainstCppOnRange("f(uint256)", breakContinue, 0, 10);
);
}
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
{
return n / 2;
@ -687,12 +688,16 @@ BOOST_AUTO_TEST_CASE(calling_other_functions)
}
return y;
};
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(0));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(1));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(2));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(8));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(127));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(0));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(1));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(2));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(8));
testContractAgainstCpp("run(uint256)", collatz_cpp, u256(127));
)
}
BOOST_AUTO_TEST_CASE(many_local_variables)
@ -706,18 +711,18 @@ BOOST_AUTO_TEST_CASE(many_local_variables)
}
}
)";
auto f = [](u256 const& x1, u256 const& x2, u256 const& x3) -> u256
{
u256 a = 0x1;
u256 b = 0x10;
u256 c = 0x100;
u256 y = a + b + c + x1 + x2 + x3;
return y + b + x2;
};
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
auto f = [](u256 const& x1, u256 const& x2, u256 const& x3) -> u256
{
u256 a = 0x1;
u256 b = 0x10;
u256 c = 0x100;
u256 y = a + b + c + x1 + x2 + x3;
return y + b + x2;
};
testContractAgainstCpp("run(uint256,uint256,uint256)", f, u256(0x1000), u256(0x10000), u256(0x100000));
)
}
@ -823,12 +828,15 @@ BOOST_AUTO_TEST_CASE(small_signed_types)
}
}
)";
compileAndRun(sourceCode);
auto small_signed_types_cpp = []() -> u256
{
return -int32_t(10) * -int64_t(20);
};
testContractAgainstCpp("run()", small_signed_types_cpp);
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
auto small_signed_types_cpp = []() -> u256
{
return -int32_t(10) * -int64_t(20);
};
testContractAgainstCpp("run()", small_signed_types_cpp);
);
}
BOOST_AUTO_TEST_CASE(compound_assign)
@ -1154,10 +1162,13 @@ BOOST_AUTO_TEST_CASE(uncalled_blockhash)
}
}
)";
compileAndRun(code, 0, "C");
bytes result = callContractFunction("f()");
BOOST_REQUIRE_EQUAL(result.size(), 32);
BOOST_CHECK(result[0] != 0 || result[1] != 0 || result[2] != 0);
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(code, 0, "C");
bytes result = callContractFunction("f()");
BOOST_REQUIRE_EQUAL(result.size(), 32);
BOOST_CHECK(result[0] != 0 || result[1] != 0 || result[2] != 0);
)
}
BOOST_AUTO_TEST_CASE(log0)
@ -1325,14 +1336,17 @@ BOOST_AUTO_TEST_CASE(keccak256)
}
}
)";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> u256
{
return util::keccak256(toBigEndian(_x));
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> u256
{
return util::keccak256(toBigEndian(_x));
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
);
}
BOOST_AUTO_TEST_CASE(sha256)
@ -1344,7 +1358,6 @@ BOOST_AUTO_TEST_CASE(sha256)
}
}
)";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes
{
if (_x == u256(4))
@ -1355,9 +1368,13 @@ BOOST_AUTO_TEST_CASE(sha256)
return fromHex("af9613760f72635fbdb44a5a0a63c39f12af30f950a6ee5c971be188e89c4051");
return fromHex("");
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
}
BOOST_AUTO_TEST_CASE(ripemd)
@ -1369,7 +1386,6 @@ BOOST_AUTO_TEST_CASE(ripemd)
}
}
)";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes
{
if (_x == u256(4))
@ -1380,9 +1396,13 @@ BOOST_AUTO_TEST_CASE(ripemd)
return fromHex("1cf4e77f5966e13e109703cd8a0df7ceda7f3dc3000000000000000000000000");
return fromHex("");
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
}
BOOST_AUTO_TEST_CASE(packed_keccak256)
@ -1396,7 +1416,6 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
}
}
)";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> u256
{
return util::keccak256(
@ -1407,9 +1426,13 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
toBigEndian(u256(256))
);
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
}
BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
@ -1428,13 +1451,16 @@ BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
}
}
)";
compileAndRun(sourceCode);
// Strangely, arrays are encoded with intra-element padding.
ABI_CHECK(callContractFunction("f()"), encodeArgs(
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"))
));
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
// Strangely, arrays are encoded with intra-element padding.
ABI_CHECK(callContractFunction("f()"), encodeArgs(
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"))
));
)
}
BOOST_AUTO_TEST_CASE(packed_sha256)
@ -1448,7 +1474,6 @@ BOOST_AUTO_TEST_CASE(packed_sha256)
}
}
)";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes
{
if (_x == u256(4))
@ -1459,9 +1484,13 @@ BOOST_AUTO_TEST_CASE(packed_sha256)
return fromHex("f14def4d07cd185ddd8b10a81b2238326196a38867e6e6adbcc956dc913488c7");
return fromHex("");
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
}
BOOST_AUTO_TEST_CASE(packed_ripemd160)
@ -1475,7 +1504,6 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160)
}
}
)";
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> bytes
{
if (_x == u256(4))
@ -1486,9 +1514,13 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160)
return fromHex("c0a2e4b1f3ff766a9a0089e7a410391730872495000000000000000000000000");
return fromHex("");
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
compileAndRun(sourceCode);
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
testContractAgainstCpp("a(bytes32)", f, u256(-1));
)
}
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
../fuzzer_common.cpp
../../TestCaseReader.cpp
SolidityLexer.cpp
SolidityParser.cpp
)
target_compile_options(solc_opt_ossfuzz
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)
target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm)
set_target_properties(solc_opt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
add_executable(solc_noopt_ossfuzz
solc_noopt_ossfuzz.cpp
../fuzzer_common.cpp
../../TestCaseReader.cpp
SolidityLexer.cpp
SolidityParser.cpp
)
target_compile_options(solc_noopt_ossfuzz
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)
target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm)
set_target_properties(solc_noopt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
add_executable(const_opt_ossfuzz const_opt_ossfuzz.cpp ../fuzzer_common.cpp)