-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into evm-bn254-precompile-native-js
- Loading branch information
Showing
4 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters