mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[ewasm] add ewasm bytecode compare support.
This commit is contained in:
parent
158154bac3
commit
aa40583f1d
@ -902,7 +902,9 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: build
|
||||
- run: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-ubuntu.txt
|
||||
- run:
|
||||
no_output_timeout: 60m
|
||||
command: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-ubuntu.txt
|
||||
- store_artifacts:
|
||||
path: report.txt
|
||||
- persist_to_workspace:
|
||||
@ -919,7 +921,9 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-osx.txt
|
||||
- run:
|
||||
no_output_timeout: 60m
|
||||
command: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-osx.txt
|
||||
- store_artifacts:
|
||||
path: report.txt
|
||||
- persist_to_workspace:
|
||||
@ -936,7 +940,9 @@ jobs:
|
||||
- attach_workspace:
|
||||
at: build
|
||||
- run: python scripts\isolate_tests.py test\
|
||||
- run: python scripts\bytecodecompare\prepare_report.py build\solc\Release\solc.exe
|
||||
- run:
|
||||
no_output_timeout: 60m
|
||||
command: python scripts\bytecodecompare\prepare_report.py build\solc\Release\solc.exe
|
||||
- run: cp report.txt bytecode-report-windows.txt
|
||||
- store_artifacts:
|
||||
path: report.txt
|
||||
@ -954,7 +960,9 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: emscripten_build/libsolc
|
||||
- run: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-emscripten.txt
|
||||
- run:
|
||||
no_output_timeout: 60m
|
||||
command: scripts/bytecodecompare/storebytecode.sh && cp -v report.txt bytecode-report-emscripten.txt
|
||||
- store_artifacts:
|
||||
path: report.txt
|
||||
- persist_to_workspace:
|
||||
|
@ -10,34 +10,41 @@ REPORT_FILE = open("report.txt", mode="w", encoding='utf8', newline='\n')
|
||||
|
||||
for optimize in [False, True]:
|
||||
for f in sorted(glob.glob("*.sol")):
|
||||
sources = {}
|
||||
sources[f] = {'content': open(f, mode='r', encoding='utf8').read()}
|
||||
input_json = {
|
||||
'language': 'Solidity',
|
||||
'sources': sources,
|
||||
'settings': {
|
||||
'optimizer': {
|
||||
'enabled': optimize
|
||||
},
|
||||
'outputSelection': {'*': {'*': ['evm.bytecode.object', 'metadata']}},
|
||||
'modelChecker': { "engine": 'none' }
|
||||
for output_type in [['evm.bytecode.object', 'metadata'], ['ewasm.wast', 'ewasm.wasm', 'metadata']]:
|
||||
sources = {}
|
||||
sources[f] = {'content': open(f, mode='r', encoding='utf8').read()}
|
||||
input_json = {
|
||||
'language': 'Solidity',
|
||||
'sources': sources,
|
||||
'settings': {
|
||||
'optimizer': {
|
||||
'enabled': optimize
|
||||
},
|
||||
'outputSelection': {'*': {'*': output_type}},
|
||||
'modelChecker': {"engine": 'none'}
|
||||
}
|
||||
}
|
||||
}
|
||||
args = [SOLC_BIN, '--standard-json']
|
||||
if optimize:
|
||||
args += ['--optimize']
|
||||
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(out, err) = proc.communicate(json.dumps(input_json).encode('utf-8'))
|
||||
try:
|
||||
result = json.loads(out.decode('utf-8').strip())
|
||||
for filename in sorted(result['contracts'].keys()):
|
||||
for contractName in sorted(result['contracts'][filename].keys()):
|
||||
contractData = result['contracts'][filename][contractName]
|
||||
if 'evm' in contractData and 'bytecode' in contractData['evm']:
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' ' +
|
||||
contractData['evm']['bytecode']['object'] + '\n')
|
||||
else:
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' NO BYTECODE\n')
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
|
||||
except KeyError:
|
||||
REPORT_FILE.write(f + ": ERROR\n")
|
||||
args = [SOLC_BIN, '--standard-json']
|
||||
if optimize:
|
||||
args += ['--optimize']
|
||||
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(out, err) = proc.communicate(json.dumps(input_json).encode('utf-8'))
|
||||
try:
|
||||
result = json.loads(out.decode('utf-8').strip())
|
||||
for filename in sorted(result['contracts'].keys()):
|
||||
for contractName in sorted(result['contracts'][filename].keys()):
|
||||
outputType = ""
|
||||
if 'ewasm.wast' in output_type:
|
||||
outputType = "(ewasm)"
|
||||
contractData = result['contracts'][filename][contractName]
|
||||
if 'evm' in contractData and 'bytecode' in contractData['evm']:
|
||||
REPORT_FILE.write(filename + ':' + contractName + ' ' +
|
||||
contractData['evm']['bytecode']['object'] + '\n')
|
||||
elif 'ewasm' in contractData and 'wasm' in contractData['ewasm']:
|
||||
REPORT_FILE.write(filename + ':' + contractName + outputType +
|
||||
contractData['ewasm']['wasm'] + '\n')
|
||||
else:
|
||||
REPORT_FILE.write(filename + ':' + contractName + outputType + ' NO BYTECODE\n')
|
||||
REPORT_FILE.write(filename + ':' + contractName + outputType + ' ' + contractData['metadata'] + '\n')
|
||||
except KeyError:
|
||||
REPORT_FILE.write(f + ": ERROR\n")
|
||||
|
Loading…
Reference in New Issue
Block a user