Skip to content

Instantly share code, notes, and snippets.

@pirapira
pirapira / add.txt
Created May 25, 2018 21:27
evm code that adds two numbers from the storage and writes the result to storage
~/src/solidity/build((v0.4.21)) $ lllc/lllc < ../../cpp-ethereum/build-tsan/add-storage.lll
60015460005401600255
~/src/solidity/build((v0.4.21)) $ cat ../../cpp-ethereum/build-tsan/add-storage.lll
(sstore 2 (+ (sload 0) (sload 1)))
$ make
<snip>
eval $(opam config env) \
&& /home/yh/tmp/evm-semantics/.build/k/k-distribution/target/release/k/bin/kompile --debug --main-module ETHEREUM-SIMULATION \
--syntax-module ETHEREUM-SIMULATION .build/ocaml/driver.k --directory .build/ocaml \
--hook-namespaces KRYPTO --gen-ml-only -O3 --non-strict \
&& ocamlfind opt -c .build/ocaml/driver-kompiled/constants.ml -package gmp -package zarith \
&& ocamlfind opt -c -I .build/ocaml/driver-kompiled KRYPTO.ml -package cryptokit -package secp256k1 -package bn128 \
&& ocamlfind opt -a -o semantics.cmxa KRYPTO.cmx \
&& ocamlfind remove ethereum-semantics-plugin \
~/src/evm-semantics(exception-checker) $ ./kevm bugcheck tests/interactive/bug-checker/invalid-opcode.evm
== bug-checking: tests/interactive/bug-checker/invalid-opcode.evm
(error "line 12 column 35: Sorts Int and KItem are incompatible")
(error "line 12 column 35: Sorts Int and KItem are incompatible")
(error "line 13 column 35: Sorts Int and KItem are incompatible")
(error "line 13 column 35: Sorts Int and KItem are incompatible")
(error "line 13 column 35: Sorts Int and KItem are incompatible")
#accountExists ( V0 ) ==K true #And
Result ==K <generatedTop>
<k>
{
"201503110226PYTHON_DUP6" : {
"_info" : {
"comment" : "This test used to be a VM test and it once failed in python client some day. Since the test contains a BALANCE instruction (which must be mocked), it's moved to GeneralSateTest https://github.com/ethereum/tests/pull/445/files#r17\
9426325"
},
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
"currentGasLimit" : "1000000",
// Based on http://www.blunderingcode.com/ether-vaults/
contract Vault(address hotwallet, address vaultKey, address recoveryKey) {
case(void unvault(uint256 amount)) {
if (sender(msg) != vaultKey) abort;
uint256 unvaultPeriod = 60 * 60 * 24 * 7 * 2; // two weeks
if (now(block) + unvaultPeriod < now(block)) abort;
return then become UnVaulting(now(block) + unvaultPeriod, amount, hotwallet, vaultKey, recoveryKey);
}
case(void recover(address _newHotWallet)) {
// This code does not compile yet.
// Should Bamboo support this kind of nesting contracts, which represent substates and a superstate?
contract Alive(address hotWallet, address vaultKey, address recoveryKey) {
case(void destroy()) {
if (sender(msg) != recoveryKey) abort;
return then become Destroyed();
}
case(void recover(address _newHotWallet)) {
if (sender(msg) != recoveryKey) abort;
{
"uncleBlockAtBlock3AfterBlock3" : {
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "131072",
"extraData" : "0x42",
"gasLimit" : "3141592",
"gasUsed" : "0",
"number" : "0",
{
"randomStatetest645" : {
"_info" : {
"comment" : "",
"filledwith" : "cpp-1.3.0+commit.0b2b4ec2.Linux.g++",
"source" : "/home/wins/Ethereum/tests/src/GeneralStateTestsFiller/stRandom/randomStatetest645Filler.json"
},
"env" : {
"currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"currentDifficulty" : "0x20000",
[15:22] yh@sri: ~/src/parity(metropolis-update|✔)$ git remote add tim https://github.com/tcsiwula/parity
[15:22] yh@sri: ~/src/parity(metropolis-update|✔)$ git fetch tim
[15:22] yh@sri: ~/src/parity(metropolis-update|✔)$ git checkout tims_benchmarks
[15:22] yh@sri: ~/src/parity(tims_benchmarks|✔)$ rustup override set nightly
[15:23] yh@sri: ~/src/parity(tims_benchmarks|✔)$ cargo bench -p ethcore
<snip>
test bn_128_add ... bench: 14,527 ns/iter (+/- 413)
[16:44] yh@sri: ~/gopath/src/github.com/ethereum/go-ethereum(master↓2|✚1…)$ git checkout holiman/metro_benchmark_on_karalabe
[16:46] yh@sri: ~/gopath/src/github.com/ethereum/go-ethereum/core/vm(:e07d36f12|…)$ go test -bench BenchmarkPre
<snip>
BenchmarkPrecompiledBn256Add/chfast1-Gas=0-4 20000 90297 ns/op
BenchmarkPrecompiledBn256Add/chfast2-Gas=0-4 20000 98101 ns/op