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
008086f9
Unverified
Commit
008086f9
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: validate blobtx.To at serialization time (#27393)
parent
495692c9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
13 deletions
+8
-13
block_validator.go
core/block_validator.go
+0
-3
receipt_test.go
core/types/receipt_test.go
+2
-2
transaction_marshalling.go
core/types/transaction_marshalling.go
+3
-2
tx_blob.go
core/types/tx_blob.go
+3
-3
queue.go
eth/downloader/queue.go
+0
-3
No files found.
core/block_validator.go
View file @
008086f9
...
...
@@ -89,9 +89,6 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
// 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"
)
}
...
...
core/types/receipt_test.go
View file @
008086f9
...
...
@@ -130,7 +130,7 @@ var (
}),
// EIP-4844 transactions.
NewTx
(
&
BlobTx
{
To
:
&
to6
,
To
:
to6
,
Nonce
:
6
,
Value
:
uint256
.
NewInt
(
6
),
Gas
:
6
,
...
...
@@ -139,7 +139,7 @@ var (
BlobFeeCap
:
uint256
.
NewInt
(
100066
),
}),
NewTx
(
&
BlobTx
{
To
:
&
to7
,
To
:
to7
,
Nonce
:
7
,
Value
:
uint256
.
NewInt
(
7
),
Gas
:
7
,
...
...
core/types/transaction_marshalling.go
View file @
008086f9
...
...
@@ -290,9 +290,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
return
errors
.
New
(
"missing required field 'nonce' in transaction"
)
}
itx
.
Nonce
=
uint64
(
*
dec
.
Nonce
)
if
dec
.
To
!
=
nil
{
itx
.
To
=
dec
.
To
if
dec
.
To
=
=
nil
{
return
errors
.
New
(
"missing required field 'to' in transaction"
)
}
itx
.
To
=
*
dec
.
To
if
dec
.
Gas
==
nil
{
return
errors
.
New
(
"missing required field 'gas' for txdata"
)
}
...
...
core/types/tx_blob.go
View file @
008086f9
...
...
@@ -31,7 +31,7 @@ type BlobTx struct {
GasTipCap
*
uint256
.
Int
// a.k.a. maxPriorityFeePerGas
GasFeeCap
*
uint256
.
Int
// a.k.a. maxFeePerGas
Gas
uint64
To
*
common
.
Address
`rlp:"nil"`
// nil means contract creation
To
common
.
Address
Value
*
uint256
.
Int
Data
[]
byte
AccessList
AccessList
...
...
@@ -48,7 +48,7 @@ type BlobTx struct {
func
(
tx
*
BlobTx
)
copy
()
TxData
{
cpy
:=
&
BlobTx
{
Nonce
:
tx
.
Nonce
,
To
:
copyAddressPtr
(
tx
.
To
)
,
To
:
tx
.
To
,
Data
:
common
.
CopyBytes
(
tx
.
Data
),
Gas
:
tx
.
Gas
,
// These are copied below.
...
...
@@ -104,7 +104,7 @@ func (tx *BlobTx) gasTipCap() *big.Int { return tx.GasTipCap.ToBig() }
func
(
tx
*
BlobTx
)
gasPrice
()
*
big
.
Int
{
return
tx
.
GasFeeCap
.
ToBig
()
}
func
(
tx
*
BlobTx
)
value
()
*
big
.
Int
{
return
tx
.
Value
.
ToBig
()
}
func
(
tx
*
BlobTx
)
nonce
()
uint64
{
return
tx
.
Nonce
}
func
(
tx
*
BlobTx
)
to
()
*
common
.
Address
{
return
tx
.
To
}
func
(
tx
*
BlobTx
)
to
()
*
common
.
Address
{
tmp
:=
tx
.
To
;
return
&
tmp
}
func
(
tx
*
BlobTx
)
blobGas
()
uint64
{
return
params
.
BlobTxDataGasPerBlob
*
uint64
(
len
(
tx
.
BlobHashes
))
}
func
(
tx
*
BlobTx
)
blobGasFeeCap
()
*
big
.
Int
{
return
tx
.
BlobFeeCap
.
ToBig
()
}
func
(
tx
*
BlobTx
)
blobHashes
()
[]
common
.
Hash
{
return
tx
.
BlobHashes
}
...
...
eth/downloader/queue.go
View file @
008086f9
...
...
@@ -806,9 +806,6 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
// 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
}
...
...
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