Commit aa48e6ae authored by George Hotz's avatar George Hotz

txs load, they don't work

parent f245d631
......@@ -15,6 +15,21 @@ type extblock struct {
Uncles []*Header
}
*/
function getTransactionRlp(tx : any) {
let dat = [
tx.nonce,
tx.gasPrice,
tx.gas,
tx.to,
tx.value,
tx.input,
tx.v,
tx.r,
tx.s,
];
dat = dat.map((x) => (x == "0x0") ? "0x" : x)
return dat
}
function getBlockRlp(block : any) {
let dat = [
......@@ -35,18 +50,20 @@ function getBlockRlp(block : any) {
block['nonce'],
block['baseFeePerGas']
];
// special case for 0
dat = dat.map((x) => (x == "0x0") ? "0x" : x)
return rlp.encode(dat);
return dat
}
async function main() {
const blockNumber = 13247502;
let blockData = await provider.send("eth_getBlockByNumber", ["0x"+(blockNumber).toString(16), true])
const blockHeaderRlp = getBlockRlp(blockData)
const blockHeaderRlp = rlp.encode(getBlockRlp(blockData))
assert(keccak256(blockHeaderRlp) == blockData['hash'])
//console.log(blockData)
const txsRlp = rlp.encode(blockData.transactions.map(getTransactionRlp))
fs.writeFileSync(`data/block_${blockNumber}`, blockHeaderRlp)
fs.writeFileSync(`data/tx_${blockNumber}`, txsRlp)
}
main().then(() => process.exit(0))
......@@ -20,16 +20,31 @@ func main() {
processor := core.NewStateProcessor(params.MainnetChainConfig, bc, bc.Engine())
fmt.Println("made state processor")
f, _ := os.Open("../data/block_13247502")
defer f.Close()
// read header
var header types.Header
rlpheader := rlp.NewStream(f, 0)
rlpheader.Decode(&header)
{
f, _ := os.Open("data/block_13247502")
defer f.Close()
rlpheader := rlp.NewStream(f, 0)
rlpheader.Decode(&header)
}
// read txs
var txs []*types.Transaction
{
f, _ := os.Open("data/tx_13247502")
defer f.Close()
rlpheader := rlp.NewStream(f, 0)
rlpheader.Decode(&txs)
}
fmt.Println("read", len(txs), "transactions")
var uncles []*types.Header
var receipts []*types.Receipt
block := types.NewBlock(&header, txs, uncles, receipts, trie.NewStackTrie(nil))
fmt.Println("made block, parent:", header.ParentHash)
processor.Process(block, statedb, vmconfig)
_, _, _, err := processor.Process(block, statedb, vmconfig)
fmt.Println(err)
fmt.Println("process done")
}
#!/bin/bash -e
(cd minigeth/ && go build)
minigeth/go-ethereum
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment