Skip to content

Commit a61d4fc

Browse files
authored
feat: Autostaker transaction timeout (#3236)
Using 60s timeout for stake and unstake transactions.
1 parent 2f1d16c commit a61d4fc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Changes before Tatum release are not documented in this file.
1212

1313
#### Added
1414

15+
- Transaction timeouts in Autostaker (https://github.com/streamr-dev/network/pull/3236)
16+
1517
#### Changed
1618

1719
#### Deprecated

packages/node/src/plugins/autostaker/AutostakerPlugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const MIN_SPONSORSHIP_TOTAL_PAYOUT_PER_SECOND = 1000000000000n
5353
const ACTION_SUBMIT_RETRY_COUNT = 5
5454
const ACTION_SUBMIT_RETRY_DELAY_MS = 5000
5555
const ACTION_GAS_LIMIT_BUMP_PCT = 20
56+
const TRANSACTION_TIMEOUT = 60 * 1000
5657

5758
const fetchMinStakePerSponsorship = async (theGraphClient: TheGraphClient): Promise<bigint> => {
5859
const queryResult = await theGraphClient.queryEntity<{ network: { minimumStakeWei: string } }>({
@@ -73,7 +74,8 @@ const getStakeOrUnstakeFunction = (action: Action): (
7374
sponsorshipContractAddress: string,
7475
amount: WeiAmount,
7576
bumpGasLimitPct: number,
76-
onSubmit: (tx: ContractTransactionResponse) => void
77+
onSubmit: (tx: ContractTransactionResponse) => void,
78+
transactionTimeout?: number
7779
) => Promise<ContractTransactionReceipt | null> => {
7880
switch (action.type) {
7981
case 'stake':
@@ -148,7 +150,8 @@ export class AutostakerPlugin extends Plugin<AutostakerPluginConfig> {
148150
// be staking/unstaking at the same time, so we bump the gas limit to be safe
149151
ACTION_GAS_LIMIT_BUMP_PCT,
150152
// resolve on the onSubmit callback (=tx is broadcasted) instead of when the stakeOrUnstakeFunction resolves (=tx is mined)
151-
(tx) => resolve(tx)
153+
(tx) => resolve(tx),
154+
TRANSACTION_TIMEOUT
152155
).catch(reject)
153156
})
154157
}

0 commit comments

Comments
 (0)