Skip to content

Instantly share code, notes, and snippets.

@cdetrio
cdetrio / readme.md
Created July 11, 2019 14:53
starter pack: merkle-patricia-trie proof verifier

Building on the Stateless MPT-based token script for Scout.

instructions

  1. use smtp-proof-generator.js to generate a test vector for a basic merkle-patricia-trie proof verifier.
  2. paste the test vector into verify-branch.js

TODO

  • verify-branch.js only verifies a single proof (i.e. a single merkle branch)
@cdetrio
cdetrio / ewasm-bencher.js
Created April 2, 2019 18:07
minimal node.js script for benchmarking ewasm contracts/precompiles
// node --experimental-wasm-bigint ewasm-bencher.js bn128mul_metered.wasm "039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d98ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "00a1a234d08efaa2616607e31eca1980128b00b415c845ff25bba3afcb81dc00242077290ed33906aeb8e42fd98c41bcb9057ba03421af3f2d08cfc441186024"
var args = process.argv.slice(2);
var wasmfile = args[0];
var input = args[1];
var expected = args[2];
if (args.length < 3) {
console.log('missing an arg!');
process.exit(1);
@cdetrio
cdetrio / async-wasm.html
Created December 31, 2017 01:09
async wasm imports don't work
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Async wasm doesnt work</title>
</head>
<script>
/*
// wasm code:
@cdetrio
cdetrio / readme.md
Created January 24, 2019 00:49
estimating stateless contract block sizes on Ethereum

Estimating stateless contract block sizes on Ethereum

Results of running the script for 100 blocks (#7021700 - #7021800).

>>> sizes = [852946, 221839, 637053, 672740, 1093313, 225852, 1678145, 761029, 1419458, 1152028, 653192, 67545, 29260, 249825, 1526471, 76492, 791376, 0, 204216, 973265, 561570, 579943, 1515495, 1738738, 1717572, 395549, 354647, 16870, 551612, 89760, 1848829, 290080, 505966, 22421, 1471108, 28740, 1578582, 880692, 13205, 1442855, 1255767, 644168, 1634534, 2631529, 869398, 437570, 452382, 1236448, 870726, 203800, 570037, 446159, 6947, 55375, 599809, 308926, 113536, 0, 605908, 357154, 829124, 1583076, 1413534, 854483, 198182, 1015926, 1080430, 59555, 1106610, 205846, 445871, 379150, 980513, 72306, 1293635, 40396, 942147, 561540, 297171, 1035896, 917608, 272911, 776640, 0, 1293114, 627284, 3675, 965540, 32970, 168510, 113672, 863180, 25912, 1245664, 532234, 576862, 1332396, 590317, 760537, 1295538, 1543689]
>>> len(sizes)
101
>>> np.mean(sizes)
698258.3762376237
file: /home/ubuntu/cdetrio/evmlab/evmlab-holiman/evmlab/generatedTests/GeneralStateTests/stRandom/randomStatetestubuntu-Tue_03_48_41-1432.json
test_name: randomStatetestubuntu-Tue_03_48_41-1432. tx_i: 1
running state test in pyeth.
docker run --rm -t -v /home/ubuntu/cdetrio/evmlab/evmlab-holiman/evmlab/prestate.json:/mounted_prestate cdetrio/pyethereum run_statetest.py /mounted_prestate "{\"data\": \"0x79b94053bf1fb725756225cde415738a99e1a7690cbe409744b73761038f5277367dedc82e30635bc57e35fcb2038306d9a3a6e4ddcb9d306c879e470f5dd81e1148184f62bd6361ae97087aff61cee25c694a734342be5043b1fde117ba383682ba0d91e0db8b6a29c882a044d0c8bb4925a6796d8480df1b1ccc25641df94f43d5802aa8f44bf70a6817ed784e675725bdc7718a54d686307da5234286085240ba84575dac25d7fc32c59999a9d38fee0d25e7c23986006e9c5bb022f7d28a2cab01a4bb37dd4210608d6101bf6101606079637be1ae4373c94f5374fce5edbc8e2a8697c15331677e6ebf0b63627cbc7df161023161030a60213e60686102596102c861032b73b94f5374fce5edbc8e2a8697c15331677e6ebf0b630a549e50f461036761038161026c6103d1633aded16b73b9
@cdetrio
cdetrio / pyeth_trace_howto.md
Created July 8, 2017 21:25
Instructions for generating EVM traces of state tests in pyethereum

Instructions for generating EVM traces of state tests in pyethereum

Step 1. Install pyethereum modules and pytest

I'd suggest using pipenv.

mkdir pyeth
cd pyeth
pipenv --three
@cdetrio
cdetrio / pyeth-block-decode.ipynb
Created May 27, 2017 20:48
pyethereum block decode example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// This file reproduces the EIP 155 examples
// values compared to EIP 155 issue text as of 2017-05-03 https://github.com/ethereum/eips/issues/155#issue-183002027
const ethUtil = require('ethereumjs-util') // ethereumjs-util version 5.1.1
const fields = [{
name: 'nonce',
length: 32,
allowLess: true,

Keybase proof

I hereby claim:

  • I am cdetrio on github.
  • I am cdetrio (https://keybase.io/cdetrio) on keybase.
  • I have a public key ASC_9u0zlWx3WXuew_6LeeB-dVc2kwfBFh9UWdTdG_MIpgo

To claim this, I am signing this object:

@cdetrio
cdetrio / pyethereum_state_snapshot_at_block_100000.json
Created March 12, 2017 04:26
pyethereum state snapshot JSON file at block #100000
This file has been truncated, but you can view the full file.
{
"block_number": "100000",
"alloc": {
"381d12209f3d12ca9b10b47eeddb206c4e790137": {
"nonce": "2",
"balance": "0",
"storage": {},
"code": "0x"
},
"845eda2dc559f882d393ffe560a5a6989f7a46e5": {