Skip to content

Instantly share code, notes, and snippets.

# Poor man's interfaces
contract ENS:
pub fn resolver(node: String<32>) -> Resolver:
revert
contract Resolver:
pub fn addr(node: String<32>) -> address:
revert
@cburgdorf
cburgdorf / xor_keras.py
Last active November 18, 2020 11:23
Comparing XOR between tensorflow and keras
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
target_data = np.array([[0],[1],[1],[0]], "float32")
model = Sequential()
model.add(Dense(32, input_dim=2, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
@cburgdorf
cburgdorf / gist:9713936
Last active March 3, 2020 00:42
A simple example of how to use async/await with hack-lang to perform non-blocking async tasks.
<?hh
async function helloAfter($name, $timeout) {
// sleep asynchronously -- let other async functions do their job
await SleepWaitHandle::create($timeout * 1000000);
echo sprintf("hello %s\n", $name);
}
async function run() {
$joe = helloAfter('Joe', 3);
benchmark run-test: commands[0] | bash -c 'python /home/circleci/repo/scripts/perf_benchmark.py --num-processes 10 --num-events 10000 --backend asyncio --backend trio'
+++ASYNCIO+++
+++Globals+++
|Consumer processes | Total time | Total aggegated time | Propagated events |Received events | Propagated EPS | Received EPS |
| 10 | 1.87429 | 15.36448 | 10000 | 100000 | 5335.353 | 53353.530 |
+++Process Details+++
| Process |Processed Events| First sent | Last received | Fastest | Slowest | AVG | Total dur
DEBUG2 2020-01-16 11:54:15,457 Computation COMPUTATION STARTING: gas: 81604 | from: 0xa416050e3ed652caf8537ec2b4f319377e753401 | to: 0x | value: 0 | depth 0 | static: n
DEBUG2 2020-01-16 11:54:15,457 Computation OPCODE: 0x60 (PUSH1) | pc: 0
DEBUG2 2020-01-16 11:54:15,457 GasMeter GAS CONSUMPTION: 81604 - 3 -> 81601 (PUSH1)
DEBUG2 2020-01-16 11:54:15,462 Computation OPCODE: 0x60 (PUSH1) | pc: 2
DEBUG2 2020-01-16 11:54:15,467 GasMeter GAS CONSUMPTION: 81601 - 3 -> 81598 (PUSH1)
DEBUG2 2020-01-16 11:54:15,474 Computation OPCODE: 0x52 (MSTORE) | pc: 4
DEBUG2 2020-01-16 11:54:15,474 GasMeter GAS CONSUMPTION: 81598 - 3 -> 81595 (MSTORE)
DEBUG2 2020-01-16 11:54:15,475 Computation MEMORY: size (0 -> 96) | cost (0 -> 9)
DEBUG2 2020-01-16 11:54:15,475 GasMeter GAS CONSUMPTION: 81595 - 9 -> 81586 (Expanding memory 0 -> 96)
DEBUG2 2020-01-16 11:54:15,475 Computation OPCODE:
$ go run . --sim ethereum/consensus --loglevel 6 --client go-ethereum_master --sim-parallelism 1 --sim-rootcontext --simloglevel 6 --docker-noshell --docker-nocache . --hivemaxtestcount 1 --simlimiter 300
INFO[12-20|10:44:51] docker daemon online version=19.03.3
INFO[12-20|10:44:51] building new docker image client=go-ethereum_master nocache=true
Step 1/11 : ARG branch=latest
Step 2/11 : FROM ethereum/client-go:$branch
EROR[12-20|10:44:54] failed to build docker image client=go-ethereum_master error="manifest for ethereum/client-go:master not found: manifest unknown: manifest unknown"
CRIT[12-20|10:44:54] failed to build client images error="clients/go-ethereum: manifest for ethereum/client-go:master not found: manifest unknown: manifest unknown"
INFO[12-20|10:44:54] Creating output folder if necessary folder=workspace/logs
INFO[12-20|10:44:54] creating ethash container
INFO[12-20|10:44:54] building new docker image nocache=true
$ trinity
INFO 2019-11-14 11:23:01,592 trinity
______ _ _ __
/_ __/____(_)___ (_) /___ __
/ / / ___/ / __ \/ / __/ / / /
/ / / / / / / / / / /_/ /_/ /
/_/ /_/ /_/_/ /_/_/\__/\__, /
/____/
INFO 2019-11-14 11:23:01,592 trinity Started main process (pid=28151)
INFO 2019-11-14 11:23:01,592 trinity Trinity/v0.1.0a29/linux/cpython3.7.3
(venv-current) cburgdorf at snakebot in ~/Documents/hacking/ef/vyper on fubuloubu/eth-tester-upgrade*
$ pytest tests/examples/safe_remote_purchase/test_safe_remote_purchase.py -vv -k 'test_abort' -n0 --log-cli-level 0
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.7.3, pytest-5.2.2, py-1.8.0, pluggy-0.13.0 -- /home/cburgdorf/Documents/hacking/ef/vyper/venv-current/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/cburgdorf/Documents/hacking/ef/vyper/.hypothesis/examples')
rootdir: /home/cburgdorf/Documents/hacking/ef/vyper, inifile: setup.cfg
plugins: web3-5.2.2, cov-2.8.1, forked-1.1.3, hypothesis-4.42.0, xdist-1.30.0
collected 5 items / 4 deselected / 1 selected
$ pytest tests/examples/safe_remote_purchase/test_safe_remote_purchase.py -vv -k 'test_abort' -n0 --log-cli-level 0
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.7.3, pytest-5.2.2, py-1.8.0, pluggy-0.13.0 -- /home/cburgdorf/Documents/hacking/ef/vyper/venv/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/cburgdorf/Documents/hacking/ef/vyper/.hypothesis/examples')
rootdir: /home/cburgdorf/Documents/hacking/ef/vyper, inifile: setup.cfg
plugins: web3-5.2.2, cov-2.8.1, forked-1.1.3, hypothesis-4.42.0, xdist-1.30.0
collected 5 items / 4 deselected / 1 selected
tests/examples/safe_remote_purchase/tes
pytest tests/examples/safe_remote_purchase/test_safe_remote_purchase.py -vv -k 'test_abort' -n0 --log-cli-level 0
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.7.3, pytest-5.2.2, py-1.8.0, pluggy-0.13.0 -- /home/cburgdorf/Documents/hacking/ef/vyper/venv/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/cburgdorf/Documents/hacking/ef/vyper/.hypothesis/examples')
rootdir: /home/cburgdorf/Documents/hacking/ef/vyper, inifile: setup.cfg
plugins: web3-5.2.2, cov-2.8.1, forked-1.1.3, hypothesis-4.42.0, xdist-1.30.0
collected 5 items / 4 deselected / 1 selected
tests/examples/safe_remote_purchase/test