Skip to content

Commit

Permalink
Merge pull request #14678 from ethereum/fix-no-output-timeout-in-js-b…
Browse files Browse the repository at this point in the history
…ytecode-report

Make JS version of bytecode report indicate progress on stdout to prevent CI timeouts
  • Loading branch information
cameel authored Nov 10, 2023
2 parents 90b046a + d668330 commit 58811f1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ commands:
steps:
- run:
name: Generate bytecode reports for the selected preset
no_output_timeout: 30m
command: |
.circleci/parallel_bytecode_report.sh \
"<< parameters.label >>" \
Expand Down
2 changes: 1 addition & 1 deletion .circleci/parallel_bytecode_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ else
# shellcheck disable=SC2035
./prepare_report.js \
--preset "$preset" \
*.sol > "../bytecode-report-${label}-${preset}.txt"
*.sol --report-file "../bytecode-report-${label}-${preset}.txt"
fi
38 changes: 32 additions & 6 deletions scripts/bytecodecompare/prepare_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function cleanString(string)
let inputFiles = []
let stripSMTPragmas = false
let presets = []
let reportFilePath = undefined

for (let i = 2; i < process.argv.length; ++i)
{
Expand All @@ -45,10 +46,26 @@ for (let i = 2; i < process.argv.length; ++i)
presets.push(process.argv[i + 1])
++i;
}
else if (process.argv[i] === '--report-file')
{
if (reportFilePath !== undefined)
throw Error("Option --report-file was specified multiple times.")

if (i + 1 === process.argv.length)
throw Error("Option --report-file was used, but no file name given.")

reportFilePath = process.argv[i + 1]
++i;
}
else
inputFiles.push(process.argv[i])
}

if (reportFilePath === undefined)
throw Error("Use --report-file option to specify the report file path.")

let reportFile = fs.createWriteStream(reportFilePath, {flags : 'w'});

if (presets.length === 0)
presets = ['legacy-no-optimize', 'legacy-optimize']

Expand Down Expand Up @@ -113,8 +130,11 @@ for (const preset of presets)
Object.keys(result['contracts']).length === 0 ||
Object.keys(result['contracts']).every(file => Object.keys(result['contracts'][file]).length === 0)
)
{
// NOTE: do not exit here because this may be run on source which cannot be compiled
console.log(filename + ': <ERROR>')
reportFile.write(filename + ': <ERROR>\n')
process.stdout.write('E')
}
else
for (const contractFile in result['contracts'])
for (const contractName in result['contracts'][contractFile])
Expand All @@ -123,6 +143,12 @@ for (const preset of presets)

let bytecode = '<NO BYTECODE>'
let metadata = '<NO METADATA>'
let progressIndicator = '.'

if ('metadata' in contractResults && cleanString(contractResults.metadata) !== undefined)
metadata = contractResults.metadata
else
progressIndicator = 'M'

if (
'evm' in contractResults &&
Expand All @@ -131,12 +157,12 @@ for (const preset of presets)
cleanString(contractResults.evm.bytecode.object) !== undefined
)
bytecode = cleanString(contractResults.evm.bytecode.object)
else
progressIndicator = 'B'

if ('metadata' in contractResults && cleanString(contractResults.metadata) !== undefined)
metadata = contractResults.metadata

console.log(filename + ':' + contractName + ' ' + bytecode)
console.log(filename + ':' + contractName + ' ' + metadata)
reportFile.write(filename + ':' + contractName + ' ' + bytecode + '\n')
reportFile.write(filename + ':' + contractName + ' ' + metadata + '\n')
process.stdout.write(progressIndicator)
}
}
}
2 changes: 1 addition & 1 deletion scripts/solc-bin/bytecode_reports_for_modified_binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ for binary_name in $platform_binaries; do
"$solidity_version_and_commit"

# shellcheck disable=SC2035
./prepare_report.js --strip-smt-pragmas *.sol > "${report_dir}/report-${binary_name}.txt"
./prepare_report.js --strip-smt-pragmas *.sol --report-file "${report_dir}/report-${binary_name}.txt"
else
yul_optimizer_flags=()
if [[ $solidity_version == 0.6.0 ]] || [[ $solidity_version == 0.6.1 ]]; then
Expand Down

0 comments on commit 58811f1

Please sign in to comment.