-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb9610f
commit 2017d54
Showing
3 changed files
with
59 additions
and
65 deletions.
There are no files selected for viewing
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,59 @@ | ||
const level = require('level') | ||
import { Transaction } from '@ethereumjs/tx' | ||
import VM from '../../lib' | ||
import { SecureTrie as Trie } from '@ethereumjs/trie' | ||
import { DefaultStateManager } from '../../lib/state' | ||
import Common from '@ethereumjs/common' | ||
import { Block } from '@ethereumjs/block' | ||
import tape from 'tape' | ||
|
||
tape('Consensus bugs', (t) => { | ||
t.test( | ||
'transaction 0x8420dbe268209c4e921bf6b78bc9fb959d9d9553fd16aacb9dd8cad955dbe729 should evaluate to right state root', | ||
async (st) => { | ||
const txData = { | ||
nonce: '0x1a', | ||
gasPrice: '0xba43b7400', | ||
gasLimit: '0x493e0', | ||
to: '0x9ca228250f9d8f86c23690074c2b96d5f5479f79', | ||
value: '0x0', | ||
data: | ||
'0xa9059cbb000000000000000000000000bfe465e7eb5a2928b5bf22bef93ad06089dc6179000000000000000000000000000000000000000000000000006a94d74f430000', | ||
v: '0x1c', | ||
r: '0xc04f048766bea3b20dcea6d2fcaecc92f1a615d337606ab6eec2a1e8e1f27bfe', | ||
s: '0x1c57e62653724560b06c95be750d958840db9fa44ffa777b6625b344bfadbbcf', | ||
} | ||
const common = new Common({ chain: 'mainnet', hardfork: 'chainstart' }) | ||
const tx = Transaction.fromTxData(txData, { common }) | ||
const trie = new Trie(level('/Users/jochem/Library/Ethereum/ethereumjs/mainnet/state/')) | ||
|
||
// Ensure we run on the right root | ||
trie._setRoot( | ||
Buffer.from('9dceb42e227ee6a244449d1d92cc5e0c17c63b520d0ff050d943baa8055d0ca6', 'hex') | ||
) | ||
|
||
const stateManager = new DefaultStateManager({ trie, common }) | ||
const vm = new VM({ stateManager, common }) | ||
|
||
const block = Block.fromBlockData( | ||
{ | ||
header: { | ||
// Ensures our fees get added to coinbase after we run the Tx (this is important for the state root in the receipt) | ||
coinbase: Buffer.from('52bc44d5378309ee2abf1539bf71de1b7d7be3b5', 'hex'), | ||
timestamp: 1442117987, | ||
}, | ||
}, | ||
{ common } | ||
) | ||
|
||
await vm.runTx({ tx, block }) | ||
const expectedRoot = Buffer.from( | ||
'9d735b19daf3205f93e60f3eb02df6b211aebb4d3a2c512cb51055d8ecfb35c1', | ||
'hex' | ||
) | ||
|
||
st.ok(expectedRoot.equals(await vm.stateManager.getStateRoot()), 'state root ok') | ||
st.end() | ||
} | ||
) | ||
}) |
This file was deleted.
Oops, something went wrong.