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

Add and fix missing txn/staking txn rpc apis #2343

Merged
merged 4 commits into from
Mar 3, 2020

Conversation

denniswon
Copy link
Contributor

Issue

Fixes issue #2227
Explorer for staking network is not displaying the transaction history

Test

Unit Test Coverage

Before:

<!-- copy/paste 'go test -cover' result in the directory you made change -->

After:

<!-- copy/paste 'go test -cover' result in the directory you made change -->

Test/Run Logs

Operational Checklist

  1. Does this PR introduce backward-incompatible changes to the on-disk data structure and/or the over-the-wire protocol?. (If no, skip to question 8.)

    NO

  2. Does this PR introduce backward-incompatible changes NOT related to on-disk data structure and/or over-the-wire protocol? (If no, continue to question 11.)

    NO. (There is no change in API name or args. Just addition of new api funcs)

  3. Does the existing node.sh continue to work with this change?

    YES

  4. What should node operators know about this change?

    Harmony doc should be updated with the new api functions with explanations.
    Also, fixed some api function comments correcting the functionality/purpose of the function.
    cc: @Renewwen @Cem-Harmony could you help me update these once merged and released?

  5. Does this PR introduce significant changes to the operational requirements of the node software, such as >20% increase in CPU, memory, and/or disk usage?

    NO

TODO

Check and add/fix missing or incorrect staking related RPC apis if needed.

@denniswon denniswon added the rpc RPC or API label Feb 28, 2020
@denniswon denniswon self-assigned this Feb 28, 2020
return addressData.TXs[i].Timestamp < addressData.TXs[j].Timestamp
})
}
hashes := make([]common.Hash, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer literal when don't have dynamic size, aka hashes := []common.Hash{}

@@ -241,6 +240,12 @@ func (b *APIBackend) GetTransactionsHistory(address, txType, order string) ([]co
return hashes, err
}

// GetStakingTransactionsHistory returns list of staking transactions hashes of address.
func (b *APIBackend) GetStakingTransactionsHistory(address, txType, order string) ([]common.Hash, error) {
hashes, err := b.hmy.nodeAPI.GetStakingTransactionsHistory(address, txType, order)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well just return b.hmy.... the signatures are the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you clarify your comment here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the signature of b.hmy.nodeAPI.GetStakingTransactionsHistory is the same as the RPC GetStakingTransactionsHistory so no point to hold onto intermediate variables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see. so no possibility they will/could become different between regular vs. staking txns, correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course its possible, its an open source project, anything can change. But we can change when needed, rather than adds lines of code now.


// GetStakingTransactionsHistory returns list of staking transactions hashes of address.
func (node *Node) GetStakingTransactionsHistory(address, txType, order string) ([]common.Hash, error) {
addressData := &explorer.Address{}
Copy link
Contributor

@gupadhyaya gupadhyaya Feb 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the code for this function is exactly same as GetTransactionsHistory, can't you just call it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, no need for even further code duplication

Copy link
Contributor

@flicker-harmony flicker-harmony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the guys already commented on most things. But I have separate PR which might get in conflict with your code. #2317

@LeoHChen
Copy link
Contributor

LeoHChen commented Mar 2, 2020

Jenkins, test this please.

@denniswon denniswon force-pushed the pr_txn_history branch 2 times, most recently from a8709de to 0440a60 Compare March 2, 2020 18:38
@denniswon
Copy link
Contributor Author

@flicker-harmony this PR fixes the open staking launch blocker issue #2227.
Need to merge this asap.
Will merge this first, and review your PR.

@fxfactorial @gupadhyaya please review.

@denniswon denniswon added block-explorer-backend block-explorer-backend related issues block-explorer-frontend block-explorer-frontend related issues labels Mar 3, 2020
@denniswon
Copy link
Contributor Author

denniswon commented Mar 3, 2020

From @flicker-harmony told me about there was an issue previously that might be why I am getting the error during my local testing where the explorer node's level db does not get updated even with account txns. And this issue on master is related to the staking changes in node/node_explorer.go where quorum gets checked? (It fails and so no blocks are committed to explorer storage)

@rlan35 @fxfactorial any context? so should I rebase to s3? cc: @LeoHChen which branch is being pushed to ostn? s3 or t3?

This issue is what above refers to: #2266

@rlan35 rlan35 merged commit 84abf83 into harmony-one:master Mar 3, 2020
rlan35 added a commit that referenced this pull request Mar 3, 2020
fxfactorial pushed a commit that referenced this pull request Mar 3, 2020
denniswon added a commit to denniswon/harmony that referenced this pull request Mar 7, 2020
* Add and fix missing txn/staking txn rpc apis

* removed StakingTxHistoryArgs as currently not needed yet
denniswon pushed a commit to denniswon/harmony that referenced this pull request Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block-explorer-backend block-explorer-backend related issues block-explorer-frontend block-explorer-frontend related issues rpc RPC or API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants