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

feat: introduce node command #2669

Merged
merged 49 commits into from
Aug 22, 2022
Merged

feat: introduce node command #2669

merged 49 commits into from
Aug 22, 2022

Conversation

tbruyelle
Copy link
Contributor

@tbruyelle tbruyelle commented Jul 27, 2022

Fix #2489

This PR continues the work of #2539. An other PR was required because the original branch was from an other repo.

What I did so far :

  • rebase on develop (fixed a bunch on conflicts)
  • finish @ilgooz refac on integration tooling
  • fix node command integration tests
  • fix spinner display in node command that hides the os keyring passphrase prompt. The problem exists because a spinner is displayed as soon as cliui.New() is invoked. Maybe other commands are impacted. c66131f
  • revamp the bank send toAccount fromAccount impl so it doesn't need the --from flag and accepts both account name or address.
  • fix broadcast error message. There was an old mention of SPN 6fe217f
  • add --fees flag (required for tx on cosmos-hub apparently) cb4ab7c
  • add --broadcast-mode flag to let the user change it to sync, to avoid timeouts when the requested node is too busy e3b92cf
  • Tested node q bank balances and node tx bank send with cosmos-hub account (see latest txs of https://www.mintscan.io/cosmos/account/cosmos1k2m58vv732yjrs6pnhaf3ar8dtwdql5mlcv478)
  • Integration tests: replace time.Sleep in favor of new method app.WaitNBlocks()

Kudos to @bjaanes who did the major part of the work!

@tbruyelle tbruyelle marked this pull request as draft July 27, 2022 14:07
@tbruyelle tbruyelle changed the title WIP: node command feat: introduce node command Jul 27, 2022
@tbruyelle tbruyelle force-pushed the issue-2489-node-bank-cmds branch 2 times, most recently from 08190bd to 0ab22ac Compare July 29, 2022 14:14
@ilgooz
Copy link
Member

ilgooz commented Jul 29, 2022

Should we split down this PR to parts for ex:

  • changes for cosmosclient
  • changes for integration pkg api
  • ... maybe more?
  • finally we can merge this PR to add node cmd feature and its integration tests

@tbruyelle
Copy link
Contributor Author

Should we split down this PR to parts for ex:

  • changes for cosmosclient
  • changes for integration pkg api
  • ... maybe more?
  • finally we can merge this PR to add node cmd feature and its integration tests

The cosmosclient changes are nested with the previous changes of the original PR, so that's complicated... I can try!

@ilgooz
Copy link
Member

ilgooz commented Jul 29, 2022

we don't need to worry much about this I think if it requires a ton of work, I'm in favor of not splitting

@tbruyelle tbruyelle force-pushed the issue-2489-node-bank-cmds branch from 009538f to 3792a26 Compare July 29, 2022 21:41
gjermundgaraba and others added 17 commits July 29, 2022 23:55
Bounty address: cosmos1zra3wz596n0qc898myceka3q23x9rk8fuw65c7
Fixed a bunch of conflicts with recent renaming
That helps when some commands are not running properly.
Also simplify the logic by removing the read of the --from flag, which
is no longer used in this command.

BroadcastTx now takes a cosmosaccount.Account instead of just an account
name. Since ensure the account comes from the keyring, and avoid the
BroadcastTx impl to re-check that (because the keyring is always
checked before the call to BroadcastTx).
fees are required, at least in cosmos-hub to send funds to an other
account. W/o fees the transaction returns this message:
error code: '13' msg: 'insufficient fees; got:  required: 8uatom:
insufficient fee'

Also increase the additional gas amount added to the simulated gas,
because I got some insufficient gas error with the previous value.
@aljo242
Copy link
Contributor

aljo242 commented Aug 12, 2022

Can we resolve the existing conflicts? Reviewing now

@aljo242
Copy link
Contributor

aljo242 commented Aug 12, 2022

All commands fail with the default flag as https://rpc.cosmos.network with the following error:

post failed: Post "https://rpc.cosmos.network": dial tcp: address rpc.cosmos.network: missing port in address

Commands work if i use --node https://rpc.cosmos.network:443 so I think we just need to add the proper port.

@tbruyelle
Copy link
Contributor Author

All commands fail with the default flag as https://rpc.cosmos.network with the following error:

post failed: Post "https://rpc.cosmos.network": dial tcp: address rpc.cosmos.network: missing port in address

Commands work if i use --node https://rpc.cosmos.network:443 so I think we just need to add the proper port.

I can't reproduce the problem on my side, but I have noticed it sometimes ago with an other node, so let's add it 10bd29e

integration/env.go Outdated Show resolved Hide resolved
aljo242
aljo242 previously approved these changes Aug 13, 2022
@aljo242
Copy link
Contributor

aljo242 commented Aug 13, 2022

LGTM - just a formatting suggestion

@aljo242
Copy link
Contributor

aljo242 commented Aug 16, 2022

Tried to update the branch and created a merge error - my bad

Fixed 3fa6677

aljo242
aljo242 previously approved these changes Aug 16, 2022
@aljo242 aljo242 mentioned this pull request Aug 18, 2022
7 tasks
func TestNodeQueryTx(t *testing.T) {
var (
appname = randstr.Runes(10)
// alice = "alice"
Copy link
Member

Choose a reason for hiding this comment

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

Should remove these lines if not used?

@tbruyelle tbruyelle merged commit 781e90a into develop Aug 22, 2022
@tbruyelle tbruyelle deleted the issue-2489-node-bank-cmds branch August 22, 2022 10:23
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
* add node command with bank query and send

Bounty address: cosmos1zra3wz596n0qc898myceka3q23x9rk8fuw65c7

* Code review cleanup

* Code review fix

* fix merge

* refactor

* Merge branch 'develop' into issue-2489-node-banks-cmds

Fixed a bunch of conflicts with recent renaming

* wip: fix integration tests due to recent refac

* test: finish apply refac in tests

* Fix integration test on node command

* various improvments in node integration test

* test: read test.v to add more trace on step execution

That helps when some commands are not running properly.

* fix: spinner hides os keyring prompt

* Ensure bank send can take account name or address

Also simplify the logic by removing the read of the --from flag, which
is no longer used in this command.

BroadcastTx now takes a cosmosaccount.Account instead of just an account
name. Since ensure the account comes from the keyring, and avoid the
BroadcastTx impl to re-check that (because the keyring is always
checked before the call to BroadcastTx).

* fix after rebase

* fix: bank balance can take an address absent of the keyring

* fix tx broadcast error message

* add fees flag to node tx bank send cmd

fees are required, at least in cosmos-hub to send funds to an other
account. W/o fees the transaction returns this message:
error code: '13' msg: 'insufficient fees; got:  required: 8uatom:
insufficient fee'

Also increase the additional gas amount added to the simulated gas,
because I got some insufficient gas error with the previous value.

* Change tx BroadcastMode to BroadcastSync

Previous mode BroadcastBlock alweus triggered a timeout error, even if
the tx was finally accepted in a block.

RPC error -32603 - Internal error: timed out waiting for tx to be
included in a block

* fix linter

* fix other lint

* improve lookupAddress error report

* fix typo

* wip

* simplify

* add assertBankBalanceOutput

* wip find a way to wait for block height

* test: replace time.Sleep with app.WaitNBlocks

* gofumpt

* fix integration test

* BroadcastBlock is deprecated

* simplify node query

* feat: move WaitForBlock methods in cosmosclient

* fix: revert usage of BroadcastSync mode

* docs: adapt blog tutorial to cosmosclient changes

* feat: add --broadcasd-mode flag to node tx command

The default value is still block but the flag can change to sync in
order to avoid timeout when the tx is broadcasted to busy nodes.

Also add a `node query tx` so the user can check when his tx is
included in a block.

* comments

* style: consolidate arg names

* fix: add port to default node

* merge const decls

* fix merge error

* fix after merge

* fix after merge

Co-authored-by: Gjermund Bjaanes <[email protected]>
Co-authored-by: İlker G. Öztürk <[email protected]>
Co-authored-by: Alex Johnson <[email protected]>
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.

add node command set w/ token transfer functionality
4 participants