Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/components/c2d/compute_engine_docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ export class C2DEngineDocker extends C2DEngine {

private async cleanUpUnknownLocks(chain: string, currentTimestamp: bigint) {
try {
const nodeAddress = await this.getKeyManager().getEthAddress()
const nodeAddress = this.getKeyManager().getEthAddress()
const jobIds: any[] = []
const tokens: string[] = []
const payer: string[] = []
Expand All @@ -765,6 +765,10 @@ export class C2DEngineDocker extends C2DEngine {
'0x0000000000000000000000000000000000000000',
nodeAddress
)
if (!balocks || balocks.length === 0) {
CORE_LOGGER.warn(`Could not find any locks for chain ${chain}, skipping cleanup`)
return
}
for (const lock of balocks) {
const lockExpiry = BigInt(lock.expiry.toString())
if (currentTimestamp > lockExpiry) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/integration/compute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ describe('Compute', () => {
})

it('should wait for jobWithOutputURL status 70 and download output from URL', async function () {
this.timeout(130_000) // waitForAllJobsToFinish can take up to 120s
this.timeout(180_000) // waitForAllJobsToFinish can take up to 180s
assert(jobWithOutputURL, 'jobWithOutputURL must be set by previous test')
const statusTask: ComputeGetStatusCommand = {
command: PROTOCOL_COMMANDS.COMPUTE_GET_STATUS,
Expand Down
39 changes: 26 additions & 13 deletions src/utils/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ethers,
Signer,
Contract,
JsonRpcApiProvider,
JsonRpcProvider,
FallbackProvider,
isAddress,
Expand All @@ -15,18 +14,12 @@ import { getConfiguration } from './config.js'
import { CORE_LOGGER } from './logging/common.js'
import { ConnectionStatus } from '../@types/blockchain.js'
import { ValidateChainId } from '../@types/commands.js'
// import { KNOWN_CONFIDENTIAL_EVMS } from '../utils/address.js'
import { OceanNodeConfig } from '../@types/OceanNode.js'
import { KeyManager } from '../components/KeyManager/index.js'

export class Blockchain {
private config?: OceanNodeConfig // Optional for new constructor
private static signers: Map<string, Signer> = new Map()
private static providers: Map<string, JsonRpcApiProvider> = new Map()
private keyManager: KeyManager
private signer: Signer
private provider: FallbackProvider
private providers: JsonRpcProvider[] = []
private chainId: number
private knownRPCs: string[] = []

Expand Down Expand Up @@ -65,24 +58,44 @@ export class Blockchain {

public async getProvider(force: boolean = false): Promise<FallbackProvider> {
if (!this.provider) {
for (const rpc of this.knownRPCs) {
const configs: {
provider: JsonRpcProvider
priority: number
stallTimeout: number
}[] = []

const PRIMARY_RPC_TIMEOUT = 3000
const FALLBACK_RPC_TIMEOUT = 1500
for (let i = 0; i < this.knownRPCs.length; i++) {
const rpc = this.knownRPCs[i]
const rpcProvider = new JsonRpcProvider(rpc)
// filter wrong chains or broken RPCs
if (!force) {
try {
const { chainId } = await rpcProvider.getNetwork()
if (chainId.toString() === this.chainId.toString()) {
this.providers.push(rpcProvider)
break
// primary RPC gets lowest priority = is first to be called
configs.push({
provider: rpcProvider,
priority: i + 1,
stallTimeout: i === 0 ? PRIMARY_RPC_TIMEOUT : FALLBACK_RPC_TIMEOUT
})
}
} catch (error) {
CORE_LOGGER.error(`Error getting network for RPC ${rpc}: ${error}`)
}
} else {
this.providers.push(new JsonRpcProvider(rpc))
configs.push({
provider: rpcProvider,
priority: i + 1,
stallTimeout: i === 0 ? PRIMARY_RPC_TIMEOUT : FALLBACK_RPC_TIMEOUT
})
}
}
this.provider = new FallbackProvider(this.providers)
// quorum=1: accept the first response to avoid calls to all configured rpcs
this.provider =
configs.length > 0
? new FallbackProvider(configs, undefined, { quorum: 1 })
: new FallbackProvider([])
Comment thread
ndrpp marked this conversation as resolved.
}
return this.provider
}
Expand Down
Loading