Skip to content

Commit

Permalink
hotfix js bug, v0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
cdump committed Jun 25, 2024
1 parent 892d8ab commit 7cbe2cf
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ See [examples](./examples) for more

See [benchmark/README.md](./benchmark/) for the methodology and commands to reproduce these results

<i>versions: evmole v0.3.5; <a href="https://github.com/shazow/whatsabi">whatsabi</a> v0.12.0; <a href="https://github.com/acuarica/evm">sevm</a> v0.6.17; <a href="https://github.com/g00dv1n/evm-hound-rs">evm-hound-rs</a> v0.1.4; <a href="https://github.com/Jon-Becker/heimdall-rs">heimdall-rs</a> v0.7.3</i>
<i>versions: evmole v0.3.6; <a href="https://github.com/shazow/whatsabi">whatsabi</a> v0.12.0; <a href="https://github.com/acuarica/evm">sevm</a> v0.6.17; <a href="https://github.com/g00dv1n/evm-hound-rs">evm-hound-rs</a> v0.1.4; <a href="https://github.com/Jon-Becker/heimdall-rs">heimdall-rs</a> v0.7.3</i>

<sup>(*)</sup>: <b>sevm</b> and <b>heimdall-rs</b> are full decompilers, not limited to extracting function selectors

Expand Down
2 changes: 1 addition & 1 deletion benchmark/providers/evmole-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ DS=$2

BDIR=`pwd`/benchmark

# MODE=selectors
MODE=arguments

case $1 in
js)
ln -s `pwd`/js ${BDIR}/providers/evmole-js 2>/dev/null || true
node ${BDIR}/providers/evmole-js/main.mjs \
arguments \
${MODE} \
${BDIR}/datasets/${2} \
out.json \
${BDIR}/results/etherscan.selectors_${2}.json \
Expand All @@ -21,7 +24,7 @@ case $1 in
cargo run \
--manifest-path benchmark/providers/evmole-rs/Cargo.toml \
--features "evmole/trace" \
arguments \
${MODE} \
${BDIR}/datasets/${2} \
out.json \
${BDIR}/results/etherscan.selectors_${2}.json \
Expand All @@ -33,7 +36,7 @@ case $1 in
PYTHONPATH=`pwd` \
python3.12 \
${BDIR}/providers/evmole-py/main.py \
arguments \
${MODE} \
${BDIR}/datasets/${2} \
out.json \
${BDIR}/results/etherscan.selectors_${2}.json \
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "evmole",
"version": "0.3.5",
"version": "0.3.6",
"description": "Extracts function selectors and arguments from EVM bytecode",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
Expand Down
8 changes: 7 additions & 1 deletion js/src/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,13 @@ export function functionArguments(code, selector, gas_limit = 5e4) {

const E256M1 = (1n << 256n) - 1n

if (rl.offset == 0 && rl.add_val == 0 && rl.path.length != 0 && uint8ArrayToBigInt(r.data) === 0n && ot_val == E256M1) {
if (
rl.offset == 0 &&
rl.add_val == 0 &&
rl.path.length != 0 &&
uint8ArrayToBigInt(r.data) === 0n &&
ot_val == E256M1
) {
vm.stack.peek().data = bigIntToUint8Array(0n)
}
const add = (ot_val + BigInt(rl.add_val)) & E256M1
Expand Down
6 changes: 5 additions & 1 deletion js/src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function process(vm, gasLimit) {
let gasUsed = 0

while (!vm.stopped) {
// console.log('selectors', selectors)
// console.log(vm.toString())
let ret
try {
Expand Down Expand Up @@ -82,9 +83,12 @@ function process(vm, gasLimit) {
const p = vm.stack.peek()
if (p.data.slice(-4).every((v, i) => v === vm.calldata.data[i])) {
p.label = 'signature'
} else if (r1.label === 'mulsig') {
} else {
p.label = 'mulsig'
}
} else if (r1.label === 'mulsig') {
const p = vm.stack.peek()
p.label = 'mulsig'
}
break

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "evmole"
version = "0.3.5"
version = "0.3.6"
description = "Extracts function selectors and arguments from EVM bytecode"
authors = ["Maxim Andreev <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "evmole"
version = "0.3.5"
version = "0.3.6"
edition = "2021"
description = "Extracts function selectors and arguments from EVM bytecode"
authors = ["Maxim Andreev <[email protected]>"]
Expand Down

0 comments on commit 7cbe2cf

Please sign in to comment.