-
Notifications
You must be signed in to change notification settings - Fork 292
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
[rosetta] Mempool Endpoint #3339
Conversation
* [block] Make FormatTransaction public to use in the Mempool * [mempool] Create Transaction for /mempool/transaction using estimated transaction receipt
Codecov Report
@@ Coverage Diff @@
## main #3339 +/- ##
==========================================
- Coverage 34.49% 34.26% -0.24%
==========================================
Files 210 210
Lines 24693 25067 +374
==========================================
+ Hits 8519 8588 +69
- Misses 15523 15826 +303
- Partials 651 653 +2
Continue to review full report at Codecov.
|
PR is related to #3210 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just take care of the error with collect reward txs
pool, err := s.hmy.GetPoolTransactions() | ||
if err != nil { | ||
return nil, common.NewError(common.CatchAllError, map[string]interface{}{ | ||
"message": "unable to fetch pool transactions", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a good idea to also give the err
message here.
rosetta/services/mempool.go
Outdated
Status: hmyTypes.ReceiptStatusSuccessful, // Assume transaction will succeed | ||
CumulativeGasUsed: poolTx.Gas(), | ||
Bloom: [256]byte{}, | ||
Logs: []*hmyTypes.Log{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing logs here for collect reward transaction will cause an error, reference:
harmony/rosetta/services/block.go
Lines 1004 to 1024 in e74ab0b
func getAmountFromCollectRewards( | |
receipt *hmytypes.Receipt, senderAddress ethcommon.Address, | |
) (*types.Amount, *types.Error) { | |
var amount *types.Amount | |
logs := findLogsWithTopic(receipt, staking.CollectRewardsTopic) | |
for _, log := range logs { | |
if log.Address == senderAddress { | |
amount = &types.Amount{ | |
Value: fmt.Sprintf("%v", big.NewInt(0).SetBytes(log.Data)), | |
Currency: &common.Currency, | |
} | |
break | |
} | |
} | |
if amount == nil { | |
return nil, common.NewError(common.CatchAllError, map[string]interface{}{ | |
"message": fmt.Sprintf("collect rewards amount not found for %v", senderAddress), | |
}) | |
} | |
return amount, nil | |
} |
Can just create some dummy logs with the collect reward topic and have the value at 0.
d463184
to
dbca516
Compare
Implements
/mempool
&/mempool/transaction
The transaction fetch implementation utilizes an "estimated" version of the finalized transaction receipt, which assumes transaction success.
No test file, because
formatTransaction
is already tested inblock_test.go
.Example: