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
a7a1775b
Unverified
Commit
a7a1775b
authored
Jan 05, 2024
by
Sebastian Stammler
Committed by
GitHub
Jan 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-service/sources: Always validate receipts when fetching them (#8861)
parent
f930a924
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
26 deletions
+17
-26
eth_client.go
op-service/sources/eth_client.go
+2
-6
eth_client_test.go
op-service/sources/eth_client_test.go
+15
-20
No files found.
op-service/sources/eth_client.go
View file @
a7a1775b
...
@@ -323,12 +323,8 @@ func (s *EthClient) FetchReceipts(ctx context.Context, blockHash common.Hash) (e
...
@@ -323,12 +323,8 @@ func (s *EthClient) FetchReceipts(ctx context.Context, blockHash common.Hash) (e
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
!
s
.
trustRPC
{
if
err
:=
validateReceipts
(
block
,
info
.
ReceiptHash
(),
txHashes
,
receipts
);
err
!=
nil
{
if
err
:=
validateReceipts
(
block
,
info
.
ReceiptHash
(),
txHashes
,
receipts
);
err
!=
nil
{
return
info
,
nil
,
fmt
.
Errorf
(
"invalid receipts: %w"
,
err
)
return
info
,
nil
,
fmt
.
Errorf
(
"invalid receipts: %w"
,
err
)
}
}
else
if
len
(
txHashes
)
!=
len
(
receipts
)
{
return
info
,
nil
,
fmt
.
Errorf
(
"unexpected number of receipts, expected: %d, got: %d"
,
len
(
txHashes
),
len
(
receipts
))
}
}
return
info
,
receipts
,
nil
return
info
,
receipts
,
nil
...
...
op-service/sources/eth_client_test.go
View file @
a7a1775b
...
@@ -192,36 +192,31 @@ func TestEthClient_validateReceipts(t *testing.T) {
...
@@ -192,36 +192,31 @@ func TestEthClient_validateReceipts(t *testing.T) {
rs
[
2
]
.
Bloom
[
0
]
=
1
rs
[
2
]
.
Bloom
[
0
]
=
1
return
rs
return
rs
}
}
mutTruncate
:=
func
(
rs
types
.
Receipts
)
types
.
Receipts
{
return
rs
[
:
len
(
rs
)
-
1
]
}
for
_
,
tt
:=
range
[]
validateReceiptsTest
{
for
_
,
tt
:=
range
[]
validateReceiptsTest
{
{
{
desc
:
"
no-trust-
valid"
,
desc
:
"valid"
,
},
},
{
{
desc
:
"
no-trust-
invalid-mut-bloom"
,
desc
:
"invalid-mut-bloom"
,
mutReceipts
:
mutBloom
,
mutReceipts
:
mutBloom
,
expError
:
"invalid receipts"
,
expError
:
"invalid receipts: failed to fetch list of receipts: expected receipt root"
,
},
{
desc
:
"trust-valid"
,
trustRPC
:
true
,
},
},
{
{
desc
:
"trust-invalid-mut-bloom"
,
desc
:
"invalid-truncated"
,
trustRPC
:
true
,
mutReceipts
:
mutTruncate
,
mutReceipts
:
mutBloom
,
// should still pass if trusting rpc
expError
:
"invalid receipts: got 3 receipts but expected 4"
,
},
{
desc
:
"trust-invalid-truncated"
,
trustRPC
:
true
,
mutReceipts
:
func
(
rs
types
.
Receipts
)
types
.
Receipts
{
// remove last receipt should invalidate even if trusting RPC
return
rs
[
:
len
(
rs
)
-
1
]
},
expError
:
"unexpected number of receipts"
,
},
},
}
{
}
{
t
.
Run
(
tt
.
desc
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"no-trust-"
+
tt
.
desc
,
func
(
t
*
testing
.
T
)
{
testEthClient_validateReceipts
(
t
,
tt
)
})
// trusting the rpc should still lead to failed validation
tt
.
trustRPC
=
true
t
.
Run
(
"trust-"
+
tt
.
desc
,
func
(
t
*
testing
.
T
)
{
testEthClient_validateReceipts
(
t
,
tt
)
testEthClient_validateReceipts
(
t
,
tt
)
})
})
}
}
...
...
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