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: add cobra command to batch settle pending settlements #77

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

nadim-az
Copy link
Contributor

No description provided.

@nadim-az nadim-az requested a review from a team as a code owner November 26, 2024 22:37
}

if len(batches) == 0 {
fmt.Println("No pending settlement batches found")
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use the logging library

return
}

fmt.Printf("Found %d pending settlement batches\n", len(batches))
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too

fmt.Printf("Source Chain: %s\n", batch.SourceChainID())
fmt.Printf("Destination Chain: %s\n", batch.DestinationChainID())
fmt.Printf("Number of Orders: %d\n", len(batch.OrderIDs()))
fmt.Printf("Transaction Hash: %s\n", hashes[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too

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 personally think the format is clearer when the final result is printed to the user this way rather than a structured log, that's why I used fmt.Printf for these 3 instances, but if you disagree I can change too


fmt.Printf("Found %d pending settlement batches\n", len(batches))

hashes, err := settler.SettleBatches(ctx, batches)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this will initiate settlements but not relay the hyperlane message to the destination. How were you intending for the relay to complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the batch relays

Copy link
Contributor

Choose a reason for hiding this comment

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

The hyperlane validator set usually takes a bit to generate the checkpoints signatures. What happens if those signatures aren't generated here? Were you able to test this?

var settleCmd = &cobra.Command{
Use: "settle-orders",
Short: "Settle pending order batches",
Long: `Settle all pending order batches immediately without any threshold checks (ignoring configured BatchUUSDCSettleUpThreshold).
Copy link
Contributor

Choose a reason for hiding this comment

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

The way this command is currently written, the UX involves first having run the solver to populate the db with pending settlements. Probably worth mentioning in the description

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 removed the db dependency to instead get pending settlements from the contract

@nadim-az nadim-az force-pushed the na/add-settleorder-cli branch from b6f5d99 to 5b9b327 Compare December 20, 2024 09:23
@nadim-az
Copy link
Contributor Author

Screenshot 2024-12-23 at 1 45 43 PM

Copy link
Contributor

@dhfang dhfang left a comment

Choose a reason for hiding this comment

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

doesnt this still have a dependency on the db? what happens if the settlements do not exist in the database when this clause is executed

for _, settlement := range batch {
settlementTx := db.SetInitiateSettlementTxParams{
SourceChainID: settlement.SourceChainID,
OrderID: settlement.OrderID,
SourceChainGatewayContractAddress: settlement.SourceChainGatewayContractAddress,
InitiateSettlementTx: sql.NullString{String: txHash, Valid: true},
}
if _, err = q.SetInitiateSettlementTx(ctx, settlementTx); err != nil {
return fmt.Errorf("setting initiate settlement tx for settlement from source chain %s with order id %s: %w", settlement.SourceChainID, settlement.OrderID, err)
}

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.

2 participants