Skip to content

Commit

Permalink
master->mainnet (#319)
Browse files Browse the repository at this point in the history
* Bumping sdk and jit dependencies to 2.104.0-beta.13 and 0.12.8

* Bumping sdk and jit dependencies to 2.104.0-beta.14 and 0.12.9

* Bumping sdk and jit dependencies to 2.104.0-beta.15 and 0.12.10

* Bumping sdk and jit dependencies to 2.104.0-beta.16 and 0.12.11

* Bumping sdk and jit dependencies to 2.104.0-beta.19 and 0.12.12

* Bumping sdk and jit dependencies to 2.104.0-beta.23 and 0.12.13

* update examples for swift refactor

* update example bots

* exclude market 4

* Bumping sdk and jit dependencies to 2.104.0-beta.28 and 0.12.15

* bundleSender reconnect, refactor filler logs (#317)

* bundleSender reconnect, refactor filler logs

* fix sim

* add jito_connected metric, check if bundle sender is connected

* switchboard crank: jito check

---------

Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nour Alharithi <nour.alharithi@gmail.com>
3 people authored Dec 17, 2024
1 parent 63d5d65 commit 07fb397
Showing 13 changed files with 402 additions and 366 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -65,4 +65,6 @@ jobs:
kubectl get deployments -n $BRANCH_NAME -o name | grep filler | xargs -I {} kubectl rollout restart {} -n $BRANCH_NAME
kubectl rollout restart -n $BRANCH_NAME deployment/liquidator-bot
kubectl rollout restart -n $BRANCH_NAME deployment/pyth-cranker-bot
kubectl rollout restart -n $BRANCH_NAME deployment/switchboard-cranker-bot
kubectl rollout restart -n $BRANCH_NAME deployment/switchboard-cranker-bot
kubectl rollout restart -n $BRANCH_NAME deployment/swift-taker-example-bot
kubectl rollout restart -n $BRANCH_NAME deployment/swift-maker-example-bot
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
"main": "lib/index.js",
"license": "Apache-2.0",
"dependencies": {
"@drift-labs/jit-proxy": "0.12.7",
"@drift-labs/sdk": "2.104.0-beta.12",
"@drift-labs/jit-proxy": "0.12.15",
"@drift-labs/sdk": "2.104.0-beta.28",
"@opentelemetry/api": "1.7.0",
"@opentelemetry/auto-instrumentations-node": "0.31.2",
"@opentelemetry/exporter-prometheus": "0.31.0",
65 changes: 35 additions & 30 deletions src/bots/filler.ts
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ import {
validRebalanceSettledPnlThreshold,
} from '../utils';
import { selectMakers } from '../makerSelection';
import { BundleSender } from '../bundleSender';
import { BundleSender, JITO_METRIC_TYPES } from '../bundleSender';
import { Metrics } from '../metrics';
import { LRUCache } from 'lru-cache';
import { bs58 } from '@project-serum/anchor/dist/cjs/utils/bytes';
@@ -147,11 +147,6 @@ enum METRIC_TYPES {
simulate_tx_duration_histogram = 'simulate_tx_duration_histogram',
expired_nodes_set_size = 'expired_nodes_set_size',

jito_bundles_accepted = 'jito_bundles_accepted',
jito_bundles_simulation_failure = 'jito_simulation_failure',
jito_dropped_bundle = 'jito_dropped_bundle',
jito_landed_tips = 'jito_landed_tips',
jito_bundle_count = 'jito_bundle_count',
clock_subscriber_ts = 'clock_subscriber_ts',
wall_clock_ts = 'wall_clock_ts',
}
@@ -225,6 +220,7 @@ export class FillerBot extends TxThreaded implements Bot {
protected mutexBusyCounter?: CounterValue;
protected attemptedTriggersCounter?: CounterValue;
protected txSimErrorCounter?: CounterValue;
protected jitoConnectedGauge?: GaugeValue;
protected jitoBundlesAcceptedGauge?: GaugeValue;
protected jitoBundlesSimulationFailureGauge?: GaugeValue;
protected jitoDroppedBundleGauge?: GaugeValue;
@@ -450,24 +446,28 @@ export class FillerBot extends TxThreaded implements Bot {
METRIC_TYPES.tx_sim_error_count,
'Count of errors from simulating transactions'
);
this.jitoConnectedGauge = this.metrics.addGauge(
JITO_METRIC_TYPES.jito_connected,
'Whether the jito bundle sender is connected'
);
this.jitoBundlesAcceptedGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_accepted,
JITO_METRIC_TYPES.jito_bundles_accepted,
'Count of jito bundles that were accepted'
);
this.jitoBundlesSimulationFailureGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_simulation_failure,
JITO_METRIC_TYPES.jito_bundles_simulation_failure,
'Count of jito bundles that failed simulation'
);
this.jitoDroppedBundleGauge = this.metrics.addGauge(
METRIC_TYPES.jito_dropped_bundle,
JITO_METRIC_TYPES.jito_dropped_bundle,
'Count of jito bundles that were dropped'
);
this.jitoLandedTipsGauge = this.metrics.addGauge(
METRIC_TYPES.jito_landed_tips,
JITO_METRIC_TYPES.jito_landed_tips,
'Gauge of historic bundle tips that landed'
);
this.jitoBundleCount = this.metrics.addGauge(
METRIC_TYPES.jito_bundle_count,
JITO_METRIC_TYPES.jito_bundle_count,
'Count of jito bundles that were sent, and their status'
);
this.clockSubscriberTs = this.metrics.addGauge(
@@ -1453,15 +1453,16 @@ export class FillerBot extends TxThreaded implements Bot {
marketType,
} = await this.getNodeFillInfo(nodeToFill);

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling multi maker perp node with ${nodeToFill.makerNodes.length} makers (fillTxId: ${fillTxId})`
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'multiMakerPerpFill',
this.revertOnFailure ?? false,
false
);

if (!isVariant(marketType, 'perp')) {
@@ -1645,7 +1646,7 @@ export class FillerBot extends TxThreaded implements Bot {
const nodesSent: Array<NodeToFill> = [];
const fillTxId = this.fillTxId++;

for (const [idx, nodeToFill] of nodesToFill.entries()) {
for (const [_idx, nodeToFill] of nodesToFill.entries()) {
let ixs: Array<TransactionInstruction> = [
ComputeBudgetProgram.setComputeUnitLimit({
units: 1_400_000,
@@ -1681,15 +1682,16 @@ export class FillerBot extends TxThreaded implements Bot {
marketType,
} = await this.getNodeFillInfo(nodeToFill);

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling perp node ${idx} (fillTxId: ${fillTxId})`
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'fillPerpNode',
this.revertOnFailure ?? false,
false
);
this.logSlots();

@@ -2260,6 +2262,9 @@ export class FillerBot extends TxThreaded implements Bot {
}
return slotsUntilJito < SLOTS_UNTIL_JITO_LEADER_TO_SEND;
}
if (!this.bundleSender?.connected()) {
return false;
}
return true;
}

