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 inspect-deal command to lotus client #5833

Merged
merged 25 commits into from
Apr 1, 2021
Merged

Conversation

nonsense
Copy link
Member

@nonsense nonsense commented Mar 18, 2021

  1. Requires: Add DealStages to track and log Deal status updates go-fil-markets#502
  2. Requires: Add ChannelStages to keep track of history of lifecycle of a DataTransfer go-data-transfer#163

This PR is adding a inspect-deal subcommand to lotus client. Its purpose is to provide more information about a specific deal, and filter deals by deal-id or by proposal-cid.

At the moment the output looks like:

Deal ID: 10
Proposal CID: bafyreigvio7johbflmwvcqsqvov26gz62mscy3f5yb4ymjdcbscd2q6d3m

Stage: ReserveClientFunds: Reserving client funds (a few minutes)
  Mar 18 12:18:56 funds reserved, amount <402397026845688>
  Mar 18 12:18:56 adding funds with message <bafy2bzaceax3kesknjfft25kq3m3nnf4zfkuxdebseosessntkbhrmv3sgzgk>
Stage: FundsReserved: FundsReserved (a few minutes)
  Mar 18 12:19:25 initiate data transfer
Stage: StartDataTransfer: Starting data transfer (a few minutes)
  Mar 18 12:19:26 data transfer initiated on channel id <12D3KooWPUTfSmaU5RMKF2oQZfWdDsNGP6ooGoi4wNzKNeGTaDiC-12D3KooWFXYNSdc5z74bjHp1AhVAZR9bijayy62oRRgwnR6fGw3e-0>
              Data transfer stage: Requested
              Data transfer stage: Ongoing
              Mar 18 12:19:26 queued data
              Mar 18 12:19:26 sent data
              Data transfer stage: ResponderCompleted
              Data transfer stage: Completing
Stage: CheckForAcceptance: Checking for deal acceptance (a few minutes)
  Mar 18 12:19:27 provider is verifying the data
  Mar 18 12:19:28 waiting for provider to publish the deal on-chain
  Mar 18 12:21:33 provider has submitted the deal on-chain
  Mar 18 12:22:22 deal has been accepted
Stage: ProposalAccepted: Proposal accepted (a few minutes)
  Mar 18 12:22:22 funds released, amount <402397026845688>
...

@nonsense nonsense requested review from dirkmc and raulk March 18, 2021 12:55
Copy link
Contributor

@dirkmc dirkmc left a comment

Choose a reason for hiding this comment

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

Once the debugging code is removed, LGTM 👍

cli/client.go Outdated Show resolved Hide resolved
build/params_2k.go Outdated Show resolved Hide resolved
cli/deal/showdeals.go Outdated Show resolved Hide resolved
cli/deal/showdeals.go Outdated Show resolved Hide resolved
color.Blue("Proposal CID: %s\n\n", di.ProposalCid.String())

for _, stg := range di.DealStages.Stages {
msg := fmt.Sprintf("%s %s: %s (%s)", color.BlueString("Stage:"), color.BlueString(strings.TrimPrefix(stg.Name, "StorageDeal")), stg.Description, color.GreenString(stg.ExpectedDuration))
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we'd do a fmt.Fprintf in the cli.Context.App.Writer, but if all other commands are writing outputs directly to stdout, then we can keep it like it is.

cli/deal/showdeals.go Outdated Show resolved Hide resolved
cli/deal/showdeals.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
node/impl/client/client.go Outdated Show resolved Hide resolved
@@ -289,6 +292,7 @@ func (a *API) newDealInfoWithTransfer(transferCh *api.DataTransferChannel, v sto
Verified: v.Proposal.VerifiedDeal,
TransferChannelID: v.TransferChannelID,
DataTransfer: transferCh,
DealStages: v.DealStages,
Copy link
Member

Choose a reason for hiding this comment

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

This data can be quite heavy to transfer over the wire (JSON-RPC) if it's not needed.

Since the CLI only allows to inspect a single deal, why not create an ClientDealInspect JSON-RPC operation? It's wasteful to send over all the DealStages detail, when we know the CLI will only use a single one.

Copy link
Contributor

Choose a reason for hiding this comment

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

How big can this get?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the deal transfer stages are unbounded (i.e. data transfer keeps crashing, and deal is restarted indefinitely), this will be unbounded. In general for successful deals (or those that have a few failures), the struct looks like the following (see attached file).
output.txt

Copy link
Contributor

Choose a reason for hiding this comment

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

So this is ok for a single deal, but I think that we shouldn't set this in ClientListDeals (which we do now)

Copy link
Member Author

@nonsense nonsense Apr 1, 2021

Choose a reason for hiding this comment

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

I am now populating the Stages and DealStages fields only when calling ClientGetDealInfo and not on ClientListDeals - not sure if we want omitempty JSON tags so that they don't appear at all when making JSON RPC calls...

@willscott
Copy link
Contributor

Noting that this is likely in critical path for work next week, so we ideally can get some eyes on it and get it into a version of lotus that a can be run at least on the testnet sooner rather than later.

@raulk raulk self-assigned this Mar 25, 2021
node/impl/client/client.go Outdated Show resolved Hide resolved
Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

I was trying to take this over the finish line, but I believe it's missing commits. I know we removed the interactive menu, we renamed the command to inspect-deal, and it takes proposal-cid or deal-id flags. But I see none of this in this branch.

@nonsense
Copy link
Member Author

@raulk this is ready for merging, once we get go-fil-markets and go-data-transfer PRs merged and we update go.mod here. The inspect-deal has been tested with deals created before/after this version, so it's backward compatible.

@nonsense nonsense marked this pull request as ready for review March 30, 2021 14:00
@nonsense
Copy link
Member Author

I think this is ready for review and merge - all deps have been updated given the latest go-fil-markets release.

@dirkmc could you confirm if we should merge this before/after the changes in the minerx branch end on master?

cli/deal/inspect.go Outdated Show resolved Hide resolved
@@ -289,6 +292,7 @@ func (a *API) newDealInfoWithTransfer(transferCh *api.DataTransferChannel, v sto
Verified: v.Proposal.VerifiedDeal,
TransferChannelID: v.TransferChannelID,
DataTransfer: transferCh,
DealStages: v.DealStages,
Copy link
Contributor

Choose a reason for hiding this comment

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

How big can this get?

@magik6k magik6k merged commit 49be1f3 into master Apr 1, 2021
@magik6k magik6k deleted the nonsense/cli-show-deals branch April 1, 2021 14:33
@magik6k magik6k mentioned this pull request Apr 13, 2021
69 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants