Skip to content

Commit

Permalink
Merge branch 'master' into evm-bn254-precompile-native-js
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 authored Aug 7, 2024
2 parents 8e41321 + d2cef57 commit 042765c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
15 changes: 14 additions & 1 deletion package-lock.json

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

5 changes: 3 additions & 2 deletions packages/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
"@ethereumjs/statemanager": "^2.3.0",
"@ethereumjs/tx": "^5.3.0",
"@ethereumjs/util": "^9.0.3",
"@noble/curves": "git://github.com/holgerd77/noble-curves.git#build-3ed792f",
"@types/debug": "^4.1.9",
"debug": "^4.3.3",
"ethereum-cryptography": "^2.2.1",
"@noble/curves": "git://github.com/holgerd77/noble-curves.git#build-3ed792f ",
"rustbn-wasm": "^0.4.0"
},
"devDependencies": {
Expand All @@ -81,7 +81,8 @@
"minimist": "^1.2.5",
"node-dir": "^0.1.17",
"rollup-plugin-visualizer": "^5.12.0",
"solc": "^0.8.1"
"solc": "^0.8.1",
"split": "^1.0.1"
},
"engines": {
"node": ">=18"
Expand Down
36 changes: 36 additions & 0 deletions packages/evm/scripts/eofContainerValidator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
import { unprefixedHexToBytes } from '@ethereumjs/util'
import split from 'split'

import { createEVM, validateEOF } from '../src/index.js'

/**
* This script reads hex strings (either prefixed or non-prefixed with 0x) from stdin
* It tries to validate the EOF container, if it is valid, it will print "OK"
* If there is a validation error, it will print "err: <REASON>"
* If the input is emtpy, the program will exit
*/

const common = new Common({ chain: Mainnet })
common.setHardfork(Hardfork.Prague)
common.setEIPs([663, 3540, 3670, 4200, 4750, 5450, 6206, 7069, 7480, 7620, 7692, 7698])
const evm = await createEVM({ common })

function processLine(line) {
if (line.length === 0) {
process.exit()
}
let trimmed = line
if (line.startsWith('0x')) {
trimmed = line.slice(2)
}
const bytes = unprefixedHexToBytes(trimmed)
try {
validateEOF(bytes, evm)
console.log('OK')
} catch (e: any) {
console.log('err: ' + e.message)
}
}

process.stdin.pipe(split()).on('data', processLine)
3 changes: 3 additions & 0 deletions packages/evm/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EOFContainer, validateEOF } from './eof/container.js'
import { EVM } from './evm.js'
import { ERROR as EVMErrorMessage, EvmError } from './exceptions.js'
import { Message } from './message.js'
Expand Down Expand Up @@ -36,6 +37,7 @@ export type {
}

export {
EOFContainer,
EVM,
EvmError,
EVMErrorMessage,
Expand All @@ -44,6 +46,7 @@ export {
MCLBLS,
Message,
NobleBLS,
validateEOF,
}

export * from './constructors.js'
Expand Down

0 comments on commit 042765c

Please sign in to comment.