Commit 2d12be53 authored by George Hotz's avatar George Hotz

fix transaction fetch

parent 232bde2f
......@@ -33,6 +33,11 @@ type SendTxArgs struct {
// For non-legacy transactions
AccessList *types.AccessList `json:"accessList,omitempty"`
ChainID *hexutil.Big `json:"chainId,omitempty"`
// Signature values
V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r" gencodec:"required"`
S *hexutil.Big `json:"s" gencodec:"required"`
}
type Header struct {
......@@ -116,6 +121,9 @@ func (args *SendTxArgs) ToTransaction() *types.Transaction {
Value: (*big.Int)(&args.Value),
Data: input,
AccessList: al,
V: (*big.Int)(args.V),
R: (*big.Int)(args.R),
S: (*big.Int)(args.S),
}
case args.AccessList != nil:
data = &types.AccessListTx{
......@@ -127,6 +135,9 @@ func (args *SendTxArgs) ToTransaction() *types.Transaction {
Value: (*big.Int)(&args.Value),
Data: input,
AccessList: *args.AccessList,
V: (*big.Int)(args.V),
R: (*big.Int)(args.R),
S: (*big.Int)(args.S),
}
default:
data = &types.LegacyTx{
......@@ -136,6 +147,9 @@ func (args *SendTxArgs) ToTransaction() *types.Transaction {
GasPrice: (*big.Int)(args.GasPrice),
Value: (*big.Int)(&args.Value),
Data: input,
V: (*big.Int)(args.V),
R: (*big.Int)(args.R),
S: (*big.Int)(args.S),
}
}
return types.NewTx(data)
......
......@@ -10,6 +10,7 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"math/big"
"net/http"
"os"
......@@ -208,7 +209,7 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
jr := jsonrespt{}
err := json.NewDecoder(getAPI(jsonData)).Decode(&jr)
if err != nil {
panic("bad block prefetch")
log.Fatal(err)
}
//fmt.Println(jr.Result)
blockHeader := jr.Result.ToHeader()
......@@ -247,6 +248,11 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
for i := 0; i < len(jr.Result.Transactions); i++ {
txs[i] = jr.Result.Transactions[i].ToTransaction()
}
testTxHash := types.DeriveSha(types.Transactions(txs), hasher)
if testTxHash != blockHeader.TxHash {
fmt.Println(testTxHash, "!=", blockHeader.TxHash)
panic("tx hash derived wrong")
}
// put in transaction trie
......
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