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
604c7cca
Commit
604c7cca
authored
Jan 22, 2022
by
Matthew Slipper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add script to check state roots
parent
e2be492f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
hardhat.config.ts
integration-tests/hardhat.config.ts
+1
-0
check-state-roots.ts
integration-tests/tasks/check-state-roots.ts
+57
-0
utils.ts
integration-tests/test/shared/utils.ts
+9
-0
No files found.
integration-tests/hardhat.config.ts
View file @
604c7cca
...
...
@@ -4,6 +4,7 @@ import { HardhatUserConfig } from 'hardhat/types'
import
'
@nomiclabs/hardhat-ethers
'
import
'
@nomiclabs/hardhat-waffle
'
import
'
hardhat-gas-reporter
'
import
'
./tasks/check-state-roots
'
import
{
envConfig
}
from
'
./test/shared/utils
'
const
enableGasReport
=
!!
process
.
env
.
ENABLE_GAS_REPORT
...
...
integration-tests/tasks/check-state-roots.ts
0 → 100644
View file @
604c7cca
import
{
task
}
from
'
hardhat/config
'
import
{
providers
}
from
'
ethers
'
import
{
die
,
logStderr
}
from
'
../test/shared/utils
'
task
(
'
check-state-roots
'
,
'
Compares the state roots for two different replicas.
'
)
.
addPositionalParam
(
'
replicaA
'
,
'
The first replica
'
)
.
addPositionalParam
(
'
replicaB
'
,
'
The second replica
'
)
.
setAction
(
async
({
replicaA
,
replicaB
})
=>
{
const
providerA
=
new
providers
.
JsonRpcProvider
(
replicaA
)
const
providerB
=
new
providers
.
JsonRpcProvider
(
replicaB
)
let
netA
let
netB
try
{
netA
=
await
providerA
.
getNetwork
()
}
catch
(
e
)
{
console
.
error
(
`Error getting network from
${
replicaA
}
:`
)
die
(
e
)
}
try
{
netB
=
await
providerA
.
getNetwork
()
}
catch
(
e
)
{
console
.
error
(
`Error getting network from
${
replicaB
}
:`
)
die
(
e
)
}
if
(
netA
.
chainId
!==
netB
.
chainId
)
{
die
(
'
Chain IDs do not match
'
)
return
}
logStderr
(
'
Getting block height.
'
)
const
heightA
=
await
providerA
.
getBlockNumber
()
const
heightB
=
await
providerB
.
getBlockNumber
()
const
endHeight
=
Math
.
min
(
heightA
,
heightB
)
logStderr
(
`Chose block height:
${
endHeight
}
`
)
for
(
let
n
=
endHeight
;
n
>=
1
;
n
--
)
{
const
blocks
=
await
Promise
.
all
([
providerA
.
getBlock
(
n
),
providerB
.
getBlock
(
n
),
])
const
hashA
=
blocks
[
0
].
hash
const
hashB
=
blocks
[
1
].
hash
if
(
hashA
!==
hashB
)
{
console
.
log
(
`HASH MISMATCH! block=
${
n
}
a=
${
hashA
}
b=
${
hashB
}
`
)
continue
}
console
.
log
(
`HASHES OK! block=
${
n
}
hash=
${
hashA
}
`
)
return
}
})
integration-tests/test/shared/utils.ts
View file @
604c7cca
...
...
@@ -264,3 +264,12 @@ export const isHardhat = async () => {
const
chainId
=
await
l1Wallet
.
getChainId
()
return
chainId
===
HARDHAT_CHAIN_ID
}
export
const
die
=
(...
args
)
=>
{
console
.
log
(...
args
)
process
.
exit
(
1
)
}
export
const
logStderr
=
(
msg
:
string
)
=>
{
process
.
stderr
.
write
(
`
${
msg
}
\n`
)
}
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