Hotfix: don't crash on web3 provider errors during initialization
This commit is contained in:
parent
6568e428b1
commit
883e18da81
|
@ -416,31 +416,34 @@ proc init*(T: type Eth1Monitor,
|
||||||
var web3Url = web3Url
|
var web3Url = web3Url
|
||||||
fixupWeb3Urls web3Url
|
fixupWeb3Urls web3Url
|
||||||
|
|
||||||
let dataProviderRes = await Web3DataProvider.new(depositContractAddress, web3Url)
|
try:
|
||||||
if dataProviderRes.isErr:
|
let dataProviderRes = await Web3DataProvider.new(depositContractAddress, web3Url)
|
||||||
return err(dataProviderRes.error)
|
if dataProviderRes.isErr:
|
||||||
|
return err(dataProviderRes.error)
|
||||||
|
|
||||||
let
|
|
||||||
dataProvider = dataProviderRes.get
|
|
||||||
web3 = dataProvider.web3
|
|
||||||
|
|
||||||
if eth1Network.isSome:
|
|
||||||
let
|
let
|
||||||
providerNetwork = await web3.provider.net_version()
|
dataProvider = dataProviderRes.get
|
||||||
expectedNetwork = case eth1Network.get
|
web3 = dataProvider.web3
|
||||||
of mainnet: "1"
|
|
||||||
of rinkeby: "4"
|
|
||||||
of goerli: "5"
|
|
||||||
if expectedNetwork != providerNetwork:
|
|
||||||
return err("The specified web3 provider is not attached to the " &
|
|
||||||
$eth1Network.get & " network")
|
|
||||||
|
|
||||||
return ok T(
|
if eth1Network.isSome:
|
||||||
db: db,
|
let
|
||||||
preset: preset,
|
providerNetwork = await web3.provider.net_version()
|
||||||
depositContractDeployedAt: depositContractDeployedAt,
|
expectedNetwork = case eth1Network.get
|
||||||
dataProvider: dataProvider,
|
of mainnet: "1"
|
||||||
eth1Progress: newAsyncEvent())
|
of rinkeby: "4"
|
||||||
|
of goerli: "5"
|
||||||
|
if expectedNetwork != providerNetwork:
|
||||||
|
return err("The specified web3 provider is not attached to the " &
|
||||||
|
$eth1Network.get & " network")
|
||||||
|
|
||||||
|
return ok T(
|
||||||
|
db: db,
|
||||||
|
preset: preset,
|
||||||
|
depositContractDeployedAt: depositContractDeployedAt,
|
||||||
|
dataProvider: dataProvider,
|
||||||
|
eth1Progress: newAsyncEvent())
|
||||||
|
except CatchableError as err:
|
||||||
|
return err("Failed to initialize the Eth1 monitor")
|
||||||
|
|
||||||
proc allDepositsUpTo(m: Eth1Monitor, totalDeposits: uint64): seq[DepositData] =
|
proc allDepositsUpTo(m: Eth1Monitor, totalDeposits: uint64): seq[DepositData] =
|
||||||
for i in 0'u64 ..< totalDeposits:
|
for i in 0'u64 ..< totalDeposits:
|
||||||
|
|
Loading…
Reference in New Issue