Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
495692c9
Unverified
Commit
495692c9
authored
May 31, 2023
by
Péter Szilágyi
Committed by
GitHub
May 31, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, eth/downloader, params: validate blob tx bodies (#27392)
parent
1f9b69b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
block_validator.go
core/block_validator.go
+16
-0
queue.go
eth/downloader/queue.go
+16
-0
protocol_params.go
params/protocol_params.go
+1
-0
No files found.
core/block_validator.go
View file @
495692c9
...
...
@@ -84,7 +84,23 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
// Blob transactions may be present after the Cancun fork.
var
blobs
int
for
_
,
tx
:=
range
block
.
Transactions
()
{
// Count the number of blobs to validate against the header's dataGasUsed
blobs
+=
len
(
tx
.
BlobHashes
())
// Validate the data blobs individually too
if
tx
.
Type
()
==
types
.
BlobTxType
{
if
tx
.
To
()
==
nil
{
return
errors
.
New
(
"contract creation attempt by blob transaction"
)
// TODO(karalabe): Why not make the field non-nil-able
}
if
len
(
tx
.
BlobHashes
())
==
0
{
return
errors
.
New
(
"no-blob blob transaction present in block body"
)
}
for
_
,
hash
:=
range
tx
.
BlobHashes
()
{
if
hash
[
0
]
!=
params
.
BlobTxHashVersion
{
return
fmt
.
Errorf
(
"blob hash version mismatch (have %d, supported %d)"
,
hash
[
0
],
params
.
BlobTxHashVersion
)
}
}
}
}
if
header
.
DataGasUsed
!=
nil
{
if
want
:=
*
header
.
DataGasUsed
/
params
.
BlobTxDataGasPerBlob
;
uint64
(
blobs
)
!=
want
{
// div because the header is surely good vs the body might be bloated
...
...
eth/downloader/queue.go
View file @
495692c9
...
...
@@ -801,7 +801,23 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
// and zero before the Cancun hardfork
var
blobs
int
for
_
,
tx
:=
range
txLists
[
index
]
{
// Count the number of blobs to validate against the header's dataGasUsed
blobs
+=
len
(
tx
.
BlobHashes
())
// Validate the data blobs individually too
if
tx
.
Type
()
==
types
.
BlobTxType
{
if
tx
.
To
()
==
nil
{
return
errInvalidBody
// TODO(karalabe): Why not make the field non-nil-able
}
if
len
(
tx
.
BlobHashes
())
==
0
{
return
errInvalidBody
}
for
_
,
hash
:=
range
tx
.
BlobHashes
()
{
if
hash
[
0
]
!=
params
.
BlobTxHashVersion
{
return
errInvalidBody
}
}
}
}
if
header
.
DataGasUsed
!=
nil
{
if
want
:=
*
header
.
DataGasUsed
/
params
.
BlobTxDataGasPerBlob
;
uint64
(
blobs
)
!=
want
{
// div because the header is surely good vs the body might be bloated
...
...
params/protocol_params.go
View file @
495692c9
...
...
@@ -160,6 +160,7 @@ const (
RefundQuotient
uint64
=
2
RefundQuotientEIP3529
uint64
=
5
BlobTxHashVersion
=
0x01
// Version byte of the commitment hash
BlobTxMaxDataGasPerBlock
=
1
<<
19
// Maximum consumable data gas for data blobs per block
BlobTxTargetDataGasPerBlock
=
1
<<
18
// Target consumable data gas for data blobs per block (for 1559-like pricing)
BlobTxDataGasPerBlob
=
1
<<
17
// Gas consumption of a single data blob (== blob byte size)
...
...
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