Skip to content

Commit 936e82d

Browse files
0xGorilla0xngwei3erHase
authored
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 <[email protected]> Co-authored-by: wei3erHase <[email protected]>
1 parent 1641484 commit 936e82d

File tree

7 files changed

+90
-32
lines changed

7 files changed

+90
-32
lines changed
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ on:
44
push:
55
branches:
66
- main
7+
- public
78

89
jobs:
10+
tag:
11+
name: Create tag for new version
12+
runs-on: ubuntu-latest
13+
outputs:
14+
tag_name: ${{ steps.create_new_tag.outputs.tag }}
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 2
19+
- uses: salsify/action-detect-and-tag-new-version@v2
20+
id: create_new_tag
21+
922
release:
1023
name: Create release
1124
runs-on: ubuntu-latest
@@ -21,4 +34,4 @@ jobs:
2134
tag_name: ${{ needs.tag.outputs.tag_name }}
2235
release_name: ${{ needs.tag.outputs.tag_name }}
2336
draft: false
24-
prerelease: false
37+
prerelease: false

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
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.
4+
5+
## 1.0.0 (2022-01-03)
6+
7+
8+
### Bug Fixes
9+
10+
* improved workflows
11+
* delaying process.exit in order to write logs to file
12+
* improved sending bundle logic
13+
* improved logs
14+
15+
## 1.0.0-beta.1 (2021-12-14)
16+
17+
### Features
18+
19+
* working beta version
20+
* fixed priority fee per job
21+
* e2e and unit tests
22+
* simulation feature
23+
* lots of documentation

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@keep3r-network/cli",
3-
"version": "1.0.0-beta.1",
3+
"version": "1.0.0",
44
"description": "Keep3r CLI",
55
"keywords": [
66
"keep3r",

src/core.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,10 @@ import { hideBin } from 'yargs/helpers';
7070
} else {
7171
const retry$ = retryWorkAndSendTx(
7272
job,
73-
job.config.bundleBurst,
7473
job.config.timeToAdvance,
7574
job.config.priorityFee,
7675
job.config.bundleBurst,
77-
workRequest.correlationId,
78-
Object.keys(idsInProgress),
76+
workRequest,
7977
processManager,
8078
keeper,
8179
flashbots,

src/job-wrapper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ let logMetadata: { job: string };
6363
.subscribe({
6464
next: () => console.info('Sent workable txs to core'),
6565
complete: async () => {
66-
process.exit();
66+
// give some time to logs to be exported (printed to files or something else)
67+
setTimeout(() => process.exit(), 30);
6768
},
6869
});
6970

src/utils/flashbots.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,29 @@ export class Flashbots {
9090
targetBlock: number,
9191
logId: string
9292
): Promise<boolean> {
93-
const logConsole = prelog({ targetBlock, logId });
93+
const logConsole = prelog({ targetBlock, logId, provider: provider.connection.url });
9494
logConsole.log(`Sending bundle`);
9595

96-
const response = await provider.sendBundle(bundle, targetBlock);
96+
try {
97+
const response = await provider.sendBundle(bundle, targetBlock);
9798

98-
if ('error' in response) {
99-
logConsole.log(`Bundle execution error`, response.error);
100-
return false;
101-
}
99+
if ('error' in response) {
100+
logConsole.log(`Bundle execution error`, response.error);
101+
return false;
102+
}
102103

103-
const resolution = await response.wait();
104+
const resolution = await response.wait();
104105

105-
if (resolution == FlashbotsBundleResolution.BundleIncluded) {
106-
logConsole.info(`Bundle status: BundleIncluded`);
107-
return true;
108-
} else if (resolution == FlashbotsBundleResolution.BlockPassedWithoutInclusion) {
109-
logConsole.info(`Bundle status: BlockPassedWithoutInclusion`);
110-
} else if (resolution == FlashbotsBundleResolution.AccountNonceTooHigh) {
111-
logConsole.warn(`AccountNonceTooHigh`);
106+
if (resolution == FlashbotsBundleResolution.BundleIncluded) {
107+
logConsole.info(`Bundle status: BundleIncluded`);
108+
return true;
109+
} else if (resolution == FlashbotsBundleResolution.BlockPassedWithoutInclusion) {
110+
logConsole.info(`Bundle status: BlockPassedWithoutInclusion`);
111+
} else if (resolution == FlashbotsBundleResolution.AccountNonceTooHigh) {
112+
logConsole.warn(`AccountNonceTooHigh`);
113+
}
114+
} catch (err: unknown) {
115+
logConsole.warn(`Failed to send bundle`, { error: err });
112116
}
113117

114118
return false;

src/utils/helpers.ts

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,60 @@ export function doWork(
6565

6666
export function retryWorkAndSendTx(
6767
job: JobObject,
68-
aheadAmount: number,
6968
timeToAdvance: number,
7069
priorityFee: number,
7170
bundleBurst: number,
72-
correlationId: string,
73-
skipIds: string[],
71+
lastWorkRequest: WorkRequest,
7472
processManager: ProcessManager,
7573
keeper: string,
7674
flashbots: Flashbots,
7775
localProvider: providers.JsonRpcProvider
7876
): Observable<boolean> {
7977
return from(localProvider.getBlockNumber()).pipe(
80-
tap((forkBlock) => console.log(`Retrying work for ${job.metadata.name} forking block ${forkBlock}`)),
81-
concatMap((forkBlock) =>
82-
doWork(job, forkBlock, timeToAdvance, priorityFee, aheadAmount, bundleBurst, processManager, keeper, skipIds, correlationId)
78+
concatMap((currentBlockNumber) => {
79+
const lastTargetBlockInBurst = Math.max(...lastWorkRequest.burst.map((item) => item.targetBlock));
80+
const aheadAmount = lastTargetBlockInBurst - currentBlockNumber + 1;
81+
console.log('Retrying work', {
82+
job: job.metadata.name,
83+
forkBlock: currentBlockNumber,
84+
targetBlock: currentBlockNumber + aheadAmount,
85+
});
86+
return doWork(
87+
job,
88+
currentBlockNumber,
89+
timeToAdvance,
90+
priorityFee,
91+
aheadAmount,
92+
bundleBurst,
93+
processManager,
94+
keeper,
95+
[],
96+
lastWorkRequest.correlationId
97+
);
98+
}),
99+
mergeMap((workRequest) =>
100+
sendTxs(workRequest, flashbots).then((result) => ({
101+
workRequest,
102+
result,
103+
}))
83104
),
84-
mergeMap((workRequests) => sendTxs(workRequests, flashbots)),
85105
mergeMap(
86-
(result: boolean): Observable<boolean> =>
106+
({ result, workRequest }): Observable<boolean> =>
87107
result
88108
? of(result)
89109
: retryWorkAndSendTx(
90110
job,
91-
aheadAmount,
92111
timeToAdvance,
93112
priorityFee,
94113
bundleBurst,
95-
correlationId,
96-
skipIds,
114+
workRequest,
97115
processManager,
98116
keeper,
99117
flashbots,
100118
localProvider
101119
)
102-
)
120+
),
121+
share()
103122
);
104123
}
105124

0 commit comments

Comments
 (0)