From e31bb99d18b755f345b255fd765a08fb7d03fb1c Mon Sep 17 00:00:00 2001 From: chao Date: Fri, 13 Sep 2019 11:46:16 -0700 Subject: [PATCH 1/3] add shardID information in getTransactionByHash RPC CALL --- internal/hmyapi/types.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/internal/hmyapi/types.go b/internal/hmyapi/types.go index 4ceff684e..2e159e82b 100644 --- a/internal/hmyapi/types.go +++ b/internal/hmyapi/types.go @@ -22,6 +22,8 @@ type RPCTransaction struct { To *common.Address `json:"to"` TransactionIndex hexutil.Uint `json:"transactionIndex"` Value *hexutil.Big `json:"value"` + FromShardID uint32 `json:"fromShardID"` + ToShardID uint32 `json:"toShardID"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` @@ -38,17 +40,19 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber v, r, s := tx.RawSignatureValues() result := &RPCTransaction{ - From: from, - Gas: hexutil.Uint64(tx.Gas()), - GasPrice: (*hexutil.Big)(tx.GasPrice()), - Hash: tx.Hash(), - Input: hexutil.Bytes(tx.Data()), - Nonce: hexutil.Uint64(tx.Nonce()), - To: tx.To(), - Value: (*hexutil.Big)(tx.Value()), - V: (*hexutil.Big)(v), - R: (*hexutil.Big)(r), - S: (*hexutil.Big)(s), + From: from, + Gas: hexutil.Uint64(tx.Gas()), + GasPrice: (*hexutil.Big)(tx.GasPrice()), + Hash: tx.Hash(), + Input: hexutil.Bytes(tx.Data()), + Nonce: hexutil.Uint64(tx.Nonce()), + To: tx.To(), + Value: (*hexutil.Big)(tx.Value()), + FromShardID: tx.ShardID(), + ToShardID: tx.ToShardID(), + V: (*hexutil.Big)(v), + R: (*hexutil.Big)(r), + S: (*hexutil.Big)(s), } if blockHash != (common.Hash{}) { result.BlockHash = blockHash From f3a89211c8ab37d9d753d293e12fe378510d5d09 Mon Sep 17 00:00:00 2001 From: chao Date: Fri, 13 Sep 2019 13:05:17 -0700 Subject: [PATCH 2/3] Add CXReceipt RPC call; Add indexing for CXReceipt by TxHash --- core/blockchain.go | 3 ++ core/rawdb/accessors_indexes.go | 73 ++++++++++++++++++++++++++++++ core/rawdb/schema.go | 11 ++++- core/types/block.go | 5 ++ core/types/bodyv0.go | 7 +++ core/types/bodyv1.go | 15 ++++++ internal/hmyapi/transactionpool.go | 8 ++++ internal/hmyapi/types.go | 30 ++++++++++++ 8 files changed, 150 insertions(+), 2 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 51ddca609..1118de59e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1109,6 +1109,9 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. rawdb.WriteTxLookupEntries(batch, block) rawdb.WritePreimages(batch, block.NumberU64(), state.Preimages()) + // write the positional metadata for CXReceipts lookups + rawdb.WriteCxLookupEntries(batch, block) + status = CanonStatTy } else { status = SideStatTy diff --git a/core/rawdb/accessors_indexes.go b/core/rawdb/accessors_indexes.go index 621fe2c5e..64080b16f 100644 --- a/core/rawdb/accessors_indexes.go +++ b/core/rawdb/accessors_indexes.go @@ -123,3 +123,76 @@ func WriteBloomBits(db DatabaseWriter, bit uint, section uint64, head common.Has utils.Logger().Error().Err(err).Msg("Failed to store bloom bits") } } + +// ReadCxLookupEntry retrieves the positional metadata associated with a transaction +// hash to allow retrieving the transaction or receipt by hash. +// return nil if not found +func ReadCxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64, uint64) { + data, _ := db.Get(cxLookupKey(hash)) + if len(data) == 0 { + return common.Hash{}, 0, 0, 0 + } + var entry TxLookupEntry + if err := rlp.DecodeBytes(data, &entry); err != nil { + utils.Logger().Error().Err(err).Str("hash", hash.Hex()).Msg("Invalid transaction lookup entry RLP") + return common.Hash{}, 0, 0, 0 + } + return entry.BlockHash, entry.BlockIndex, entry.Index, entry.SubIndex +} + +// WriteCxLookupEntries stores a positional metadata for every transaction from +// a block, enabling hash based transaction and receipt lookups. +func WriteCxLookupEntries(db DatabaseWriter, block *types.Block) { + for i, cxp := range block.IncomingReceipts() { + for j, cx := range cxp.Receipts { + entry := TxLookupEntry{ + BlockHash: block.Hash(), + BlockIndex: block.NumberU64(), + Index: uint64(i), + SubIndex: uint64(j), + } + data, err := rlp.EncodeToBytes(entry) + if err != nil { + utils.Logger().Error().Err(err).Msg("Failed to encode transaction lookup entry") + } + if err := db.Put(cxLookupKey(cx.TxHash), data); err != nil { + utils.Logger().Error().Err(err).Msg("Failed to store transaction lookup entry") + } + } + } +} + +// DeleteCxLookupEntry removes all transaction data associated with a hash. +func DeleteCxLookupEntry(db DatabaseDeleter, hash common.Hash) { + db.Delete(cxLookupKey(hash)) +} + +// ReadCXReceipt retrieves a specific transaction from the database, along with +// its added positional metadata. +func ReadCXReceipt(db DatabaseReader, hash common.Hash) (*types.CXReceipt, common.Hash, uint64, uint64, uint64) { + blockHash, blockNumber, cxIndex, cxSubIndex := ReadCxLookupEntry(db, hash) + if blockHash == (common.Hash{}) { + return nil, common.Hash{}, 0, 0, 0 + } + body := ReadBody(db, blockHash, blockNumber) + if body == nil { + utils.Logger().Error(). + Uint64("number", blockNumber). + Str("hash", blockHash.Hex()). + Uint64("index", cxIndex). + Uint64("subIndex", cxSubIndex). + Msg("block Body referenced missing") + return nil, common.Hash{}, 0, 0, 0 + } + cx := body.CXReceiptAt(int(cxIndex), int(cxSubIndex)) + if cx == nil { + utils.Logger().Error(). + Uint64("number", blockNumber). + Str("hash", blockHash.Hex()). + Uint64("index", cxIndex). + Uint64("subIndex", cxSubIndex). + Msg("CXReceipt referenced missing") + return nil, common.Hash{}, 0, 0, 0 + } + return cx, blockHash, blockNumber, cxIndex, cxSubIndex +} diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 4d5333456..6ba443ba5 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -51,8 +51,9 @@ var ( blockBodyPrefix = []byte("b") // blockBodyPrefix + num (uint64 big endian) + hash -> block body blockReceiptsPrefix = []byte("r") // blockReceiptsPrefix + num (uint64 big endian) + hash -> block receipts - txLookupPrefix = []byte("l") // txLookupPrefix + hash -> transaction/receipt lookup metadata - bloomBitsPrefix = []byte("B") // bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash -> bloom bits + txLookupPrefix = []byte("l") // txLookupPrefix + hash -> transaction/receipt lookup metadata + cxLookupPrefix = []byte("cx") // cxLookupPrefix + hash -> cxReceipt lookup metadata + bloomBitsPrefix = []byte("B") // bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash -> bloom bits shardStatePrefix = []byte("ss") // shardStatePrefix + num (uint64 big endian) + hash -> shardState lastCommitsKey = []byte("LastCommits") @@ -93,6 +94,7 @@ type TxLookupEntry struct { BlockHash common.Hash BlockIndex uint64 Index uint64 + SubIndex uint64 // used for lookup CXReceipt from CXReceiptsProof } // encodeBlockNumber encodes a block number as big endian uint64 @@ -137,6 +139,11 @@ func txLookupKey(hash common.Hash) []byte { return append(txLookupPrefix, hash.Bytes()...) } +// cxLookupKey = cxLookupPrefix + hash +func cxLookupKey(hash common.Hash) []byte { + return append(cxLookupPrefix, hash.Bytes()...) +} + // bloomBitsKey = bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash func bloomBitsKey(bit uint, section uint64, hash common.Hash) []byte { key := append(append(bloomBitsPrefix, make([]byte, 10)...), hash.Bytes()...) diff --git a/core/types/block.go b/core/types/block.go index 9aba63ea8..8883830c6 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -86,6 +86,11 @@ type BodyInterface interface { // It returns nil if index is out of bounds. TransactionAt(index int) *Transaction + // CXReceiptAt returns the CXReceipt given index (from IncomingReceipts) + // and subindex(from CXReceiptProof in IncomingReceipts) + // It returns nil if index, subindex is out of bounds + CXReceiptAt(index int, subIndex int) *CXReceipt + // SetTransactions sets the list of transactions with a deep copy of the // given list. SetTransactions(newTransactions []*Transaction) diff --git a/core/types/bodyv0.go b/core/types/bodyv0.go index ae5c7bed9..79cd06b54 100644 --- a/core/types/bodyv0.go +++ b/core/types/bodyv0.go @@ -39,6 +39,13 @@ func (b *BodyV0) TransactionAt(index int) *Transaction { return b.f.Transactions[index].Copy() } +// CXReceiptAt returns the CXReceipt at given index-subindex in this block +// It returns nil if index/subindex is out of bounds +// V0 will just return nil because we don't support CXReceipt +func (b *BodyV0) CXReceiptAt(index int, subindex int) *CXReceipt { + return nil +} + // SetTransactions sets the list of transactions with a deep copy of the given // list. func (b *BodyV0) SetTransactions(newTransactions []*Transaction) { diff --git a/core/types/bodyv1.go b/core/types/bodyv1.go index bcabd9456..8e852cbc1 100644 --- a/core/types/bodyv1.go +++ b/core/types/bodyv1.go @@ -39,6 +39,21 @@ func (b *BodyV1) TransactionAt(index int) *Transaction { return b.f.Transactions[index].Copy() } +// CXReceiptAt returns the CXReceipt at given index/subindex in this block +// It returns nil if index/subindex is out of bounds +func (b *BodyV1) CXReceiptAt(index int, subindex int) *CXReceipt { + if index < 0 || index >= len(b.f.IncomingReceipts) { + return nil + } + + cxs := b.f.IncomingReceipts[index].Receipts + if subindex < 0 || subindex >= len(cxs) { + return nil + } + + return cxs[subindex].Copy() +} + // SetTransactions sets the list of transactions with a deep copy of the given // list. func (b *BodyV1) SetTransactions(newTransactions []*Transaction) { diff --git a/internal/hmyapi/transactionpool.go b/internal/hmyapi/transactionpool.go index f62c6a088..b6e9680fd 100644 --- a/internal/hmyapi/transactionpool.go +++ b/internal/hmyapi/transactionpool.go @@ -212,3 +212,11 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, err } return transactions, nil } + +// GetCXReceiptByHash returns the transaction for the given hash +func (s *PublicTransactionPoolAPI) GetCXReceiptByHash(ctx context.Context, hash common.Hash) *RPCCXReceipt { + if cx, blockHash, blockNumber, _, _ := rawdb.ReadCXReceipt(s.b.ChainDb(), hash); cx != nil { + return newRPCCXReceipt(cx, blockHash, blockNumber) + } + return nil +} diff --git a/internal/hmyapi/types.go b/internal/hmyapi/types.go index 2e159e82b..4c2bf4bca 100644 --- a/internal/hmyapi/types.go +++ b/internal/hmyapi/types.go @@ -29,6 +29,36 @@ type RPCTransaction struct { S *hexutil.Big `json:"s"` } +// RPCCXReceipt represents a CXReceipt that will serialize to the RPC representation of a CXReceipt +type RPCCXReceipt struct { + BlockHash common.Hash `json:"blockHash"` + BlockNumber *hexutil.Big `json:"blockNumber"` + TxHash common.Hash `json:"hash"` + From common.Address `json:"from"` + To *common.Address `json:"to"` + FromShardID uint32 `json:"fromShardID"` + ToShardID uint32 `json:"toShardID"` + Amount *hexutil.Big `json:"value"` +} + +// newRPCCXReceipt returns a CXReceipt that will serialize to the RPC representation +func newRPCCXReceipt(cx *types.CXReceipt, blockHash common.Hash, blockNumber uint64) *RPCCXReceipt { + result := &RPCCXReceipt{ + BlockHash: blockHash, + TxHash: cx.TxHash, + From: cx.From, + To: cx.To, + Amount: (*hexutil.Big)(cx.Amount), + FromShardID: cx.ShardID, + ToShardID: cx.ToShardID, + } + if blockHash != (common.Hash{}) { + result.BlockHash = blockHash + result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) + } + return result +} + // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { From 3980ae614734dee4c3cbf6a3fd5af7057d96e998 Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Fri, 13 Sep 2019 23:59:35 -0700 Subject: [PATCH 3/3] use only one index for CXEntryLookup; use shardID instead of fromShardID in RPC returned results --- core/rawdb/accessors_indexes.go | 36 ++++++++++++------------ core/rawdb/schema.go | 1 - core/types/block.go | 7 ++--- core/types/bodyv0.go | 6 ++-- core/types/bodyv1.go | 21 +++++++------- internal/hmyapi/transactionpool.go | 2 +- internal/hmyapi/types.go | 44 +++++++++++++++--------------- 7 files changed, 58 insertions(+), 59 deletions(-) diff --git a/core/rawdb/accessors_indexes.go b/core/rawdb/accessors_indexes.go index 64080b16f..1b48c0e5f 100644 --- a/core/rawdb/accessors_indexes.go +++ b/core/rawdb/accessors_indexes.go @@ -124,32 +124,33 @@ func WriteBloomBits(db DatabaseWriter, bit uint, section uint64, head common.Has } } -// ReadCxLookupEntry retrieves the positional metadata associated with a transaction -// hash to allow retrieving the transaction or receipt by hash. +// ReadCxLookupEntry retrieves the positional metadata associated with a transaction hash +// to allow retrieving cross shard receipt by hash in destination shard +// not the original transaction in source shard // return nil if not found -func ReadCxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64, uint64) { +func ReadCxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64) { data, _ := db.Get(cxLookupKey(hash)) if len(data) == 0 { - return common.Hash{}, 0, 0, 0 + return common.Hash{}, 0, 0 } var entry TxLookupEntry if err := rlp.DecodeBytes(data, &entry); err != nil { utils.Logger().Error().Err(err).Str("hash", hash.Hex()).Msg("Invalid transaction lookup entry RLP") - return common.Hash{}, 0, 0, 0 + return common.Hash{}, 0, 0 } - return entry.BlockHash, entry.BlockIndex, entry.Index, entry.SubIndex + return entry.BlockHash, entry.BlockIndex, entry.Index } // WriteCxLookupEntries stores a positional metadata for every transaction from // a block, enabling hash based transaction and receipt lookups. func WriteCxLookupEntries(db DatabaseWriter, block *types.Block) { - for i, cxp := range block.IncomingReceipts() { + previousSum := 0 + for _, cxp := range block.IncomingReceipts() { for j, cx := range cxp.Receipts { entry := TxLookupEntry{ BlockHash: block.Hash(), BlockIndex: block.NumberU64(), - Index: uint64(i), - SubIndex: uint64(j), + Index: uint64(j + previousSum), } data, err := rlp.EncodeToBytes(entry) if err != nil { @@ -159,6 +160,7 @@ func WriteCxLookupEntries(db DatabaseWriter, block *types.Block) { utils.Logger().Error().Err(err).Msg("Failed to store transaction lookup entry") } } + previousSum += len(cxp.Receipts) } } @@ -169,10 +171,10 @@ func DeleteCxLookupEntry(db DatabaseDeleter, hash common.Hash) { // ReadCXReceipt retrieves a specific transaction from the database, along with // its added positional metadata. -func ReadCXReceipt(db DatabaseReader, hash common.Hash) (*types.CXReceipt, common.Hash, uint64, uint64, uint64) { - blockHash, blockNumber, cxIndex, cxSubIndex := ReadCxLookupEntry(db, hash) +func ReadCXReceipt(db DatabaseReader, hash common.Hash) (*types.CXReceipt, common.Hash, uint64, uint64) { + blockHash, blockNumber, cxIndex := ReadCxLookupEntry(db, hash) if blockHash == (common.Hash{}) { - return nil, common.Hash{}, 0, 0, 0 + return nil, common.Hash{}, 0, 0 } body := ReadBody(db, blockHash, blockNumber) if body == nil { @@ -180,19 +182,17 @@ func ReadCXReceipt(db DatabaseReader, hash common.Hash) (*types.CXReceipt, commo Uint64("number", blockNumber). Str("hash", blockHash.Hex()). Uint64("index", cxIndex). - Uint64("subIndex", cxSubIndex). Msg("block Body referenced missing") - return nil, common.Hash{}, 0, 0, 0 + return nil, common.Hash{}, 0, 0 } - cx := body.CXReceiptAt(int(cxIndex), int(cxSubIndex)) + cx := body.CXReceiptAt(int(cxIndex)) if cx == nil { utils.Logger().Error(). Uint64("number", blockNumber). Str("hash", blockHash.Hex()). Uint64("index", cxIndex). - Uint64("subIndex", cxSubIndex). Msg("CXReceipt referenced missing") - return nil, common.Hash{}, 0, 0, 0 + return nil, common.Hash{}, 0, 0 } - return cx, blockHash, blockNumber, cxIndex, cxSubIndex + return cx, blockHash, blockNumber, cxIndex } diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 6ba443ba5..15a0f3adb 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -94,7 +94,6 @@ type TxLookupEntry struct { BlockHash common.Hash BlockIndex uint64 Index uint64 - SubIndex uint64 // used for lookup CXReceipt from CXReceiptsProof } // encodeBlockNumber encodes a block number as big endian uint64 diff --git a/core/types/block.go b/core/types/block.go index 8883830c6..3ecd12c30 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -86,10 +86,9 @@ type BodyInterface interface { // It returns nil if index is out of bounds. TransactionAt(index int) *Transaction - // CXReceiptAt returns the CXReceipt given index (from IncomingReceipts) - // and subindex(from CXReceiptProof in IncomingReceipts) - // It returns nil if index, subindex is out of bounds - CXReceiptAt(index int, subIndex int) *CXReceipt + // CXReceiptAt returns the CXReceipt given index (calculated from IncomingReceipts) + // It returns nil if index is out of bounds + CXReceiptAt(index int) *CXReceipt // SetTransactions sets the list of transactions with a deep copy of the // given list. diff --git a/core/types/bodyv0.go b/core/types/bodyv0.go index 79cd06b54..a6c4a1da0 100644 --- a/core/types/bodyv0.go +++ b/core/types/bodyv0.go @@ -39,10 +39,10 @@ func (b *BodyV0) TransactionAt(index int) *Transaction { return b.f.Transactions[index].Copy() } -// CXReceiptAt returns the CXReceipt at given index-subindex in this block -// It returns nil if index/subindex is out of bounds +// CXReceiptAt returns the CXReceipt at given index in this block +// It returns nil if index is out of bounds // V0 will just return nil because we don't support CXReceipt -func (b *BodyV0) CXReceiptAt(index int, subindex int) *CXReceipt { +func (b *BodyV0) CXReceiptAt(index int) *CXReceipt { return nil } diff --git a/core/types/bodyv1.go b/core/types/bodyv1.go index 8e852cbc1..e14520c88 100644 --- a/core/types/bodyv1.go +++ b/core/types/bodyv1.go @@ -39,19 +39,20 @@ func (b *BodyV1) TransactionAt(index int) *Transaction { return b.f.Transactions[index].Copy() } -// CXReceiptAt returns the CXReceipt at given index/subindex in this block -// It returns nil if index/subindex is out of bounds -func (b *BodyV1) CXReceiptAt(index int, subindex int) *CXReceipt { - if index < 0 || index >= len(b.f.IncomingReceipts) { +// CXReceiptAt returns the CXReceipt at given index in this block +// It returns nil if index is out of bounds +func (b *BodyV1) CXReceiptAt(index int) *CXReceipt { + if index < 0 { return nil } - - cxs := b.f.IncomingReceipts[index].Receipts - if subindex < 0 || subindex >= len(cxs) { - return nil + for _, cxp := range b.f.IncomingReceipts { + cxs := cxp.Receipts + if index < len(cxs) { + return cxs[index].Copy() + } + index -= len(cxs) } - - return cxs[subindex].Copy() + return nil } // SetTransactions sets the list of transactions with a deep copy of the given diff --git a/internal/hmyapi/transactionpool.go b/internal/hmyapi/transactionpool.go index b6e9680fd..0408f6403 100644 --- a/internal/hmyapi/transactionpool.go +++ b/internal/hmyapi/transactionpool.go @@ -215,7 +215,7 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, err // GetCXReceiptByHash returns the transaction for the given hash func (s *PublicTransactionPoolAPI) GetCXReceiptByHash(ctx context.Context, hash common.Hash) *RPCCXReceipt { - if cx, blockHash, blockNumber, _, _ := rawdb.ReadCXReceipt(s.b.ChainDb(), hash); cx != nil { + if cx, blockHash, blockNumber, _ := rawdb.ReadCXReceipt(s.b.ChainDb(), hash); cx != nil { return newRPCCXReceipt(cx, blockHash, blockNumber) } return nil diff --git a/internal/hmyapi/types.go b/internal/hmyapi/types.go index 4c2bf4bca..66511b954 100644 --- a/internal/hmyapi/types.go +++ b/internal/hmyapi/types.go @@ -22,7 +22,7 @@ type RPCTransaction struct { To *common.Address `json:"to"` TransactionIndex hexutil.Uint `json:"transactionIndex"` Value *hexutil.Big `json:"value"` - FromShardID uint32 `json:"fromShardID"` + ShardID uint32 `json:"shardID"` ToShardID uint32 `json:"toShardID"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` @@ -36,7 +36,7 @@ type RPCCXReceipt struct { TxHash common.Hash `json:"hash"` From common.Address `json:"from"` To *common.Address `json:"to"` - FromShardID uint32 `json:"fromShardID"` + ShardID uint32 `json:"shardID"` ToShardID uint32 `json:"toShardID"` Amount *hexutil.Big `json:"value"` } @@ -44,13 +44,13 @@ type RPCCXReceipt struct { // newRPCCXReceipt returns a CXReceipt that will serialize to the RPC representation func newRPCCXReceipt(cx *types.CXReceipt, blockHash common.Hash, blockNumber uint64) *RPCCXReceipt { result := &RPCCXReceipt{ - BlockHash: blockHash, - TxHash: cx.TxHash, - From: cx.From, - To: cx.To, - Amount: (*hexutil.Big)(cx.Amount), - FromShardID: cx.ShardID, - ToShardID: cx.ToShardID, + BlockHash: blockHash, + TxHash: cx.TxHash, + From: cx.From, + To: cx.To, + Amount: (*hexutil.Big)(cx.Amount), + ShardID: cx.ShardID, + ToShardID: cx.ToShardID, } if blockHash != (common.Hash{}) { result.BlockHash = blockHash @@ -70,19 +70,19 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber v, r, s := tx.RawSignatureValues() result := &RPCTransaction{ - From: from, - Gas: hexutil.Uint64(tx.Gas()), - GasPrice: (*hexutil.Big)(tx.GasPrice()), - Hash: tx.Hash(), - Input: hexutil.Bytes(tx.Data()), - Nonce: hexutil.Uint64(tx.Nonce()), - To: tx.To(), - Value: (*hexutil.Big)(tx.Value()), - FromShardID: tx.ShardID(), - ToShardID: tx.ToShardID(), - V: (*hexutil.Big)(v), - R: (*hexutil.Big)(r), - S: (*hexutil.Big)(s), + From: from, + Gas: hexutil.Uint64(tx.Gas()), + GasPrice: (*hexutil.Big)(tx.GasPrice()), + Hash: tx.Hash(), + Input: hexutil.Bytes(tx.Data()), + Nonce: hexutil.Uint64(tx.Nonce()), + To: tx.To(), + Value: (*hexutil.Big)(tx.Value()), + ShardID: tx.ShardID(), + ToShardID: tx.ToShardID(), + V: (*hexutil.Big)(v), + R: (*hexutil.Big)(r), + S: (*hexutil.Big)(s), } if blockHash != (common.Hash{}) { result.BlockHash = blockHash