Skip to content

Commit

Permalink
Fill bot: fallback to filling each message individually.
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Aug 14, 2024
1 parent 59a9c6e commit db58152
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- Ingest tracing
- Apply taker fee and spread factor for fill bot amount estimation
- Reduce fill bot slippage bound by one ulp
- Fallback to filling each message individually.

## v25.9.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type TxContextI interface {
// GetSDKMsgs returns chain messages associated with this transaction context as sdk.Msg.
GetSDKMsgs() []sdk.Msg

// GetMsgs returns message contexts
GetMsgs() []msgctx.MsgContextI

// GetAdjustedGasUsedTotal returns the gas used after simulating this transaction
// against chain and adjusting the gas by a constant pre-configured multiplier.
GetAdjustedGasUsedTotal() uint64
Expand Down Expand Up @@ -145,3 +148,8 @@ func (t *txContext) RankAndFilterMsgs() {
func (t *txContext) GetMaxTxFeeCap() osmomath.Dec {
return t.maxTxFeeCap
}

// GetMsgs implements TxContextI.
func (t *txContext) GetMsgs() []msgctx.MsgContextI {
return t.msgs
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,33 @@ func (o *orderbookFillerIngestPlugin) ProcessEndBlock(ctx context.Context, block
}
}

// Execute tx
txCtx := blockCtx.GetTxCtx()
originalMsgs := blockCtx.GetTxCtx().GetMsgs()

blockGasPrice := blockCtx.GetGasPrice()
if err := o.tryFill(ctx, txCtx, blockGasPrice); err != nil {

Check failure on line 170 in ingest/usecase/plugins/orderbookfiller/ordebook_filler_ingest_plugin.go

View workflow job for this annotation

GitHub Actions / Run linter

unnecessary leading newline (whitespace)
o.logger.Error("failed to fill", zap.Error(err))

if len(originalMsgs) == 1 {
o.logger.Error("failed to fill", zap.Error(err))
return err
} else {
o.logger.Error("failed to fill batch of arbs as one tx - falling back to executing each message as separate tx", zap.Error(err))

// Try to fill each message indivdually
for _, msg := range originalMsgs {

Check failure on line 179 in ingest/usecase/plugins/orderbookfiller/ordebook_filler_ingest_plugin.go

View workflow job for this annotation

GitHub Actions / Run linter

unnecessary leading newline (whitespace)

// Create a new transaction context for each message
curTxCtx := txctx.New()

// Add the message to the transaction context
curTxCtx.AddMsg(msg)

// Try to fill the message
if err := o.tryFill(ctx, txCtx, blockGasPrice); err != nil {
o.logger.Error("failed to fill individual msg tx", zap.Error(err))
}
}
}
}

o.logger.Info("processed end block in orderbook filler ingest plugin", zap.Uint64("block_height", blockHeight))
Expand Down

0 comments on commit db58152

Please sign in to comment.