From 936e82d55933950298200e8b833dc20135d92149 Mon Sep 17 00:00:00 2001 From: 0xGorilla <84932007+0xGorilla@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:15:28 +0100 Subject: [PATCH] chore(release): 1.0.0 * improved workflows * delaying process.exit in order to write logs to file * improved sending bundle logic * improved logs Co-authored-by: 0xng Co-authored-by: wei3erHase --- .../{release.yml => git-release.yml} | 15 ++++++- CHANGELOG.md | 23 ++++++++++ package.json | 2 +- src/core.ts | 4 +- src/job-wrapper.ts | 3 +- src/utils/flashbots.ts | 32 ++++++++------ src/utils/helpers.ts | 43 +++++++++++++------ 7 files changed, 90 insertions(+), 32 deletions(-) rename .github/workflows/{release.yml => git-release.yml} (59%) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/release.yml b/.github/workflows/git-release.yml similarity index 59% rename from .github/workflows/release.yml rename to .github/workflows/git-release.yml index 9a5d636..fefbf16 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/git-release.yml @@ -4,8 +4,21 @@ on: push: branches: - main + - public jobs: + tag: + name: Create tag for new version + runs-on: ubuntu-latest + outputs: + tag_name: ${{ steps.create_new_tag.outputs.tag }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - uses: salsify/action-detect-and-tag-new-version@v2 + id: create_new_tag + release: name: Create release runs-on: ubuntu-latest @@ -21,4 +34,4 @@ jobs: tag_name: ${{ needs.tag.outputs.tag_name }} release_name: ${{ needs.tag.outputs.tag_name }} draft: false - prerelease: false + prerelease: false \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1ecbbc6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## 1.0.0 (2022-01-03) + + +### Bug Fixes + +* improved workflows +* delaying process.exit in order to write logs to file +* improved sending bundle logic +* improved logs + +## 1.0.0-beta.1 (2021-12-14) + +### Features + +* working beta version +* fixed priority fee per job +* e2e and unit tests +* simulation feature +* lots of documentation diff --git a/package.json b/package.json index c01110a..b65f1e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@keep3r-network/cli", - "version": "1.0.0-beta.1", + "version": "1.0.0", "description": "Keep3r CLI", "keywords": [ "keep3r", diff --git a/src/core.ts b/src/core.ts index 1225afa..468af2b 100644 --- a/src/core.ts +++ b/src/core.ts @@ -70,12 +70,10 @@ import { hideBin } from 'yargs/helpers'; } else { const retry$ = retryWorkAndSendTx( job, - job.config.bundleBurst, job.config.timeToAdvance, job.config.priorityFee, job.config.bundleBurst, - workRequest.correlationId, - Object.keys(idsInProgress), + workRequest, processManager, keeper, flashbots, diff --git a/src/job-wrapper.ts b/src/job-wrapper.ts index bff5306..43d9ae1 100644 --- a/src/job-wrapper.ts +++ b/src/job-wrapper.ts @@ -63,7 +63,8 @@ let logMetadata: { job: string }; .subscribe({ next: () => console.info('Sent workable txs to core'), complete: async () => { - process.exit(); + // give some time to logs to be exported (printed to files or something else) + setTimeout(() => process.exit(), 30); }, }); diff --git a/src/utils/flashbots.ts b/src/utils/flashbots.ts index 5382110..1d23f3c 100644 --- a/src/utils/flashbots.ts +++ b/src/utils/flashbots.ts @@ -90,25 +90,29 @@ export class Flashbots { targetBlock: number, logId: string ): Promise { - const logConsole = prelog({ targetBlock, logId }); + const logConsole = prelog({ targetBlock, logId, provider: provider.connection.url }); logConsole.log(`Sending bundle`); - const response = await provider.sendBundle(bundle, targetBlock); + try { + const response = await provider.sendBundle(bundle, targetBlock); - if ('error' in response) { - logConsole.log(`Bundle execution error`, response.error); - return false; - } + if ('error' in response) { + logConsole.log(`Bundle execution error`, response.error); + return false; + } - const resolution = await response.wait(); + const resolution = await response.wait(); - if (resolution == FlashbotsBundleResolution.BundleIncluded) { - logConsole.info(`Bundle status: BundleIncluded`); - return true; - } else if (resolution == FlashbotsBundleResolution.BlockPassedWithoutInclusion) { - logConsole.info(`Bundle status: BlockPassedWithoutInclusion`); - } else if (resolution == FlashbotsBundleResolution.AccountNonceTooHigh) { - logConsole.warn(`AccountNonceTooHigh`); + if (resolution == FlashbotsBundleResolution.BundleIncluded) { + logConsole.info(`Bundle status: BundleIncluded`); + return true; + } else if (resolution == FlashbotsBundleResolution.BlockPassedWithoutInclusion) { + logConsole.info(`Bundle status: BlockPassedWithoutInclusion`); + } else if (resolution == FlashbotsBundleResolution.AccountNonceTooHigh) { + logConsole.warn(`AccountNonceTooHigh`); + } + } catch (err: unknown) { + logConsole.warn(`Failed to send bundle`, { error: err }); } return false; diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 3ac77bf..0fb7d80 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -65,41 +65,60 @@ export function doWork( export function retryWorkAndSendTx( job: JobObject, - aheadAmount: number, timeToAdvance: number, priorityFee: number, bundleBurst: number, - correlationId: string, - skipIds: string[], + lastWorkRequest: WorkRequest, processManager: ProcessManager, keeper: string, flashbots: Flashbots, localProvider: providers.JsonRpcProvider ): Observable { return from(localProvider.getBlockNumber()).pipe( - tap((forkBlock) => console.log(`Retrying work for ${job.metadata.name} forking block ${forkBlock}`)), - concatMap((forkBlock) => - doWork(job, forkBlock, timeToAdvance, priorityFee, aheadAmount, bundleBurst, processManager, keeper, skipIds, correlationId) + concatMap((currentBlockNumber) => { + const lastTargetBlockInBurst = Math.max(...lastWorkRequest.burst.map((item) => item.targetBlock)); + const aheadAmount = lastTargetBlockInBurst - currentBlockNumber + 1; + console.log('Retrying work', { + job: job.metadata.name, + forkBlock: currentBlockNumber, + targetBlock: currentBlockNumber + aheadAmount, + }); + return doWork( + job, + currentBlockNumber, + timeToAdvance, + priorityFee, + aheadAmount, + bundleBurst, + processManager, + keeper, + [], + lastWorkRequest.correlationId + ); + }), + mergeMap((workRequest) => + sendTxs(workRequest, flashbots).then((result) => ({ + workRequest, + result, + })) ), - mergeMap((workRequests) => sendTxs(workRequests, flashbots)), mergeMap( - (result: boolean): Observable => + ({ result, workRequest }): Observable => result ? of(result) : retryWorkAndSendTx( job, - aheadAmount, timeToAdvance, priorityFee, bundleBurst, - correlationId, - skipIds, + workRequest, processManager, keeper, flashbots, localProvider ) - ) + ), + share() ); }