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
aef72764
Unverified
Commit
aef72764
authored
May 22, 2023
by
OptimismBot
Committed by
GitHub
May 22, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5738 from ethereum-optimism/refcell/challenger/outputfilter
feat(op-challenger): L2OutputOracle Filter Query.
parents
df11f76b
f23a7ea6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
0 deletions
+88
-0
oracle.go
op-challenger/challenger/oracle.go
+36
-0
oracle_test.go
op-challenger/challenger/oracle_test.go
+52
-0
No files found.
op-challenger/challenger/oracle.go
0 → 100644
View file @
aef72764
package
challenger
import
(
"errors"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
)
var
ErrMissingEvent
=
errors
.
New
(
"missing event"
)
// BuildOutputLogFilter creates a filter query for the L2OutputOracle contract.
//
// The `OutputProposed` event is encoded as:
// 0: bytes32 indexed outputRoot,
// 1: uint256 indexed l2OutputIndex,
// 2: uint256 indexed l2BlockNumber,
// 3: uint256 l1Timestamp
func
BuildOutputLogFilter
(
l2ooABI
*
abi
.
ABI
)
(
ethereum
.
FilterQuery
,
error
)
{
// Get the L2OutputOracle contract `OutputProposed` event
event
:=
l2ooABI
.
Events
[
"OutputProposed"
]
// Sanity check that the `OutputProposed` event is defined
if
event
.
ID
==
(
common
.
Hash
{})
{
return
ethereum
.
FilterQuery
{},
ErrMissingEvent
}
query
:=
ethereum
.
FilterQuery
{
Topics
:
[][]
common
.
Hash
{
{
event
.
ID
},
},
}
return
query
,
nil
}
op-challenger/challenger/oracle_test.go
0 → 100644
View file @
aef72764
package
challenger
import
(
"testing"
"github.com/stretchr/testify/require"
eth
"github.com/ethereum/go-ethereum"
abi
"github.com/ethereum/go-ethereum/accounts/abi"
common
"github.com/ethereum/go-ethereum/common"
)
// TestBuildOutputLogFilter_Succeeds tests that the Output
// Log Filter is built correctly.
func
TestBuildOutputLogFilter_Succeeds
(
t
*
testing
.
T
)
{
// Create a mock event id
event
:=
abi
.
Event
{
ID
:
[
32
]
byte
{
0x01
},
}
filterQuery
:=
eth
.
FilterQuery
{
Topics
:
[][]
common
.
Hash
{
{
event
.
ID
},
},
}
// Mock the ABI
l2ooABI
:=
abi
.
ABI
{
Events
:
map
[
string
]
abi
.
Event
{
"OutputProposed"
:
event
,
},
}
// Build the filter
query
,
err
:=
BuildOutputLogFilter
(
&
l2ooABI
)
require
.
Equal
(
t
,
filterQuery
,
query
)
require
.
NoError
(
t
,
err
)
}
// TestBuildOutputLogFilter_Fails tests that the Output
// Log Filter fails when the event definition is missing.
func
TestBuildOutputLogFilter_Fails
(
t
*
testing
.
T
)
{
// Mock the ABI
l2ooABI
:=
abi
.
ABI
{
Events
:
map
[
string
]
abi
.
Event
{},
}
// Build the filter
_
,
err
:=
BuildOutputLogFilter
(
&
l2ooABI
)
require
.
Error
(
t
,
err
)
require
.
Equal
(
t
,
ErrMissingEvent
,
err
)
}
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