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
64337ed5
Unverified
Commit
64337ed5
authored
Jul 28, 2022
by
Mark Tyneway
Committed by
GitHub
Jul 28, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3124 from ethereum-optimism/ci/check-op-node
core-utils,contracts-bedrock,ci: OpNodeProvider + check
parents
ae097069
0f9e7279
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
193 additions
and
3 deletions
+193
-3
eighty-kings-approve.md
.changeset/eighty-kings-approve.md
+5
-0
config.yml
.circleci/config.yml
+5
-2
hardhat.config.ts
packages/contracts-bedrock/hardhat.config.ts
+1
-0
package.json
packages/contracts-bedrock/package.json
+1
-1
check-op-node.ts
packages/contracts-bedrock/tasks/check-op-node.ts
+20
-0
package.json
packages/core-utils/package.json
+2
-0
index.ts
packages/core-utils/src/optimism/index.ts
+1
-0
op-provider.ts
packages/core-utils/src/optimism/op-provider.ts
+158
-0
No files found.
.changeset/eighty-kings-approve.md
0 → 100644
View file @
64337ed5
---
'
@eth-optimism/core-utils'
:
patch
---
Implement basic OpNodeProvider
.circleci/config.yml
View file @
64337ed5
...
...
@@ -457,9 +457,12 @@ jobs:
--amount-eth 1 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--network devnetL1
working_directory
:
packages/contracts-bedrock
/contracts-bedrock
working_directory
:
packages/contracts-bedrock
-
run
:
command
:
echo "Deposit complete."
name
:
Check the status
command
:
|
npx hardhat check-op-node
working_directory
:
packages/contracts-bedrock
integration-tests
:
machine
:
...
...
packages/contracts-bedrock/hardhat.config.ts
View file @
64337ed5
...
...
@@ -14,6 +14,7 @@ import './tasks/genesis-l2'
import
'
./tasks/deposits
'
import
'
./tasks/rekey
'
import
'
./tasks/rollup-config
'
import
'
./tasks/check-op-node
'
subtask
(
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS
).
setAction
(
async
(
_
,
__
,
runSuper
)
=>
{
...
...
packages/contracts-bedrock/package.json
View file @
64337ed5
...
...
@@ -15,7 +15,7 @@
],
"scripts"
:
{
"build:forge"
:
"forge build"
,
"build:differential"
:
"tsc scripts/differential-testing.ts --outDir dist --moduleResolution node"
,
"build:differential"
:
"tsc scripts/differential-testing.ts --outDir dist --moduleResolution node
--esModuleInterop
"
,
"prebuild"
:
"yarn ts-node scripts/verifyFoundryInstall.ts"
,
"build"
:
"hardhat compile && yarn autogen:artifacts && yarn build:ts && yarn typechain"
,
"build:ts"
:
"tsc -p tsconfig.json"
,
...
...
packages/contracts-bedrock/tasks/check-op-node.ts
0 → 100644
View file @
64337ed5
import
{
task
,
types
}
from
'
hardhat/config
'
import
{
OpNodeProvider
}
from
'
@eth-optimism/core-utils
'
// TODO(tynes): add in config validation
task
(
'
check-op-node
'
,
'
Validate the config of the op-node
'
)
.
addParam
(
'
opNodeUrl
'
,
'
URL of the OP Node.
'
,
'
http://localhost:7545
'
,
types
.
string
)
.
setAction
(
async
(
args
)
=>
{
const
provider
=
new
OpNodeProvider
(
args
.
opNodeUrl
)
const
syncStatus
=
await
provider
.
syncStatus
()
console
.
log
(
JSON
.
stringify
(
syncStatus
,
null
,
2
))
const
config
=
await
provider
.
rollupConfig
()
console
.
log
(
JSON
.
stringify
(
config
,
null
,
2
))
})
packages/core-utils/package.json
View file @
64337ed5
...
...
@@ -35,6 +35,8 @@
"@ethersproject/abstract-provider"
:
"^5.6.1"
,
"@ethersproject/providers"
:
"^5.6.8"
,
"@ethersproject/transactions"
:
"^5.6.2"
,
"@ethersproject/properties"
:
"^5.6.0"
,
"@ethersproject/web"
:
"^5.6.1"
,
"bufio"
:
"^1.0.7"
,
"chai"
:
"^4.3.4"
,
"ethers"
:
"^5.6.8"
...
...
packages/core-utils/src/optimism/index.ts
View file @
64337ed5
...
...
@@ -10,3 +10,4 @@ export * from './op-node'
export
*
from
'
./deposit-transaction
'
export
*
from
'
./encoding
'
export
*
from
'
./hashing
'
export
*
from
'
./op-provider
'
packages/core-utils/src/optimism/op-provider.ts
0 → 100644
View file @
64337ed5
import
EventEmitter
from
'
events
'
import
{
BigNumber
}
from
'
ethers
'
import
{
deepCopy
}
from
'
@ethersproject/properties
'
import
{
ConnectionInfo
,
fetchJson
}
from
'
@ethersproject/web
'
const
getResult
=
(
payload
:
{
error
?:
{
code
?:
number
;
data
?:
any
;
message
?:
string
}
result
?:
any
}):
any
=>
{
if
(
payload
.
error
)
{
const
error
:
any
=
new
Error
(
payload
.
error
.
message
)
error
.
code
=
payload
.
error
.
code
error
.
data
=
payload
.
error
.
data
throw
error
}
return
payload
.
result
}
export
interface
BlockDescriptor
{
hash
:
string
number
:
BigNumber
parentHash
:
string
timestamp
:
BigNumber
}
export
interface
L2BlockDescriptor
extends
BlockDescriptor
{
l1Origin
:
{
hash
:
string
number
:
BigNumber
}
sequencerNumber
:
BigNumber
}
export
interface
SyncStatusResponse
{
currentL1
:
BlockDescriptor
headL1
:
BlockDescriptor
unsafeL2
:
L2BlockDescriptor
safeL2
:
L2BlockDescriptor
finalizedL2
:
L2BlockDescriptor
}
export
class
OpNodeProvider
extends
EventEmitter
{
readonly
connection
:
ConnectionInfo
private
_nextId
:
number
=
0
constructor
(
url
?:
ConnectionInfo
|
string
)
{
super
()
if
(
typeof
url
===
'
string
'
)
{
this
.
connection
=
{
url
}
}
else
{
this
.
connection
=
url
}
}
async
syncStatus
():
Promise
<
SyncStatusResponse
>
{
const
result
=
await
this
.
send
(
'
optimism_syncStatus
'
,
[])
return
{
currentL1
:
{
hash
:
result
.
current_l1
.
hash
,
number
:
BigNumber
.
from
(
result
.
current_l1
.
number
),
parentHash
:
result
.
current_l1
.
parentHash
,
timestamp
:
BigNumber
.
from
(
result
.
current_l1
.
timestamp
),
},
headL1
:
{
hash
:
result
.
head_l1
.
hash
,
number
:
BigNumber
.
from
(
result
.
head_l1
.
number
),
parentHash
:
result
.
head_l1
.
parentHash
,
timestamp
:
BigNumber
.
from
(
result
.
head_l1
.
timestamp
),
},
unsafeL2
:
{
hash
:
result
.
unsafe_l2
.
hash
,
number
:
BigNumber
.
from
(
result
.
unsafe_l2
.
number
),
parentHash
:
result
.
unsafe_l2
.
parentHash
,
timestamp
:
BigNumber
.
from
(
result
.
unsafe_l2
.
timestamp
),
l1Origin
:
{
hash
:
result
.
unsafe_l2
.
l1origin
.
hash
,
number
:
BigNumber
.
from
(
result
.
unsafe_l2
.
l1origin
.
number
),
},
sequencerNumber
:
BigNumber
.
from
(
result
.
unsafe_l2
.
sequenceNumber
),
},
safeL2
:
{
hash
:
result
.
safe_l2
.
hash
,
number
:
BigNumber
.
from
(
result
.
safe_l2
.
number
),
parentHash
:
result
.
safe_l2
.
parentHash
,
timestamp
:
BigNumber
.
from
(
result
.
safe_l2
.
timestamp
),
l1Origin
:
{
hash
:
result
.
safe_l2
.
l1origin
.
hash
,
number
:
BigNumber
.
from
(
result
.
safe_l2
.
l1origin
.
number
),
},
sequencerNumber
:
BigNumber
.
from
(
result
.
safe_l2
.
sequenceNumber
),
},
finalizedL2
:
{
hash
:
result
.
finalized_l2
.
hash
,
number
:
BigNumber
.
from
(
result
.
finalized_l2
.
number
),
parentHash
:
result
.
finalized_l2
.
parentHash
,
timestamp
:
BigNumber
.
from
(
result
.
finalized_l2
.
timestamp
),
l1Origin
:
{
hash
:
result
.
finalized_l2
.
l1origin
.
hash
,
number
:
BigNumber
.
from
(
result
.
finalized_l2
.
l1origin
.
number
),
},
sequencerNumber
:
BigNumber
.
from
(
result
.
finalized_l2
.
sequenceNumber
),
},
}
}
// TODO(tynes): turn the response into a stronger type
async
rollupConfig
()
{
const
result
=
await
this
.
send
(
'
optimism_rollupConfig
'
,
[])
return
result
}
send
(
method
:
string
,
params
:
Array
<
any
>
):
Promise
<
any
>
{
const
request
=
{
method
,
params
,
id
:
this
.
_nextId
++
,
jsonrpc
:
'
2.0
'
,
}
this
.
emit
(
'
debug
'
,
{
action
:
'
request
'
,
request
:
deepCopy
(
request
),
provider
:
this
,
})
const
result
=
fetchJson
(
this
.
connection
,
JSON
.
stringify
(
request
),
getResult
).
then
(
(
res
)
=>
{
this
.
emit
(
'
debug
'
,
{
action
:
'
response
'
,
request
,
response
:
res
,
provider
:
this
,
})
return
res
},
(
error
)
=>
{
this
.
emit
(
'
debug
'
,
{
action
:
'
response
'
,
error
,
request
,
provider
:
this
,
})
throw
error
}
)
return
result
}
}
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