Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix klay_getBlockWithConsensusInfo when receipts are unavailable #2071

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/api_public_blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ func getFrom(tx *types.Transaction) common.Address {
return from
}

func NewRPCTransaction(b *types.Block, tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) map[string]interface{} {
return newRPCTransaction(b, tx, blockHash, blockNumber, index)
}

// newRPCTransaction returns a transaction that will serialize to the RPC
// representation, with the given location metadata set (if available).
func newRPCTransaction(b *types.Block, tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) map[string]interface{} {
Expand Down
7 changes: 6 additions & 1 deletion consensus/istanbul/backend/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,12 @@ func (api *APIExtension) makeRPCBlockOutput(b *types.Block,
numTxs := len(transactions)
rpcTransactions := make([]map[string]interface{}, numTxs)
for i, tx := range transactions {
rpcTransactions[i] = klaytnApi.RpcOutputReceipt(head, tx, hash, head.Number.Uint64(), uint64(i), receipts[i])
if len(receipts) == len(transactions) {
rpcTransactions[i] = klaytnApi.RpcOutputReceipt(head, tx, hash, head.Number.Uint64(), uint64(i), receipts[i])
} else {
// fill the transaction output if receipt is not found
rpcTransactions[i] = klaytnApi.NewRPCTransaction(b, tx, hash, head.Number.Uint64(), uint64(i))
}
}

r["committee"] = cInfo.Committee
Expand Down