69 changes: 36 additions & 33 deletions src/bots/spotFiller.ts
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ import {
validMinimumGasAmount,
validRebalanceSettledPnlThreshold,
} from '../utils';
import { BundleSender } from '../bundleSender';
import { JITO_METRIC_TYPES, BundleSender } from '../bundleSender';
import {
CACHED_BLOCKHASH_OFFSET,
CONFIRM_TX_INTERVAL_MS,
@@ -139,11 +139,6 @@ enum METRIC_TYPES {
simulate_tx_duration_histogram = 'simulate_tx_duration_histogram',
expired_nodes_set_size = 'expired_nodes_set_size',

jito_bundles_accepted = 'jito_bundles_accepted',
jito_bundles_simulation_failure = 'jito_simulation_failure',
jito_dropped_bundle = 'jito_dropped_bundle',
jito_landed_tips = 'jito_landed_tips',
jito_bundle_count = 'jito_bundle_count',
clock_subscriber_ts = 'clock_subscriber_ts',
wall_clock_ts = 'wall_clock_ts',
}
@@ -309,6 +304,7 @@ export class SpotFillerBot implements Bot {
protected pendingTxSigsLoopRateLimitedCounter?: CounterValue;
protected evictedPendingTxSigsToConfirmCounter?: CounterValue;
protected expiredNodesSetSize?: GaugeValue;
protected jitoConnectedGauge?: GaugeValue;
protected jitoBundlesAcceptedGauge?: GaugeValue;
protected jitoBundlesSimulationFailureGauge?: GaugeValue;
protected jitoDroppedBundleGauge?: GaugeValue;
@@ -583,24 +579,28 @@ export class SpotFillerBot implements Bot {
METRIC_TYPES.expired_nodes_set_size,
'Count of nodes that are expired'
);
this.jitoConnectedGauge = this.metrics.addGauge(
JITO_METRIC_TYPES.jito_connected,
'Whether the jito bundle sender is connected'
);
this.jitoBundlesAcceptedGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_accepted,
JITO_METRIC_TYPES.jito_bundles_accepted,
'Count of jito bundles that were accepted'
);
this.jitoBundlesSimulationFailureGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_simulation_failure,
JITO_METRIC_TYPES.jito_bundles_simulation_failure,
'Count of jito bundles that failed simulation'
);
this.jitoDroppedBundleGauge = this.metrics.addGauge(
METRIC_TYPES.jito_dropped_bundle,
JITO_METRIC_TYPES.jito_dropped_bundle,
'Count of jito bundles that were dropped'
);
this.jitoLandedTipsGauge = this.metrics.addGauge(
METRIC_TYPES.jito_landed_tips,
JITO_METRIC_TYPES.jito_landed_tips,
'Gauge of historic bundle tips that landed'
);
this.jitoBundleCount = this.metrics.addGauge(
METRIC_TYPES.jito_bundle_count,
JITO_METRIC_TYPES.jito_bundle_count,
'Count of jito bundles that were sent, and their status'
);
this.clockSubscriberTs = this.metrics.addGauge(
@@ -1571,6 +1571,9 @@ export class SpotFillerBot implements Bot {
}
return slotsUntilJito < SLOTS_UNTIL_JITO_LEADER_TO_SEND;
}
if (!this.bundleSender?.connected()) {
return false;
}
return true;
}

