Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
85a1fead
Unverified
Commit
85a1fead
authored
Oct 01, 2021
by
Mark Tyneway
Committed by
GitHub
Oct 01, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1393 from ethereum-optimism/sc/use-fallback-provider
feat: use FallbackProvider in the DTL
parents
0847f199
e0be02e1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
14 deletions
+88
-14
eleven-moles-pull.md
.changeset/eleven-moles-pull.md
+6
-0
package.json
packages/core-utils/package.json
+1
-0
index.ts
packages/core-utils/src/index.ts
+1
-0
provider.ts
packages/core-utils/src/provider.ts
+40
-0
service.ts
...data-transport-layer/src/services/l1-ingestion/service.ts
+9
-8
event-handler-types.ts
...ges/data-transport-layer/src/types/event-handler-types.ts
+2
-2
contracts.ts
packages/data-transport-layer/src/utils/contracts.ts
+4
-4
yarn.lock
yarn.lock
+25
-0
No files found.
.changeset/eleven-moles-pull.md
0 → 100644
View file @
85a1fead
---
'
@eth-optimism/core-utils'
:
patch
'
@eth-optimism/data-transport-layer'
:
patch
---
Add fallback provider support to DTL using helper function in core-utils
packages/core-utils/package.json
View file @
85a1fead
...
...
@@ -47,6 +47,7 @@
},
"dependencies"
:
{
"@ethersproject/abstract-provider"
:
"^5.4.1"
,
"@ethersproject/providers"
:
"^5.4.5"
,
"ethers"
:
"^5.4.5"
,
"lodash"
:
"^4.17.21"
}
...
...
packages/core-utils/src/index.ts
View file @
85a1fead
...
...
@@ -6,3 +6,4 @@ export * from './events'
export
*
from
'
./batches
'
export
*
from
'
./bcfg
'
export
*
from
'
./fees
'
export
*
from
'
./provider
'
packages/core-utils/src/provider.ts
0 → 100644
View file @
85a1fead
/**
* Provider Utilities
*/
import
{
ethers
}
from
'
ethers
'
import
{
Provider
}
from
'
@ethersproject/providers
'
// Copied from @ethersproject/providers since it is not
// currently exported
export
interface
FallbackProviderConfig
{
// The Provider
provider
:
Provider
// The priority to favour this Provider; higher values are used first
priority
?:
number
// Timeout before also triggering the next provider; this does not stop
// this provider and if its result comes back before a quorum is reached
// it will be incorporated into the vote
// - lower values will cause more network traffic but may result in a
// faster retult.
stallTimeout
?:
number
// How much this provider contributes to the quorum; sometimes a specific
// provider may be more reliable or trustworthy than others, but usually
// this should be left as the default
weight
?:
number
}
export
const
FallbackProvider
=
(
config
:
string
|
FallbackProviderConfig
[])
=>
{
const
configs
=
[]
if
(
typeof
config
===
'
string
'
)
{
const
urls
=
config
.
split
(
'
,
'
)
for
(
const
[
i
,
url
]
of
urls
.
entries
())
{
configs
.
push
({
priority
:
i
,
provider
:
new
ethers
.
providers
.
StaticJsonRpcProvider
(
url
),
})
}
return
new
ethers
.
providers
.
FallbackProvider
(
configs
)
}
return
new
ethers
.
providers
.
FallbackProvider
(
config
)
}
packages/data-transport-layer/src/services/l1-ingestion/service.ts
View file @
85a1fead
/* Imports: External */
import
{
fromHexString
}
from
'
@eth-optimism/core-utils
'
import
{
fromHexString
,
FallbackProvider
}
from
'
@eth-optimism/core-utils
'
import
{
BaseService
,
Metrics
}
from
'
@eth-optimism/common-ts
'
import
{
StaticJsonRpcProvider
}
from
'
@ethersproject/providers
'
import
{
StaticJsonRpcProvider
,
BaseProvider
}
from
'
@ethersproject/providers
'
import
{
LevelUp
}
from
'
levelup
'
import
{
ethers
,
constants
}
from
'
ethers
'
import
{
Gauge
,
Counter
}
from
'
prom-client
'
...
...
@@ -80,7 +80,7 @@ const optionSettings = {
},
l1RpcProvider
:
{
validate
:
(
val
:
any
)
=>
{
return
validators
.
is
Url
(
val
)
||
validators
.
isJsonRpcProvider
(
val
)
return
validators
.
is
String
(
val
)
||
validators
.
isJsonRpcProvider
(
val
)
},
},
l2ChainId
:
{
...
...
@@ -98,7 +98,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
private
state
:
{
db
:
TransportDB
contracts
:
OptimismContracts
l1RpcProvider
:
StaticJsonRpc
Provider
l1RpcProvider
:
Base
Provider
startingL1BlockNumber
:
number
}
=
{}
as
any
...
...
@@ -107,10 +107,11 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
this
.
l1IngestionMetrics
=
registerMetrics
(
this
.
metrics
)
this
.
state
.
l1RpcProvider
=
typeof
this
.
options
.
l1RpcProvider
===
'
string
'
?
new
StaticJsonRpcProvider
(
this
.
options
.
l1RpcProvider
)
:
this
.
options
.
l1RpcProvider
if
(
typeof
this
.
options
.
l1RpcProvider
===
'
string
'
)
{
this
.
state
.
l1RpcProvider
=
FallbackProvider
(
this
.
options
.
l1RpcProvider
)
}
else
{
this
.
state
.
l1RpcProvider
=
this
.
options
.
l1RpcProvider
}
this
.
logger
.
info
(
'
Using AddressManager
'
,
{
addressManager
:
this
.
options
.
addressManager
,
...
...
packages/data-transport-layer/src/types/event-handler-types.ts
View file @
85a1fead
import
{
JsonRpc
Provider
}
from
'
@ethersproject/providers
'
import
{
Base
Provider
}
from
'
@ethersproject/providers
'
import
{
BigNumber
,
Event
}
from
'
ethers
'
import
{
TransportDB
}
from
'
../db/transport-db
'
...
...
@@ -15,7 +15,7 @@ export type TypedEthersEvent<T> = Event & {
export
type
GetExtraDataHandler
<
TEventArgs
,
TExtraData
>
=
(
event
?:
TypedEthersEvent
<
TEventArgs
>
,
l1RpcProvider
?:
JsonRpc
Provider
l1RpcProvider
?:
Base
Provider
)
=>
Promise
<
TExtraData
>
export
type
ParseEventHandler
<
TEventArgs
,
TExtraData
,
TParsedEvent
>
=
(
...
...
packages/data-transport-layer/src/utils/contracts.ts
View file @
85a1fead
/* Imports: External */
import
{
constants
,
Contract
,
Signer
}
from
'
ethers
'
import
{
JsonRpc
Provider
}
from
'
@ethersproject/providers
'
import
{
Base
Provider
}
from
'
@ethersproject/providers
'
import
{
getContractInterface
}
from
'
@eth-optimism/contracts
'
export
const
loadContract
=
(
name
:
string
,
address
:
string
,
provider
:
JsonRpc
Provider
provider
:
Base
Provider
):
Contract
=>
{
return
new
Contract
(
address
,
getContractInterface
(
name
)
as
any
,
provider
)
}
...
...
@@ -15,7 +15,7 @@ export const loadProxyFromManager = async (
name
:
string
,
proxy
:
string
,
Lib_AddressManager
:
Contract
,
provider
:
JsonRpc
Provider
provider
:
Base
Provider
):
Promise
<
Contract
>
=>
{
const
address
=
await
Lib_AddressManager
.
getAddress
(
proxy
)
...
...
@@ -36,7 +36,7 @@ export interface OptimismContracts {
}
export
const
loadOptimismContracts
=
async
(
l1RpcProvider
:
JsonRpc
Provider
,
l1RpcProvider
:
Base
Provider
,
addressManagerAddress
:
string
,
signer
?:
Signer
):
Promise
<
OptimismContracts
>
=>
{
...
...
yarn.lock
View file @
85a1fead
...
...
@@ -922,6 +922,31 @@
bech32 "1.1.4"
ws "7.4.6"
"@ethersproject/providers@^5.4.5":
version "5.4.5"
resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.4.5.tgz#eb2ea2a743a8115f79604a8157233a3a2c832928"
integrity sha512-1GkrvkiAw3Fj28cwi1Sqm8ED1RtERtpdXmRfwIBGmqBSN5MoeRUHuwHPppMtbPayPgpFcvD7/Gdc9doO5fGYgw==
dependencies:
"@ethersproject/abstract-provider" "^5.4.0"
"@ethersproject/abstract-signer" "^5.4.0"
"@ethersproject/address" "^5.4.0"
"@ethersproject/basex" "^5.4.0"
"@ethersproject/bignumber" "^5.4.0"
"@ethersproject/bytes" "^5.4.0"
"@ethersproject/constants" "^5.4.0"
"@ethersproject/hash" "^5.4.0"
"@ethersproject/logger" "^5.4.0"
"@ethersproject/networks" "^5.4.0"
"@ethersproject/properties" "^5.4.0"
"@ethersproject/random" "^5.4.0"
"@ethersproject/rlp" "^5.4.0"
"@ethersproject/sha2" "^5.4.0"
"@ethersproject/strings" "^5.4.0"
"@ethersproject/transactions" "^5.4.0"
"@ethersproject/web" "^5.4.0"
bech32 "1.1.4"
ws "7.4.6"
"@ethersproject/random@5.4.0", "@ethersproject/random@^5.0.0", "@ethersproject/random@^5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.4.0.tgz#9cdde60e160d024be39cc16f8de3b9ce39191e16"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment