-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
if len(batches) == 0 { | ||
fmt.Println("No pending settlement batches found") |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too
cmd/solvercli/cmd/settle_orders.go
Outdated
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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the batch relays
There was a problem hiding this comment.
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?
cmd/solvercli/cmd/settle_orders.go
Outdated
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). |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
b6f5d99
to
5b9b327
Compare
There was a problem hiding this 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
skip-go-fast-solver/ordersettler/ordersettler.go
Lines 504 to 513 in ad9cc0a
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) | |
} |
No description provided.