@@ -1764,17 +1767,17 @@ export class SpotFillerBot implements Bot {
marketType,
} = await this.getNodeFillInfo(nodeToFill);

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling multi maker spot node with ${nodeToFill.makerNodes.length} makers (fillTxId: ${fillTxId})`,
spotPrecision,
'SHOULD_NOT_HAVE_NO_MAKERS'
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'multiMakerSpotFill',
this.revertOnFailure ?? false,
false,
spotPrecision
);

if (!isVariant(marketType, 'spot')) {
@@ -2015,17 +2018,17 @@ export class SpotFillerBot implements Bot {
}
}

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling spot node with ${nodeToFill.makerNodes.length} makers (fillTxId: ${fillTxId})`,
spotMarketPrecision,
fallbackSource as string
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'fillSpotNode',
this.revertOnFailure ?? false,
false,
spotMarketPrecision
);

const ixs = [
15 changes: 13 additions & 2 deletions src/bots/switchboardCranker.ts
Original file line number Diff line number Diff line change
@@ -106,6 +106,16 @@ export class SwitchboardCrankerBot implements Bot {
return recentBlockhash.blockhash;
}

private shouldBuildForBundle(): boolean {
if (!this.globalConfig.useJito) {
return false;
}
if (!this.bundleSender?.connected()) {
return false;
}
return true;
}

async runCrankLoop() {
const pullFeedAliases = chunks(
shuffle(Object.keys(this.crankConfigs.pullFeedConfigs)),
@@ -119,7 +129,8 @@ export class SwitchboardCrankerBot implements Bot {
}),
];

if (this.globalConfig.useJito) {
const shouldBuildForBundle = this.shouldBuildForBundle();
if (shouldBuildForBundle) {
ixs.push(this.bundleSender!.getTipIx());
} else {
const priorityFees =
@@ -143,7 +154,7 @@ export class SwitchboardCrankerBot implements Bot {
await this.getBlockhashForTx()
);

if (this.globalConfig.useJito) {
if (shouldBuildForBundle) {
tx.sign([
// @ts-ignore;
this.driftClient.wallet.payer,
Loading

0 comments on commit 07fb397

Please sign in to comment.