Skip to content

Commit

Permalink
chore(release): 1.0.0
Browse files Browse the repository at this point in the history
* improved workflows
* delaying process.exit in order to write logs to file
* improved sending bundle logic
* improved logs

Co-authored-by: 0xng <[email protected]>
Co-authored-by: wei3erHase <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2022
1 parent 1641484 commit 936e82d
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keep3r-network/cli",
"version": "1.0.0-beta.1",
"version": "1.0.0",
"description": "Keep3r CLI",
"keywords": [
"keep3r",
Expand Down
4 changes: 1 addition & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/job-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});

Expand Down
32 changes: 18 additions & 14 deletions src/utils/flashbots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,29 @@ export class Flashbots {
targetBlock: number,
logId: string
): Promise<boolean> {
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;
Expand Down
43 changes: 31 additions & 12 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
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<boolean> =>
({ result, workRequest }): Observable<boolean> =>
result
? of(result)
: retryWorkAndSendTx(
job,
aheadAmount,
timeToAdvance,
priorityFee,
bundleBurst,
correlationId,
skipIds,
workRequest,
processManager,
keeper,
flashbots,
localProvider
)
)
),
share()
);
}

Expand Down

0 comments on commit 936e82d

Please sign in to comment.