This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Stop waiting after transactionBlockTimeout
#5294
Merged
Muhammad-Altabba
merged 136 commits into
4.x
from
feature/5113/stop-waiting-after-transactionBlockTimeout
Sep 22, 2022
Merged
Changes from all commits
Commits
Show all changes
136 commits
Select commit
Hold shift + click to select a range
7dd0134
stop waiting after `transactionBlockTimeout`
Muhammad-Altabba d5e4efb
add `transactionRpcTimeou` and implement related logic
Muhammad-Altabba 94fe864
remove a testing variable
Muhammad-Altabba 67b7e4f
fixed typos and re-arranged json
Muhammad-Altabba 635ff8e
few comments edits and tiny enhancements
Muhammad-Altabba 2fe7ff1
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba 6dd9b5c
Merge branch '4.x' into fix/5293/interrupt-waiting-for-node-after-tim…
Muhammad-Altabba 9010022
handle different timeout errors for different providers when nonce is…
Muhammad-Altabba 1e9d2d2
rename transactionRpcTimeout to transactionSendTimeout
Muhammad-Altabba ee618fe
fix an issue inside transactionPollingTimeout at waitForTransactionRe…
Muhammad-Altabba df6b7c4
Merge branch 'fix/5293/interrupt-waiting-for-node-after-timeout' of h…
Muhammad-Altabba b720f85
resolve an issue in a test case with transactionPollingTimeout
Muhammad-Altabba e4e74bf
increase transactionPollingTimeout at some tests
Muhammad-Altabba 373418a
fix a config at a test
Muhammad-Altabba 91e2db2
clare timeout at waitWithTimeout
Muhammad-Altabba afc6c8d
refactor the code for `waitForTransactionReceipt`
Muhammad-Altabba 5c41d40
Merge remote-tracking branch 'origin/4.x' into fix/5293/interrupt-wai…
Muhammad-Altabba ca960de
decrease transactionPollingTimeout config at a test case
Muhammad-Altabba 8514511
Merge branch '4.x' into fix/5293/interrupt-waiting-for-node-after-tim…
Muhammad-Altabba 11d6396
increase `transactionSendTimeout` to 1 min
Muhammad-Altabba 4efe05f
Merge branch 'fix/5293/interrupt-waiting-for-node-after-timeout' of h…
Muhammad-Altabba defdfb7
inclease `transactionSendTimeout` to 750 seconds (12.5 min)
Muhammad-Altabba c12510b
fix a test case by updating a config comparison value
Muhammad-Altabba 612e5b1
updating comment and whitespaces
Muhammad-Altabba 1274bd6
update unit tests accoding to the latest refactor of `WaitForTransact…
Muhammad-Altabba f99dd40
call `Error.captureStackTrace(...)` only if available
Muhammad-Altabba aff34a6
Merge branch '4.x' into fix/5293/interrupt-waiting-for-node-after-tim…
Muhammad-Altabba 3c3331e
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba bd4e535
Merge branch '4.x' into fix/5293/interrupt-waiting-for-node-after-tim…
Muhammad-Altabba 9a3573a
Merge remote-tracking branch 'origin/4.x' into fix/5293/interrupt-wai…
Muhammad-Altabba 3226dfe
updating a comment at an integration est
Muhammad-Altabba ed6a629
Merge remote-tracking branch 'origin/4.x' into feature/5113/stop-wait…
Muhammad-Altabba 6f84799
Merge branch 'feature/5113/stop-waiting-after-transactionBlockTimeout…
Muhammad-Altabba 74a12c2
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba 8d12305
Merge branch '4.x' into fix/5293/interrupt-waiting-for-node-after-tim…
Muhammad-Altabba 80bb971
Merge branch 'fix/5293/interrupt-waiting-for-node-after-timeout' into…
Muhammad-Altabba 56d0af8
small fixes for TransactionBlockTimeout
Muhammad-Altabba 89f9f7a
improve test for transactionBlockTimeout
Muhammad-Altabba 6bd2aeb
apply a fix at a test for transactionBlockTimeout
Muhammad-Altabba 0c98339
update a timeout at test for faster run
Muhammad-Altabba d0c4794
Apply suggestions from code review
Muhammad-Altabba bfe1e5a
Update packages/web3-eth/src/errors.ts
Muhammad-Altabba 28ac55e
add a missing import
Muhammad-Altabba 1d261c9
Merge branch 'fix/5293/interrupt-waiting-for-node-after-timeout' into…
Muhammad-Altabba 3a64910
improve a test case for `transactionBlockTimeout`
Muhammad-Altabba 1ead018
Merge remote-tracking branch 'origin/4.x' into feature/5113/stop-wait…
Muhammad-Altabba 7613844
handle an edge case at at test for transactionBlockTimeout
Muhammad-Altabba 31e2ad5
speedup a test case for transactionBlockTimeout
Muhammad-Altabba 04b6bf4
tolerate when checking an error message at web3-eth
Muhammad-Altabba f9e4cec
Apply BlockTimeout to sendTansaction
Muhammad-Altabba 87a03ef
fix unit test at web3-eth according to the new structure
Muhammad-Altabba f6547ee
fix a docusaurus syntax complain
Muhammad-Altabba f660e8c
try increasing the web3-eth integration test timeout
Muhammad-Altabba 74207ad
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba b174271
try handling promise rejection in one test in a different way because…
Muhammad-Altabba c4ab371
add a missed `return` after `reject` at `sendTransaction`
Muhammad-Altabba 7a35976
tiny fix and tries for an issue in the pipeline
Muhammad-Altabba f367433
try sending more transactions to enforce composing more block for an …
Muhammad-Altabba 9e48309
try for an issue in the pipeline: do not wait for the receipt when te…
Muhammad-Altabba 6e93da0
revert some un-needed changes in test helper
Muhammad-Altabba 5eafd42
revert an update to a jest timeout
Muhammad-Altabba d3491c3
try for an issue in the pipeline
Muhammad-Altabba ae3da4a
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba a4b588c
try for an issue in the pipeline
Muhammad-Altabba 39821cc
try for an issue in the pipeline
Muhammad-Altabba 28d300d
try for an issue in the pipeline
Muhammad-Altabba 4ffdf46
a try for an issue in the pipeline
Muhammad-Altabba 4a598a3
a try for an issue in the pipeline
Muhammad-Altabba 4e67f51
a try for an issue in the pipeline
Muhammad-Altabba 90cebf4
a try for an issue in the pipeline
Muhammad-Altabba fe4cddd
Merge remote-tracking branch 'origin/4.x' into feature/5113/stop-wait…
Muhammad-Altabba 1dbcaa6
a tiny fix after merge
Muhammad-Altabba 2dcfded
enhance a test case at web3-eth integration test
Muhammad-Altabba 476077d
enhance a test case at web3-eth integration test
Muhammad-Altabba d555dc0
enhance a test case at web3-eth integration test
Muhammad-Altabba 2eace84
enhance a test case at web3-eth integration test
Muhammad-Altabba 51abd5c
fix a test case at web3-eth integration default.test.ts
Muhammad-Altabba c702cc0
Merge remote-tracking branch 'origin/4.x' into feature/5113/stop-wait…
Muhammad-Altabba 8df6ba1
add removeAllListeners after finish testing ''watch polling transacti…
Muhammad-Altabba c17481b
add a warn if connection raises an error while closing
Muhammad-Altabba 4303c1d
tiny fix and improvements to tests at web-eth
Muhammad-Altabba 6183d28
tiny fix for a test warning at web-eth
Muhammad-Altabba 279aed2
revert un needed changes
Muhammad-Altabba fd17f20
enhance a test case at web3-eth
Muhammad-Altabba d38ef68
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba dbeab7a
wait a bit to ensure a new block at a test case in web3-eth
Muhammad-Altabba c25b102
Merge branch 'feature/5113/stop-waiting-after-transactionBlockTimeout…
Muhammad-Altabba d5db7d3
tiny enhancement at a test case in web3-eth
Muhammad-Altabba f75014d
try for an issue in the pipeline
Muhammad-Altabba 45eec68
try for an issue in the pipeline
Muhammad-Altabba 3a0805f
try for an issue in the pipeline
Muhammad-Altabba 337fe80
try for an issue in the pipeline
Muhammad-Altabba 566f609
try for an issue in the pipeline
Muhammad-Altabba 9142d08
add few temp console logging
Muhammad-Altabba 1c2b4de
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba e24032f
add few temp console logging
Muhammad-Altabba bd7d191
Merge branch 'feature/5113/stop-waiting-after-transactionBlockTimeout…
Muhammad-Altabba aea8a32
try for an issue in the pipeline
Muhammad-Altabba 1a2fd46
try for an issue in the pipeline
Muhammad-Altabba 8433d3e
try for an issue in the pipeline
Muhammad-Altabba b0e271c
try for an issue in the pipeline
Muhammad-Altabba ba2a4a1
try for an issue in the pipeline
Muhammad-Altabba ac98e10
tiny code cleaning
Muhammad-Altabba 28d79d2
try for an issue in the pipeline
Muhammad-Altabba 71850a9
try for an issue in the pipeline
Muhammad-Altabba 7c831fa
try for an issue in the pipeline
Muhammad-Altabba bca5e6f
try for an issue in the pipeline
Muhammad-Altabba 0ff1573
try for an issue in the pipeline
Muhammad-Altabba 6d3138a
tiny fix for a typing mismatch
Muhammad-Altabba c729654
try for an issue in the pipeline
Muhammad-Altabba ef782bd
try for an issue in the pipeline
Muhammad-Altabba 043cca5
try for an issue in the pipeline
Muhammad-Altabba 3270fc4
try for an issue in the pipeline
Muhammad-Altabba e9a29eb
try for an issue in the pipeline
Muhammad-Altabba d79f880
try for an issue in the pipeline
Muhammad-Altabba bbf5284
Wait a bit before closing a connection
Muhammad-Altabba dbdfe1e
tiny touch for tests at web3-eth
Muhammad-Altabba 045ada6
Add function comment
Muhammad-Altabba 7af5f77
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
Muhammad-Altabba bce6b05
Apply suggestions from code review
Muhammad-Altabba 688fa46
move errors.ts from webs-eth to webb3-errors
Muhammad-Altabba ceee9aa
Merge branch 'feature/5113/stop-waiting-after-transactionBlockTimeout…
Muhammad-Altabba 2cce357
Merge branch '4.x' into feature/5113/stop-waiting-after-transactionBl…
jdevcs abad14e
Merge remote-tracking branch 'origin/4.x' into feature/5113/stop-wait…
Muhammad-Altabba 261007f
fix an issue in the usage of 2 error codes
Muhammad-Altabba 3a3b28e
log for an error in the pipeline
Muhammad-Altabba fe113b2
log for an error in the pipeline
Muhammad-Altabba 3c07dd6
log for an error in the pipeline
Muhammad-Altabba c801202
try for an issue in the pipe line
Muhammad-Altabba 1c08018
improve `rejectIfConditionAtInterval`
Muhammad-Altabba d5432ac
cause pollTillDefined to stop once found
Muhammad-Altabba e826ee9
Merge remote-tracking branch 'origin/4.x' into feature/5113/stop-wait…
Muhammad-Altabba 42086cc
catch and log errors when pooling for new blocks or transaction receipts
Muhammad-Altabba 964f00a
Merge remote-tracking branch 'origin/4.x' into feature/5113/stop-wait…
Muhammad-Altabba 11cc08d
update CHANGELOG.md files
Muhammad-Altabba 6c3139f
update CHANGELOG.md
Muhammad-Altabba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| This file is part of web3.js. | ||
|
|
||
| web3.js is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published by | ||
| the Free Software Foundation, either version 3 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| web3.js is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with web3.js. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| import { EthExecutionAPI, Bytes } from 'web3-types'; | ||
| import { Web3Context } from 'web3-core'; | ||
| import { rejectIfConditionAtInterval } from 'web3-utils'; | ||
|
|
||
| import { TransactionBlockTimeoutError } from 'web3-errors'; | ||
| import { NUMBER_DATA_FORMAT } from '../constants'; | ||
| // eslint-disable-next-line import/no-cycle | ||
| import { getBlockNumber } from '../rpc_method_wrappers'; | ||
|
|
||
| /* TODO: After merge, there will be constant block mining time (exactly 12 second each block, except slot missed that currently happens in <1% of slots. ) so we can optimize following function | ||
| for POS NWs, we can skip checking getBlockNumber(); after interval and calculate only based on time that certain num of blocked are mined after that for internal double check, can do one getBlockNumber() call and timeout. | ||
| */ | ||
| export function rejectIfBlockTimeout( | ||
| web3Context: Web3Context<EthExecutionAPI>, | ||
| starterBlockNumber: number, | ||
| interval: number, | ||
| transactionHash?: Bytes, | ||
| ): [NodeJS.Timer, Promise<never>] { | ||
| return rejectIfConditionAtInterval(async () => { | ||
| let lastBlockNumber; | ||
| try { | ||
| lastBlockNumber = await getBlockNumber(web3Context, NUMBER_DATA_FORMAT); | ||
| } catch (error) { | ||
| console.warn('An error happen while trying to get the block number', error); | ||
| return undefined; | ||
| } | ||
| const numberOfBlocks = lastBlockNumber - starterBlockNumber; | ||
| if (numberOfBlocks >= web3Context.transactionBlockTimeout) { | ||
| return new TransactionBlockTimeoutError({ | ||
| starterBlockNumber, | ||
| numberOfBlocks, | ||
| transactionHash, | ||
| }); | ||
| } | ||
| return undefined; | ||
| }, interval); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| This file is part of web3.js. | ||
|
|
||
| web3.js is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published by | ||
| the Free Software Foundation, either version 3 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| web3.js is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with web3.js. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| import { Web3Context } from 'web3-core'; | ||
| import { EthExecutionAPI, Bytes } from 'web3-types'; | ||
| import { AsyncFunction, rejectIfTimeout } from 'web3-utils'; | ||
|
|
||
| import { TransactionSendTimeoutError } from 'web3-errors'; | ||
| import { NUMBER_DATA_FORMAT } from '../constants'; | ||
| // eslint-disable-next-line import/no-cycle | ||
| import { rejectIfBlockTimeout } from './reject_if_block_timeout'; | ||
| // eslint-disable-next-line import/no-cycle | ||
| import { getBlockNumber } from '../rpc_method_wrappers'; | ||
|
|
||
| /** | ||
| * An internal function to send a transaction or throws if sending did not finish during the timeout during the blocks-timeout. | ||
| * @param web3Context the context to read the configurations from | ||
| * @param sendTransactionFunc the function that will send the transaction (could be sendTransaction or sendRawTransaction) | ||
| * @param transactionHash to be used inside the exception message if there will be any exceptions. | ||
| * @returns the Promise<string> returned by the `sendTransactionFunc`. | ||
| */ | ||
| export async function trySendTransaction( | ||
| web3Context: Web3Context<EthExecutionAPI>, | ||
| sendTransactionFunc: AsyncFunction<string>, | ||
| transactionHash?: Bytes, | ||
| ): Promise<string> { | ||
| const pollingInterval = web3Context.transactionPollingInterval; | ||
|
|
||
| const [timeoutId, rejectOnTimeout] = rejectIfTimeout( | ||
| web3Context.transactionSendTimeout, | ||
| new TransactionSendTimeoutError({ | ||
| numberOfSeconds: web3Context.transactionSendTimeout / 1000, | ||
| transactionHash, | ||
| }), | ||
| ); | ||
|
|
||
| const starterBlockNumber = await getBlockNumber(web3Context, NUMBER_DATA_FORMAT); | ||
| const [intervalId, rejectOnBlockTimeout] = rejectIfBlockTimeout( | ||
| web3Context, | ||
| starterBlockNumber, | ||
| pollingInterval, | ||
| transactionHash, | ||
| ); | ||
|
|
||
| try { | ||
| return await Promise.race([sendTransactionFunc(), rejectOnTimeout, rejectOnBlockTimeout]); | ||
| } finally { | ||
| clearTimeout(timeoutId); | ||
| clearInterval(intervalId); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.