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

[dot/rpc] implement RPC system_accountNextIndex #1376

Merged
merged 16 commits into from
Feb 17, 2021

Conversation

edwardmack
Copy link
Member

@edwardmack edwardmack commented Feb 9, 2021

Changes

  • Implement system_accountNextIndex to lookup account nonce from state storage.

Tests

go test ./dot/rpc/... -run TestSystemModule_AccountNextIndex

Checklist

  • I have read CODE_OF_CONDUCT and CONTRIBUTING
  • I have provided as much information as possible and necessary
  • I have reviewed my own pull request before requesting a review
  • All integration tests and required coverage checks are passing

Issues

Comment on lines 174 to 175
if req == nil || len(req.String) == 0 {
return errors.New("Account address must be valid")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe move this to the top of the function so it checks it first?

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea.

Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good!

@edwardmack
Copy link
Member Author

Added check of pending transactions before looking in storage. codeclimate is complaining, so please take a re-look at this and let me know suggestions for cleaning it up.

@edwardmack edwardmack requested review from arijitAD, noot and RyRy79261 and removed request for anthdm February 16, 2021 16:40
Comment on lines +185 to +186
if sigNonce.Uint64() > nonce {
nonce = sigNonce.Uint64()
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't the nonce always be greater unless it's 0, in which case it's fine to directly set it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but there may be more than one tx signed by that user in the tx pool, so did this to make sure we have the maximum nonce.

res := new(interface{})
err := sys.Properties(nil, nil, res)
require.NoError(t, err)
require.Equal(t, expected, *res)
}

func TestSystemModule_AccountNextIndex(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to add a test for the non-pending case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I've added tests.

Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

nice work!

@edwardmack edwardmack merged commit 409b3aa into development Feb 17, 2021
@edwardmack edwardmack deleted the ed/rpc_accountNextIndex branch February 17, 2021 22:04
github-actions bot pushed a commit that referenced this pull request Feb 17, 2021
Edward Mack: [dot/rpc] implement RPC system_accountNextIndex (#1376)

* stub AccountNextIndex

* implement rpc system_accountNextIndex

* lint

* update testService_Methods

* move parmeter check

* add TransactionStateAPI to RPC systemModule

* add check of pending transactions ot accountNextIndex

* add test for pending tranactions

* run lint

* add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants