This node comes directly from ethereum-js team meeting dusing EthCC, but the idea described here lives longer.
Instead of having the base layer of the P2P network stack implemented as a library (like currently DevP2P) it should be moved to its own process running on the same machine with specified Inter-Process Communiocation (IPC) for accessing it.
<html> | |
<head> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<h1>WASM loader</h1> | |
<pre id="log">Log: | |
</pre> | |
<script> | |
log = document.getElementById('log'); |
########## BAD BLOCK ######### | |
Chain config: {ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash} | |
Number: 5708548 | |
Hash: 0xa382e502e982ee89d300f839b61a38209f702f24ad1696056c2a9d2d97e43a07 | |
&{[] 1 21000 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [] [191 119 99 221 143 139 143 177 235 233 157 219 136 52 21 78 94 26 159 20 149 39 239 118 179 155 210 78 73 104 25 92] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 21000} | |
&{[] 1 42000 [0 0 0 0 0 |
- Define fnv1a() as
where
def fnv1a(v1, v2): return ((v1 ^ v2) * FNV1A_PRIME) % 2**32
FNV1A_PRIME
is 16777499 or 16777639.` - Change the hash function that determines the DAG item index in Ethash algorighm from fnv() to new fnv1a(). In Main Loop change
{ | |
"config": { | |
"chainId": 66, | |
"homesteadBlock": 1, | |
"eip150Block": 2, | |
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", | |
"eip155Block": 3, | |
"eip158Block": 3, | |
"byzantiumBlock": 4, | |
"ewasmBlock": 0, |
build/bin/geth --datadir ~/.ethereum/ewasm --networkid=66 --vm.ewasm=/tmp/evmc6/lib/libhera.so:metering=true --bootnodes="$bn1,$bn2" --syncmode=full --vmodule "eth=3,p2p=3" --port 11111 | |
INFO [10-21|19:21:11.840] Maximum peer count ETH=25 LES=0 total=25 | |
INFO [10-21|19:21:11.841] Starting peer-to-peer node instance=Geth/v1.8.18-unstable-895d3601/linux-amd64/go1.11.1 | |
INFO [10-21|19:21:11.841] Allocated cache and file handles database=/home/chfast/.ethereum/ewasm/geth/chaindata cache=768 handles=512 | |
INFO [10-21|19:21:12.000] Initialised chain configuration config="{ChainID: 66 Homestead: 1 DAO: <nil> DAOSupport: false EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 4 Constantinople: <nil> Engine: ethash}" | |
INFO [10-21|19:21:12.000] Disk storage enabled for ethash caches dir=/home/chfast/.ethereum/ewasm/geth/ethash count=3 | |
INFO [10-21|19:21:12.000] Disk storage enabled for ethash DAGs dir=/home/chfast/.ethash count=2 | |
INF |
l=0 i=0 word=9de9a7a2 | |
l=0 i=1 word=9a96da15 | |
l=0 i=2 word=97848039 | |
l=0 i=3 word=bcde5009 | |
l=1 i=0 word=19173998 | |
l=1 i=1 word=62077d8 | |
l=1 i=2 word=6c596733 | |
l=1 i=3 word=18a6f318 | |
l=2 i=0 word=9c4e4a04 | |
l=2 i=1 word=cdff0add |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##5e6b68ec… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##0c46d0d2… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##70b28671… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##6028267a… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##85c98043… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##8516b786… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##d693da0f… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##e602ae32… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##24d8ec7d… | |
DEBUG 01-10 11:11:01 p2p discov p2p.nodes.drop ##0fa9c65d… |
All assembly snippets are generated from intx. Compiled by clang 9 (trung), -O3 -march=skylake.
The first one mul256_x86_64.s is the one evmone is using.
It exploits the fact that x86 has mul
instruction performing full 64x64 -> 128 multiplication.
See umul()
procedure in intx.
This instruction cannot be used by wasm,
but I'm working on teaching LLVM to recognize the 64x64 -> 128 mul pattern.
Instruction count: