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
57268f7e
Unverified
Commit
57268f7e
authored
Jul 27, 2023
by
Péter Szilágyi
Committed by
GitHub
Jul 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: rename dataGas to blobGas (#27789)
parent
0f4b21fe
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
224 additions
and
225 deletions
+224
-225
gen_ed.go
beacon/engine/gen_ed.go
+10
-10
types.go
beacon/engine/types.go
+8
-8
consensus.go
consensus/beacon/consensus.go
+5
-5
eip4844.go
consensus/misc/eip4844/eip4844.go
+29
-29
eip4844_test.go
consensus/misc/eip4844/eip4844_test.go
+13
-13
block_validator.go
core/block_validator.go
+4
-4
blockchain.go
core/blockchain.go
+5
-7
evm.go
core/evm.go
+1
-1
gen_genesis.go
core/gen_genesis.go
+10
-10
genesis.go
core/genesis.go
+12
-12
accessors_chain.go
core/rawdb/accessors_chain.go
+4
-6
state_processor_test.go
core/state_processor_test.go
+7
-7
state_transition.go
core/state_transition.go
+12
-12
blobpool.go
core/txpool/blobpool/blobpool.go
+7
-7
blobpool_test.go
core/txpool/blobpool/blobpool_test.go
+4
-4
validation.go
core/txpool/validation.go
+2
-2
block.go
core/types/block.go
+24
-24
gen_header_json.go
core/types/gen_header_json.go
+10
-10
gen_header_rlp.go
core/types/gen_header_rlp.go
+6
-6
gen_receipt_json.go
core/types/gen_receipt_json.go
+10
-10
receipt.go
core/types/receipt.go
+5
-5
receipt_test.go
core/types/receipt_test.go
+8
-8
transaction_marshalling.go
core/types/transaction_marshalling.go
+5
-5
tx_blob.go
core/types/tx_blob.go
+2
-2
evm.go
core/vm/evm.go
+1
-1
api.go
eth/catalyst/api.go
+1
-1
queue.go
eth/downloader/queue.go
+3
-3
odr_util.go
light/odr_util.go
+5
-5
protocol_params.go
params/protocol_params.go
+5
-5
gen_sttransaction.go
tests/gen_sttransaction.go
+2
-2
state_test.go
tests/state_test.go
+3
-0
state_test_util.go
tests/state_test_util.go
+1
-1
No files found.
beacon/engine/gen_ed.go
View file @
57268f7e
...
...
@@ -32,8 +32,8 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
BlockHash
common
.
Hash
`json:"blockHash" gencodec:"required"`
Transactions
[]
hexutil
.
Bytes
`json:"transactions" gencodec:"required"`
Withdrawals
[]
*
types
.
Withdrawal
`json:"withdrawals"`
DataGasUsed
*
hexutil
.
Uint64
`json:"data
GasUsed"`
Excess
DataGas
*
hexutil
.
Uint64
`json:"excessData
Gas"`
BlobGasUsed
*
hexutil
.
Uint64
`json:"blob
GasUsed"`
Excess
BlobGas
*
hexutil
.
Uint64
`json:"excessBlob
Gas"`
}
var
enc
ExecutableData
enc
.
ParentHash
=
e
.
ParentHash
...
...
@@ -56,8 +56,8 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
}
}
enc
.
Withdrawals
=
e
.
Withdrawals
enc
.
DataGasUsed
=
(
*
hexutil
.
Uint64
)(
e
.
Data
GasUsed
)
enc
.
Excess
DataGas
=
(
*
hexutil
.
Uint64
)(
e
.
ExcessData
Gas
)
enc
.
BlobGasUsed
=
(
*
hexutil
.
Uint64
)(
e
.
Blob
GasUsed
)
enc
.
Excess
BlobGas
=
(
*
hexutil
.
Uint64
)(
e
.
ExcessBlob
Gas
)
return
json
.
Marshal
(
&
enc
)
}
...
...
@@ -79,8 +79,8 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
BlockHash
*
common
.
Hash
`json:"blockHash" gencodec:"required"`
Transactions
[]
hexutil
.
Bytes
`json:"transactions" gencodec:"required"`
Withdrawals
[]
*
types
.
Withdrawal
`json:"withdrawals"`
DataGasUsed
*
hexutil
.
Uint64
`json:"data
GasUsed"`
Excess
DataGas
*
hexutil
.
Uint64
`json:"excessData
Gas"`
BlobGasUsed
*
hexutil
.
Uint64
`json:"blob
GasUsed"`
Excess
BlobGas
*
hexutil
.
Uint64
`json:"excessBlob
Gas"`
}
var
dec
ExecutableData
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
...
...
@@ -148,11 +148,11 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
if
dec
.
Withdrawals
!=
nil
{
e
.
Withdrawals
=
dec
.
Withdrawals
}
if
dec
.
Data
GasUsed
!=
nil
{
e
.
DataGasUsed
=
(
*
uint64
)(
dec
.
Data
GasUsed
)
if
dec
.
Blob
GasUsed
!=
nil
{
e
.
BlobGasUsed
=
(
*
uint64
)(
dec
.
Blob
GasUsed
)
}
if
dec
.
Excess
Data
Gas
!=
nil
{
e
.
Excess
DataGas
=
(
*
uint64
)(
dec
.
ExcessData
Gas
)
if
dec
.
Excess
Blob
Gas
!=
nil
{
e
.
Excess
BlobGas
=
(
*
uint64
)(
dec
.
ExcessBlob
Gas
)
}
return
nil
}
beacon/engine/types.go
View file @
57268f7e
...
...
@@ -62,8 +62,8 @@ type ExecutableData struct {
BlockHash
common
.
Hash
`json:"blockHash" gencodec:"required"`
Transactions
[][]
byte
`json:"transactions" gencodec:"required"`
Withdrawals
[]
*
types
.
Withdrawal
`json:"withdrawals"`
DataGasUsed
*
uint64
`json:"data
GasUsed"`
Excess
DataGas
*
uint64
`json:"excessData
Gas"`
BlobGasUsed
*
uint64
`json:"blob
GasUsed"`
Excess
BlobGas
*
uint64
`json:"excessBlob
Gas"`
}
// JSON type overrides for executableData.
...
...
@@ -76,8 +76,8 @@ type executableDataMarshaling struct {
ExtraData
hexutil
.
Bytes
LogsBloom
hexutil
.
Bytes
Transactions
[]
hexutil
.
Bytes
Data
GasUsed
*
hexutil
.
Uint64
Excess
Data
Gas
*
hexutil
.
Uint64
Blob
GasUsed
*
hexutil
.
Uint64
Excess
Blob
Gas
*
hexutil
.
Uint64
}
//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go
...
...
@@ -224,8 +224,8 @@ func ExecutableDataToBlock(params ExecutableData, versionedHashes []common.Hash)
Extra
:
params
.
ExtraData
,
MixDigest
:
params
.
Random
,
WithdrawalsHash
:
withdrawalsRoot
,
Excess
DataGas
:
params
.
ExcessData
Gas
,
DataGasUsed
:
params
.
Data
GasUsed
,
Excess
BlobGas
:
params
.
ExcessBlob
Gas
,
BlobGasUsed
:
params
.
Blob
GasUsed
,
}
block
:=
types
.
NewBlockWithHeader
(
header
)
.
WithBody
(
txs
,
nil
/* uncles */
)
.
WithWithdrawals
(
params
.
Withdrawals
)
if
block
.
Hash
()
!=
params
.
BlockHash
{
...
...
@@ -253,8 +253,8 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, blobs []kzg4844.Bl
Random
:
block
.
MixDigest
(),
ExtraData
:
block
.
Extra
(),
Withdrawals
:
block
.
Withdrawals
(),
DataGasUsed
:
block
.
Data
GasUsed
(),
Excess
DataGas
:
block
.
ExcessData
Gas
(),
BlobGasUsed
:
block
.
Blob
GasUsed
(),
Excess
BlobGas
:
block
.
ExcessBlob
Gas
(),
}
blobsBundle
:=
BlobsBundleV1
{
Commitments
:
make
([]
hexutil
.
Bytes
,
0
),
...
...
consensus/beacon/consensus.go
View file @
57268f7e
...
...
@@ -269,13 +269,13 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
if
!
shanghai
&&
header
.
WithdrawalsHash
!=
nil
{
return
fmt
.
Errorf
(
"invalid withdrawalsHash: have %x, expected nil"
,
header
.
WithdrawalsHash
)
}
// Verify the existence / non-existence of excess
Data
Gas
// Verify the existence / non-existence of excess
Blob
Gas
cancun
:=
chain
.
Config
()
.
IsCancun
(
header
.
Number
,
header
.
Time
)
if
!
cancun
&&
header
.
Excess
Data
Gas
!=
nil
{
return
fmt
.
Errorf
(
"invalid excess
DataGas: have %d, expected nil"
,
header
.
ExcessData
Gas
)
if
!
cancun
&&
header
.
Excess
Blob
Gas
!=
nil
{
return
fmt
.
Errorf
(
"invalid excess
BlobGas: have %d, expected nil"
,
header
.
ExcessBlob
Gas
)
}
if
!
cancun
&&
header
.
Data
GasUsed
!=
nil
{
return
fmt
.
Errorf
(
"invalid
dataGasUsed: have %d, expected nil"
,
header
.
Data
GasUsed
)
if
!
cancun
&&
header
.
Blob
GasUsed
!=
nil
{
return
fmt
.
Errorf
(
"invalid
blobGasUsed: have %d, expected nil"
,
header
.
Blob
GasUsed
)
}
if
cancun
{
if
err
:=
eip4844
.
VerifyEIP4844Header
(
parent
,
header
);
err
!=
nil
{
...
...
consensus/misc/eip4844/eip4844.go
View file @
57268f7e
...
...
@@ -26,58 +26,58 @@ import (
)
var
(
min
DataGasPrice
=
big
.
NewInt
(
params
.
BlobTxMinData
Gasprice
)
dataGaspriceUpdateFraction
=
big
.
NewInt
(
params
.
BlobTxData
GaspriceUpdateFraction
)
min
BlobGasPrice
=
big
.
NewInt
(
params
.
BlobTxMinBlob
Gasprice
)
blobGaspriceUpdateFraction
=
big
.
NewInt
(
params
.
BlobTxBlob
GaspriceUpdateFraction
)
)
// VerifyEIP4844Header verifies the presence of the excess
Data
Gas field and that
// if the current block contains no transactions, the excess
Data
Gas is updated
// VerifyEIP4844Header verifies the presence of the excess
Blob
Gas field and that
// if the current block contains no transactions, the excess
Blob
Gas is updated
// accordingly.
func
VerifyEIP4844Header
(
parent
,
header
*
types
.
Header
)
error
{
// Verify the header is not malformed
if
header
.
Excess
Data
Gas
==
nil
{
return
errors
.
New
(
"header is missing excess
Data
Gas"
)
if
header
.
Excess
Blob
Gas
==
nil
{
return
errors
.
New
(
"header is missing excess
Blob
Gas"
)
}
if
header
.
Data
GasUsed
==
nil
{
return
errors
.
New
(
"header is missing
data
GasUsed"
)
if
header
.
Blob
GasUsed
==
nil
{
return
errors
.
New
(
"header is missing
blob
GasUsed"
)
}
// Verify that the data gas used remains within reasonable limits.
if
*
header
.
DataGasUsed
>
params
.
BlobTxMaxData
GasPerBlock
{
return
fmt
.
Errorf
(
"data gas used %d exceeds maximum allowance %d"
,
*
header
.
DataGasUsed
,
params
.
BlobTxMaxData
GasPerBlock
)
if
*
header
.
BlobGasUsed
>
params
.
BlobTxMaxBlob
GasPerBlock
{
return
fmt
.
Errorf
(
"data gas used %d exceeds maximum allowance %d"
,
*
header
.
BlobGasUsed
,
params
.
BlobTxMaxBlob
GasPerBlock
)
}
if
*
header
.
DataGasUsed
%
params
.
BlobTxData
GasPerBlob
!=
0
{
return
fmt
.
Errorf
(
"data gas used %d not a multiple of data gas per blob %d"
,
header
.
DataGasUsed
,
params
.
BlobTxData
GasPerBlob
)
if
*
header
.
BlobGasUsed
%
params
.
BlobTxBlob
GasPerBlob
!=
0
{
return
fmt
.
Errorf
(
"data gas used %d not a multiple of data gas per blob %d"
,
header
.
BlobGasUsed
,
params
.
BlobTxBlob
GasPerBlob
)
}
// Verify the excess
Data
Gas is correct based on the parent header
// Verify the excess
Blob
Gas is correct based on the parent header
var
(
parentExcess
Data
Gas
uint64
parent
Data
GasUsed
uint64
parentExcess
Blob
Gas
uint64
parent
Blob
GasUsed
uint64
)
if
parent
.
Excess
Data
Gas
!=
nil
{
parentExcess
DataGas
=
*
parent
.
ExcessData
Gas
parent
DataGasUsed
=
*
parent
.
Data
GasUsed
if
parent
.
Excess
Blob
Gas
!=
nil
{
parentExcess
BlobGas
=
*
parent
.
ExcessBlob
Gas
parent
BlobGasUsed
=
*
parent
.
Blob
GasUsed
}
expectedExcess
DataGas
:=
CalcExcessDataGas
(
parentExcessDataGas
,
parentData
GasUsed
)
if
*
header
.
Excess
DataGas
!=
expectedExcessData
Gas
{
return
fmt
.
Errorf
(
"invalid excess
DataGas: have %d, want %d, parent excessData
Gas %d, parent blobDataUsed %d"
,
*
header
.
Excess
DataGas
,
expectedExcessDataGas
,
parentExcessDataGas
,
parentData
GasUsed
)
expectedExcess
BlobGas
:=
CalcExcessBlobGas
(
parentExcessBlobGas
,
parentBlob
GasUsed
)
if
*
header
.
Excess
BlobGas
!=
expectedExcessBlob
Gas
{
return
fmt
.
Errorf
(
"invalid excess
BlobGas: have %d, want %d, parent excessBlob
Gas %d, parent blobDataUsed %d"
,
*
header
.
Excess
BlobGas
,
expectedExcessBlobGas
,
parentExcessBlobGas
,
parentBlob
GasUsed
)
}
return
nil
}
// CalcExcess
Data
Gas calculates the excess data gas after applying the set of
// CalcExcess
Blob
Gas calculates the excess data gas after applying the set of
// blobs on top of the excess data gas.
func
CalcExcess
DataGas
(
parentExcessDataGas
uint64
,
parentData
GasUsed
uint64
)
uint64
{
excess
DataGas
:=
parentExcessDataGas
+
parentData
GasUsed
if
excess
DataGas
<
params
.
BlobTxTargetData
GasPerBlock
{
func
CalcExcess
BlobGas
(
parentExcessBlobGas
uint64
,
parentBlob
GasUsed
uint64
)
uint64
{
excess
BlobGas
:=
parentExcessBlobGas
+
parentBlob
GasUsed
if
excess
BlobGas
<
params
.
BlobTxTargetBlob
GasPerBlock
{
return
0
}
return
excess
DataGas
-
params
.
BlobTxTargetData
GasPerBlock
return
excess
BlobGas
-
params
.
BlobTxTargetBlob
GasPerBlock
}
// CalcBlobFee calculates the blobfee from the header's excess data gas field.
func
CalcBlobFee
(
excess
Data
Gas
uint64
)
*
big
.
Int
{
return
fakeExponential
(
min
DataGasPrice
,
new
(
big
.
Int
)
.
SetUint64
(
excessDataGas
),
data
GaspriceUpdateFraction
)
func
CalcBlobFee
(
excess
Blob
Gas
uint64
)
*
big
.
Int
{
return
fakeExponential
(
min
BlobGasPrice
,
new
(
big
.
Int
)
.
SetUint64
(
excessBlobGas
),
blob
GaspriceUpdateFraction
)
}
// fakeExponential approximates factor * e ** (numerator / denominator) using
...
...
consensus/misc/eip4844/eip4844_test.go
View file @
57268f7e
...
...
@@ -24,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/params"
)
func
TestCalcExcess
Data
Gas
(
t
*
testing
.
T
)
{
func
TestCalcExcess
Blob
Gas
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
excess
uint64
blobs
uint64
...
...
@@ -34,23 +34,23 @@ func TestCalcExcessDataGas(t *testing.T) {
// slots are below - or equal - to the target.
{
0
,
0
,
0
},
{
0
,
1
,
0
},
{
0
,
params
.
BlobTxTarget
DataGasPerBlock
/
params
.
BlobTxData
GasPerBlob
,
0
},
{
0
,
params
.
BlobTxTarget
BlobGasPerBlock
/
params
.
BlobTxBlob
GasPerBlob
,
0
},
// If the target data gas is exceeded, the excess
Data
Gas should increase
// If the target data gas is exceeded, the excess
Blob
Gas should increase
// by however much it was overshot
{
0
,
(
params
.
BlobTxTarget
DataGasPerBlock
/
params
.
BlobTxDataGasPerBlob
)
+
1
,
params
.
BlobTxData
GasPerBlob
},
{
1
,
(
params
.
BlobTxTarget
DataGasPerBlock
/
params
.
BlobTxDataGasPerBlob
)
+
1
,
params
.
BlobTxData
GasPerBlob
+
1
},
{
1
,
(
params
.
BlobTxTarget
DataGasPerBlock
/
params
.
BlobTxDataGasPerBlob
)
+
2
,
2
*
params
.
BlobTxData
GasPerBlob
+
1
},
{
0
,
(
params
.
BlobTxTarget
BlobGasPerBlock
/
params
.
BlobTxBlobGasPerBlob
)
+
1
,
params
.
BlobTxBlob
GasPerBlob
},
{
1
,
(
params
.
BlobTxTarget
BlobGasPerBlock
/
params
.
BlobTxBlobGasPerBlob
)
+
1
,
params
.
BlobTxBlob
GasPerBlob
+
1
},
{
1
,
(
params
.
BlobTxTarget
BlobGasPerBlock
/
params
.
BlobTxBlobGasPerBlob
)
+
2
,
2
*
params
.
BlobTxBlob
GasPerBlob
+
1
},
// The excess data gas should decrease by however much the target was
// under-shot, capped at zero.
{
params
.
BlobTxTarget
DataGasPerBlock
,
params
.
BlobTxTargetDataGasPerBlock
/
params
.
BlobTxDataGasPerBlob
,
params
.
BlobTxTargetData
GasPerBlock
},
{
params
.
BlobTxTarget
DataGasPerBlock
,
(
params
.
BlobTxTargetDataGasPerBlock
/
params
.
BlobTxDataGasPerBlob
)
-
1
,
params
.
BlobTxData
GasPerBlob
},
{
params
.
BlobTxTarget
DataGasPerBlock
,
(
params
.
BlobTxTargetDataGasPerBlock
/
params
.
BlobTxData
GasPerBlob
)
-
2
,
0
},
{
params
.
BlobTx
DataGasPerBlob
-
1
,
(
params
.
BlobTxTargetDataGasPerBlock
/
params
.
BlobTxData
GasPerBlob
)
-
1
,
0
},
{
params
.
BlobTxTarget
BlobGasPerBlock
,
params
.
BlobTxTargetBlobGasPerBlock
/
params
.
BlobTxBlobGasPerBlob
,
params
.
BlobTxTargetBlob
GasPerBlock
},
{
params
.
BlobTxTarget
BlobGasPerBlock
,
(
params
.
BlobTxTargetBlobGasPerBlock
/
params
.
BlobTxBlobGasPerBlob
)
-
1
,
params
.
BlobTxBlob
GasPerBlob
},
{
params
.
BlobTxTarget
BlobGasPerBlock
,
(
params
.
BlobTxTargetBlobGasPerBlock
/
params
.
BlobTxBlob
GasPerBlob
)
-
2
,
0
},
{
params
.
BlobTx
BlobGasPerBlob
-
1
,
(
params
.
BlobTxTargetBlobGasPerBlock
/
params
.
BlobTxBlob
GasPerBlob
)
-
1
,
0
},
}
for
_
,
tt
:=
range
tests
{
result
:=
CalcExcess
DataGas
(
tt
.
excess
,
tt
.
blobs
*
params
.
BlobTxData
GasPerBlob
)
result
:=
CalcExcess
BlobGas
(
tt
.
excess
,
tt
.
blobs
*
params
.
BlobTxBlob
GasPerBlob
)
if
result
!=
tt
.
want
{
t
.
Errorf
(
"excess data gas mismatch: have %v, want %v"
,
result
,
tt
.
want
)
}
...
...
@@ -59,7 +59,7 @@ func TestCalcExcessDataGas(t *testing.T) {
func
TestCalcBlobFee
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
excess
Data
Gas
uint64
excess
Blob
Gas
uint64
blobfee
int64
}{
{
0
,
1
},
...
...
@@ -68,7 +68,7 @@ func TestCalcBlobFee(t *testing.T) {
{
10
*
1024
*
1024
,
111
},
}
for
i
,
tt
:=
range
tests
{
have
:=
CalcBlobFee
(
tt
.
excess
Data
Gas
)
have
:=
CalcBlobFee
(
tt
.
excess
Blob
Gas
)
if
have
.
Int64
()
!=
tt
.
blobfee
{
t
.
Errorf
(
"test %d: blobfee mismatch: have %v want %v"
,
i
,
have
,
tt
.
blobfee
)
}
...
...
core/block_validator.go
View file @
57268f7e
...
...
@@ -84,14 +84,14 @@ 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
data
GasUsed
// Count the number of blobs to validate against the header's
blob
GasUsed
blobs
+=
len
(
tx
.
BlobHashes
())
// The individual checks for blob validity (version-check + not empty)
// happens in the state_transition check.
}
if
header
.
Data
GasUsed
!=
nil
{
if
want
:=
*
header
.
DataGasUsed
/
params
.
BlobTxData
GasPerBlob
;
uint64
(
blobs
)
!=
want
{
// div because the header is surely good vs the body might be bloated
return
fmt
.
Errorf
(
"data gas used mismatch (header %v, calculated %v)"
,
*
header
.
DataGasUsed
,
blobs
*
params
.
BlobTxData
GasPerBlob
)
if
header
.
Blob
GasUsed
!=
nil
{
if
want
:=
*
header
.
BlobGasUsed
/
params
.
BlobTxBlob
GasPerBlob
;
uint64
(
blobs
)
!=
want
{
// div because the header is surely good vs the body might be bloated
return
fmt
.
Errorf
(
"data gas used mismatch (header %v, calculated %v)"
,
*
header
.
BlobGasUsed
,
blobs
*
params
.
BlobTxBlob
GasPerBlob
)
}
}
else
{
if
blobs
>
0
{
...
...
core/blockchain.go
View file @
57268f7e
...
...
@@ -2028,17 +2028,15 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error)
// collectLogs collects the logs that were generated or removed during
// the processing of a block. These logs are later announced as deleted or reborn.
func
(
bc
*
BlockChain
)
collectLogs
(
b
*
types
.
Block
,
removed
bool
)
[]
*
types
.
Log
{
var
data
GasPrice
*
big
.
Int
excess
DataGas
:=
b
.
ExcessData
Gas
()
if
excess
Data
Gas
!=
nil
{
dataGasPrice
=
eip4844
.
CalcBlobFee
(
*
excessData
Gas
)
var
blob
GasPrice
*
big
.
Int
excess
BlobGas
:=
b
.
ExcessBlob
Gas
()
if
excess
Blob
Gas
!=
nil
{
blobGasPrice
=
eip4844
.
CalcBlobFee
(
*
excessBlob
Gas
)
}
receipts
:=
rawdb
.
ReadRawReceipts
(
bc
.
db
,
b
.
Hash
(),
b
.
NumberU64
())
if
err
:=
receipts
.
DeriveFields
(
bc
.
chainConfig
,
b
.
Hash
(),
b
.
NumberU64
(),
b
.
Time
(),
b
.
BaseFee
(),
data
GasPrice
,
b
.
Transactions
());
err
!=
nil
{
if
err
:=
receipts
.
DeriveFields
(
bc
.
chainConfig
,
b
.
Hash
(),
b
.
NumberU64
(),
b
.
Time
(),
b
.
BaseFee
(),
blob
GasPrice
,
b
.
Transactions
());
err
!=
nil
{
log
.
Error
(
"Failed to derive block receipts fields"
,
"hash"
,
b
.
Hash
(),
"number"
,
b
.
NumberU64
(),
"err"
,
err
)
}
var
logs
[]
*
types
.
Log
for
_
,
receipt
:=
range
receipts
{
for
_
,
log
:=
range
receipt
.
Logs
{
...
...
core/evm.go
View file @
57268f7e
...
...
@@ -66,7 +66,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
BaseFee
:
baseFee
,
GasLimit
:
header
.
GasLimit
,
Random
:
random
,
Excess
DataGas
:
header
.
ExcessData
Gas
,
Excess
BlobGas
:
header
.
ExcessBlob
Gas
,
}
}
...
...
core/gen_genesis.go
View file @
57268f7e
...
...
@@ -31,8 +31,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
GasUsed
math
.
HexOrDecimal64
`json:"gasUsed"`
ParentHash
common
.
Hash
`json:"parentHash"`
BaseFee
*
math
.
HexOrDecimal256
`json:"baseFeePerGas"`
Excess
DataGas
*
math
.
HexOrDecimal64
`json:"excessData
Gas"`
DataGasUsed
*
math
.
HexOrDecimal64
`json:"data
GasUsed"`
Excess
BlobGas
*
math
.
HexOrDecimal64
`json:"excessBlob
Gas"`
BlobGasUsed
*
math
.
HexOrDecimal64
`json:"blob
GasUsed"`
}
var
enc
Genesis
enc
.
Config
=
g
.
Config
...
...
@@ -53,8 +53,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
enc
.
GasUsed
=
math
.
HexOrDecimal64
(
g
.
GasUsed
)
enc
.
ParentHash
=
g
.
ParentHash
enc
.
BaseFee
=
(
*
math
.
HexOrDecimal256
)(
g
.
BaseFee
)
enc
.
Excess
DataGas
=
(
*
math
.
HexOrDecimal64
)(
g
.
ExcessData
Gas
)
enc
.
DataGasUsed
=
(
*
math
.
HexOrDecimal64
)(
g
.
Data
GasUsed
)
enc
.
Excess
BlobGas
=
(
*
math
.
HexOrDecimal64
)(
g
.
ExcessBlob
Gas
)
enc
.
BlobGasUsed
=
(
*
math
.
HexOrDecimal64
)(
g
.
Blob
GasUsed
)
return
json
.
Marshal
(
&
enc
)
}
...
...
@@ -74,8 +74,8 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
GasUsed
*
math
.
HexOrDecimal64
`json:"gasUsed"`
ParentHash
*
common
.
Hash
`json:"parentHash"`
BaseFee
*
math
.
HexOrDecimal256
`json:"baseFeePerGas"`
Excess
DataGas
*
math
.
HexOrDecimal64
`json:"excessData
Gas"`
DataGasUsed
*
math
.
HexOrDecimal64
`json:"data
GasUsed"`
Excess
BlobGas
*
math
.
HexOrDecimal64
`json:"excessBlob
Gas"`
BlobGasUsed
*
math
.
HexOrDecimal64
`json:"blob
GasUsed"`
}
var
dec
Genesis
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
...
...
@@ -126,11 +126,11 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
if
dec
.
BaseFee
!=
nil
{
g
.
BaseFee
=
(
*
big
.
Int
)(
dec
.
BaseFee
)
}
if
dec
.
Excess
Data
Gas
!=
nil
{
g
.
Excess
DataGas
=
(
*
uint64
)(
dec
.
ExcessData
Gas
)
if
dec
.
Excess
Blob
Gas
!=
nil
{
g
.
Excess
BlobGas
=
(
*
uint64
)(
dec
.
ExcessBlob
Gas
)
}
if
dec
.
Data
GasUsed
!=
nil
{
g
.
DataGasUsed
=
(
*
uint64
)(
dec
.
Data
GasUsed
)
if
dec
.
Blob
GasUsed
!=
nil
{
g
.
BlobGasUsed
=
(
*
uint64
)(
dec
.
Blob
GasUsed
)
}
return
nil
}
core/genesis.go
View file @
57268f7e
...
...
@@ -63,8 +63,8 @@ type Genesis struct {
GasUsed
uint64
`json:"gasUsed"`
ParentHash
common
.
Hash
`json:"parentHash"`
BaseFee
*
big
.
Int
`json:"baseFeePerGas"`
// EIP-1559
Excess
DataGas
*
uint64
`json:"excessData
Gas"`
// EIP-4844
DataGasUsed
*
uint64
`json:"data
GasUsed"`
// EIP-4844
Excess
BlobGas
*
uint64
`json:"excessBlob
Gas"`
// EIP-4844
BlobGasUsed
*
uint64
`json:"blob
GasUsed"`
// EIP-4844
}
func
ReadGenesis
(
db
ethdb
.
Database
)
(
*
Genesis
,
error
)
{
...
...
@@ -99,8 +99,8 @@ func ReadGenesis(db ethdb.Database) (*Genesis, error) {
genesis
.
Mixhash
=
genesisHeader
.
MixDigest
genesis
.
Coinbase
=
genesisHeader
.
Coinbase
genesis
.
BaseFee
=
genesisHeader
.
BaseFee
genesis
.
Excess
DataGas
=
genesisHeader
.
ExcessData
Gas
genesis
.
DataGasUsed
=
genesisHeader
.
Data
GasUsed
genesis
.
Excess
BlobGas
=
genesisHeader
.
ExcessBlob
Gas
genesis
.
BlobGasUsed
=
genesisHeader
.
Blob
GasUsed
return
&
genesis
,
nil
}
...
...
@@ -228,8 +228,8 @@ type genesisSpecMarshaling struct {
Difficulty
*
math
.
HexOrDecimal256
Alloc
map
[
common
.
UnprefixedAddress
]
GenesisAccount
BaseFee
*
math
.
HexOrDecimal256
Excess
Data
Gas
*
math
.
HexOrDecimal64
Data
GasUsed
*
math
.
HexOrDecimal64
Excess
Blob
Gas
*
math
.
HexOrDecimal64
Blob
GasUsed
*
math
.
HexOrDecimal64
}
type
genesisAccountMarshaling
struct
{
...
...
@@ -477,13 +477,13 @@ func (g *Genesis) ToBlock() *types.Block {
withdrawals
=
make
([]
*
types
.
Withdrawal
,
0
)
}
if
conf
.
IsCancun
(
num
,
g
.
Timestamp
)
{
head
.
Excess
DataGas
=
g
.
ExcessData
Gas
head
.
DataGasUsed
=
g
.
Data
GasUsed
if
head
.
Excess
Data
Gas
==
nil
{
head
.
Excess
Data
Gas
=
new
(
uint64
)
head
.
Excess
BlobGas
=
g
.
ExcessBlob
Gas
head
.
BlobGasUsed
=
g
.
Blob
GasUsed
if
head
.
Excess
Blob
Gas
==
nil
{
head
.
Excess
Blob
Gas
=
new
(
uint64
)
}
if
head
.
Data
GasUsed
==
nil
{
head
.
Data
GasUsed
=
new
(
uint64
)
if
head
.
Blob
GasUsed
==
nil
{
head
.
Blob
GasUsed
=
new
(
uint64
)
}
}
}
...
...
core/rawdb/accessors_chain.go
View file @
57268f7e
...
...
@@ -645,14 +645,12 @@ func ReadReceipts(db ethdb.Reader, hash common.Hash, number uint64, time uint64,
}
else
{
baseFee
=
header
.
BaseFee
}
// Compute effective data gas price.
var
data
GasPrice
*
big
.
Int
if
header
!=
nil
&&
header
.
Excess
Data
Gas
!=
nil
{
dataGasPrice
=
eip4844
.
CalcBlobFee
(
*
header
.
ExcessData
Gas
)
var
blob
GasPrice
*
big
.
Int
if
header
!=
nil
&&
header
.
Excess
Blob
Gas
!=
nil
{
blobGasPrice
=
eip4844
.
CalcBlobFee
(
*
header
.
ExcessBlob
Gas
)
}
if
err
:=
receipts
.
DeriveFields
(
config
,
hash
,
number
,
time
,
baseFee
,
dataGasPrice
,
body
.
Transactions
);
err
!=
nil
{
if
err
:=
receipts
.
DeriveFields
(
config
,
hash
,
number
,
time
,
baseFee
,
blobGasPrice
,
body
.
Transactions
);
err
!=
nil
{
log
.
Error
(
"Failed to derive block receipts fields"
,
"hash"
,
hash
,
"number"
,
number
,
"err"
,
err
)
return
nil
}
...
...
core/state_processor_test.go
View file @
57268f7e
...
...
@@ -402,14 +402,14 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
header
.
Root
=
common
.
BytesToHash
(
hasher
.
Sum
(
nil
))
if
config
.
IsCancun
(
header
.
Number
,
header
.
Time
)
{
var
pExcess
,
pUsed
=
uint64
(
0
),
uint64
(
0
)
if
parent
.
Excess
Data
Gas
()
!=
nil
{
pExcess
=
*
parent
.
Excess
Data
Gas
()
pUsed
=
*
parent
.
Data
GasUsed
()
if
parent
.
Excess
Blob
Gas
()
!=
nil
{
pExcess
=
*
parent
.
Excess
Blob
Gas
()
pUsed
=
*
parent
.
Blob
GasUsed
()
}
excess
:=
eip4844
.
CalcExcess
Data
Gas
(
pExcess
,
pUsed
)
used
:=
uint64
(
nBlobs
*
params
.
BlobTx
Data
GasPerBlob
)
header
.
Excess
Data
Gas
=
&
excess
header
.
Data
GasUsed
=
&
used
excess
:=
eip4844
.
CalcExcess
Blob
Gas
(
pExcess
,
pUsed
)
used
:=
uint64
(
nBlobs
*
params
.
BlobTx
Blob
GasPerBlob
)
header
.
Excess
Blob
Gas
=
&
excess
header
.
Blob
GasUsed
=
&
used
}
// Assemble and return the final block for sealing
if
config
.
IsShanghai
(
header
.
Number
,
header
.
Time
)
{
...
...
core/state_transition.go
View file @
57268f7e
...
...
@@ -241,18 +241,18 @@ func (st *StateTransition) buyGas() error {
balanceCheck
.
Add
(
balanceCheck
,
st
.
msg
.
Value
)
}
if
st
.
evm
.
ChainConfig
()
.
IsCancun
(
st
.
evm
.
Context
.
BlockNumber
,
st
.
evm
.
Context
.
Time
)
{
if
dataGas
:=
st
.
dataGasUsed
();
data
Gas
>
0
{
if
st
.
evm
.
Context
.
Excess
Data
Gas
==
nil
{
if
blobGas
:=
st
.
blobGasUsed
();
blob
Gas
>
0
{
if
st
.
evm
.
Context
.
Excess
Blob
Gas
==
nil
{
// programming error
panic
(
"missing field excess data gas"
)
}
// Check that the user has enough funds to cover
data
GasUsed * tx.BlobGasFeeCap
blobBalanceCheck
:=
new
(
big
.
Int
)
.
SetUint64
(
data
Gas
)
// Check that the user has enough funds to cover
blob
GasUsed * tx.BlobGasFeeCap
blobBalanceCheck
:=
new
(
big
.
Int
)
.
SetUint64
(
blob
Gas
)
blobBalanceCheck
.
Mul
(
blobBalanceCheck
,
st
.
msg
.
BlobGasFeeCap
)
balanceCheck
.
Add
(
balanceCheck
,
blobBalanceCheck
)
// Pay for
data
GasUsed * actual blob fee
blobFee
:=
new
(
big
.
Int
)
.
SetUint64
(
data
Gas
)
blobFee
.
Mul
(
blobFee
,
eip4844
.
CalcBlobFee
(
*
st
.
evm
.
Context
.
Excess
Data
Gas
))
// Pay for
blob
GasUsed * actual blob fee
blobFee
:=
new
(
big
.
Int
)
.
SetUint64
(
blob
Gas
)
blobFee
.
Mul
(
blobFee
,
eip4844
.
CalcBlobFee
(
*
st
.
evm
.
Context
.
Excess
Blob
Gas
))
mgval
.
Add
(
mgval
,
blobFee
)
}
}
...
...
@@ -331,9 +331,9 @@ func (st *StateTransition) preCheck() error {
}
if
st
.
evm
.
ChainConfig
()
.
IsCancun
(
st
.
evm
.
Context
.
BlockNumber
,
st
.
evm
.
Context
.
Time
)
{
if
st
.
data
GasUsed
()
>
0
{
if
st
.
blob
GasUsed
()
>
0
{
// Check that the user is paying at least the current blob fee
blobFee
:=
eip4844
.
CalcBlobFee
(
*
st
.
evm
.
Context
.
Excess
Data
Gas
)
blobFee
:=
eip4844
.
CalcBlobFee
(
*
st
.
evm
.
Context
.
Excess
Blob
Gas
)
if
st
.
msg
.
BlobGasFeeCap
.
Cmp
(
blobFee
)
<
0
{
return
fmt
.
Errorf
(
"%w: address %v have %v want %v"
,
ErrBlobFeeCapTooLow
,
st
.
msg
.
From
.
Hex
(),
st
.
msg
.
BlobGasFeeCap
,
blobFee
)
}
...
...
@@ -471,7 +471,7 @@ func (st *StateTransition) gasUsed() uint64 {
return
st
.
initialGas
-
st
.
gasRemaining
}
//
data
GasUsed returns the amount of data gas used by the message.
func
(
st
*
StateTransition
)
data
GasUsed
()
uint64
{
return
uint64
(
len
(
st
.
msg
.
BlobHashes
)
*
params
.
BlobTx
Data
GasPerBlob
)
//
blob
GasUsed returns the amount of data gas used by the message.
func
(
st
*
StateTransition
)
blob
GasUsed
()
uint64
{
return
uint64
(
len
(
st
.
msg
.
BlobHashes
)
*
params
.
BlobTx
Blob
GasPerBlob
)
}
core/txpool/blobpool/blobpool.go
View file @
57268f7e
...
...
@@ -53,7 +53,7 @@ const (
// maxBlobsPerTransaction is the maximum number of blobs a single transaction
// is allowed to contain. Whilst the spec states it's unlimited, the block
// data slots are protocol bound, which implicitly also limit this.
maxBlobsPerTransaction
=
params
.
BlobTxMax
DataGasPerBlock
/
params
.
BlobTxData
GasPerBlob
maxBlobsPerTransaction
=
params
.
BlobTxMax
BlobGasPerBlock
/
params
.
BlobTxBlob
GasPerBlob
// txAvgSize is an approximate byte size of a transaction metadata to avoid
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
...
...
@@ -400,10 +400,10 @@ func (p *BlobPool) Init(gasTip *big.Int, head *types.Header, reserve txpool.Addr
}
var
(
basefee
=
uint256
.
MustFromBig
(
misc
.
CalcBaseFee
(
p
.
chain
.
Config
(),
p
.
head
))
blobfee
=
uint256
.
MustFromBig
(
big
.
NewInt
(
params
.
BlobTxMin
Data
Gasprice
))
blobfee
=
uint256
.
MustFromBig
(
big
.
NewInt
(
params
.
BlobTxMin
Blob
Gasprice
))
)
if
p
.
head
.
Excess
Data
Gas
!=
nil
{
blobfee
=
uint256
.
MustFromBig
(
eip4844
.
CalcBlobFee
(
*
p
.
head
.
Excess
Data
Gas
))
if
p
.
head
.
Excess
Blob
Gas
!=
nil
{
blobfee
=
uint256
.
MustFromBig
(
eip4844
.
CalcBlobFee
(
*
p
.
head
.
Excess
Blob
Gas
))
}
p
.
evict
=
newPriceHeap
(
basefee
,
blobfee
,
&
p
.
index
)
...
...
@@ -773,10 +773,10 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) {
// Reset the price heap for the new set of basefee/blobfee pairs
var
(
basefee
=
uint256
.
MustFromBig
(
misc
.
CalcBaseFee
(
p
.
chain
.
Config
(),
newHead
))
blobfee
=
uint256
.
MustFromBig
(
big
.
NewInt
(
params
.
BlobTxMin
Data
Gasprice
))
blobfee
=
uint256
.
MustFromBig
(
big
.
NewInt
(
params
.
BlobTxMin
Blob
Gasprice
))
)
if
newHead
.
Excess
Data
Gas
!=
nil
{
blobfee
=
uint256
.
MustFromBig
(
eip4844
.
CalcBlobFee
(
*
newHead
.
Excess
Data
Gas
))
if
newHead
.
Excess
Blob
Gas
!=
nil
{
blobfee
=
uint256
.
MustFromBig
(
eip4844
.
CalcBlobFee
(
*
newHead
.
Excess
Blob
Gas
))
}
p
.
evict
.
reinit
(
basefee
,
blobfee
,
false
)
...
...
core/txpool/blobpool/blobpool_test.go
View file @
57268f7e
...
...
@@ -137,14 +137,14 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
lo
=
mid
}
}
excess
Data
Gas
:=
lo
.
Uint64
()
excess
Blob
Gas
:=
lo
.
Uint64
()
return
&
types
.
Header
{
Number
:
blockNumber
,
Time
:
blockTime
,
GasLimit
:
gasLimit
,
BaseFee
:
baseFee
,
Excess
DataGas
:
&
excessData
Gas
,
Excess
BlobGas
:
&
excessBlob
Gas
,
}
}
...
...
@@ -523,7 +523,7 @@ func TestOpenDrops(t *testing.T) {
chain
:=
&
testBlockChain
{
config
:
testChainConfig
,
basefee
:
uint256
.
NewInt
(
params
.
InitialBaseFee
),
blobfee
:
uint256
.
NewInt
(
params
.
BlobTxMin
Data
Gasprice
),
blobfee
:
uint256
.
NewInt
(
params
.
BlobTxMin
Blob
Gasprice
),
statedb
:
statedb
,
}
pool
:=
New
(
Config
{
Datadir
:
storage
},
chain
)
...
...
@@ -638,7 +638,7 @@ func TestOpenIndex(t *testing.T) {
chain
:=
&
testBlockChain
{
config
:
testChainConfig
,
basefee
:
uint256
.
NewInt
(
params
.
InitialBaseFee
),
blobfee
:
uint256
.
NewInt
(
params
.
BlobTxMin
Data
Gasprice
),
blobfee
:
uint256
.
NewInt
(
params
.
BlobTxMin
Blob
Gasprice
),
statedb
:
statedb
,
}
pool
:=
New
(
Config
{
Datadir
:
storage
},
chain
)
...
...
core/txpool/validation.go
View file @
57268f7e
...
...
@@ -116,8 +116,8 @@ func ValidateTransaction(tx *types.Transaction, blobs []kzg4844.Blob, commits []
if
len
(
hashes
)
==
0
{
return
fmt
.
Errorf
(
"blobless blob transaction"
)
}
if
len
(
hashes
)
>
params
.
BlobTxMax
DataGasPerBlock
/
params
.
BlobTxData
GasPerBlob
{
return
fmt
.
Errorf
(
"too many blobs in transaction: have %d, permitted %d"
,
len
(
hashes
),
params
.
BlobTxMax
DataGasPerBlock
/
params
.
BlobTxData
GasPerBlob
)
if
len
(
hashes
)
>
params
.
BlobTxMax
BlobGasPerBlock
/
params
.
BlobTxBlob
GasPerBlob
{
return
fmt
.
Errorf
(
"too many blobs in transaction: have %d, permitted %d"
,
len
(
hashes
),
params
.
BlobTxMax
BlobGasPerBlock
/
params
.
BlobTxBlob
GasPerBlob
)
}
if
len
(
blobs
)
!=
len
(
hashes
)
{
return
fmt
.
Errorf
(
"invalid number of %d blobs compared to %d blob hashes"
,
len
(
blobs
),
len
(
hashes
))
...
...
core/types/block.go
View file @
57268f7e
...
...
@@ -85,11 +85,11 @@ type Header struct {
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
WithdrawalsHash
*
common
.
Hash
`json:"withdrawalsRoot" rlp:"optional"`
// Excess
Data
Gas was added by EIP-4844 and is ignored in legacy headers.
Excess
DataGas
*
uint64
`json:"excessData
Gas" rlp:"optional"`
// Excess
Blob
Gas was added by EIP-4844 and is ignored in legacy headers.
Excess
BlobGas
*
uint64
`json:"excessBlob
Gas" rlp:"optional"`
//
Data
GasUsed was added by EIP-4844 and is ignored in legacy headers.
DataGasUsed
*
uint64
`json:"data
GasUsed" rlp:"optional"`
//
Blob
GasUsed was added by EIP-4844 and is ignored in legacy headers.
BlobGasUsed
*
uint64
`json:"blob
GasUsed" rlp:"optional"`
}
// field type overrides for gencodec
...
...
@@ -102,8 +102,8 @@ type headerMarshaling struct {
Extra
hexutil
.
Bytes
BaseFee
*
hexutil
.
Big
Hash
common
.
Hash
`json:"hash"`
// adds call to Hash() in MarshalJSON
Excess
Data
Gas
*
hexutil
.
Uint64
Data
GasUsed
*
hexutil
.
Uint64
Excess
Blob
Gas
*
hexutil
.
Uint64
Blob
GasUsed
*
hexutil
.
Uint64
}
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
...
...
@@ -284,13 +284,13 @@ func CopyHeader(h *Header) *Header {
cpy
.
WithdrawalsHash
=
new
(
common
.
Hash
)
*
cpy
.
WithdrawalsHash
=
*
h
.
WithdrawalsHash
}
if
h
.
Excess
Data
Gas
!=
nil
{
cpy
.
Excess
Data
Gas
=
new
(
uint64
)
*
cpy
.
Excess
DataGas
=
*
h
.
ExcessData
Gas
if
h
.
Excess
Blob
Gas
!=
nil
{
cpy
.
Excess
Blob
Gas
=
new
(
uint64
)
*
cpy
.
Excess
BlobGas
=
*
h
.
ExcessBlob
Gas
}
if
h
.
Data
GasUsed
!=
nil
{
cpy
.
Data
GasUsed
=
new
(
uint64
)
*
cpy
.
DataGasUsed
=
*
h
.
Data
GasUsed
if
h
.
Blob
GasUsed
!=
nil
{
cpy
.
Blob
GasUsed
=
new
(
uint64
)
*
cpy
.
BlobGasUsed
=
*
h
.
Blob
GasUsed
}
return
&
cpy
}
...
...
@@ -360,22 +360,22 @@ func (b *Block) Withdrawals() Withdrawals {
return
b
.
withdrawals
}
func
(
b
*
Block
)
Excess
Data
Gas
()
*
uint64
{
var
excess
Data
Gas
*
uint64
if
b
.
header
.
Excess
Data
Gas
!=
nil
{
excess
Data
Gas
=
new
(
uint64
)
*
excess
DataGas
=
*
b
.
header
.
ExcessData
Gas
func
(
b
*
Block
)
Excess
Blob
Gas
()
*
uint64
{
var
excess
Blob
Gas
*
uint64
if
b
.
header
.
Excess
Blob
Gas
!=
nil
{
excess
Blob
Gas
=
new
(
uint64
)
*
excess
BlobGas
=
*
b
.
header
.
ExcessBlob
Gas
}
return
excess
Data
Gas
return
excess
Blob
Gas
}
func
(
b
*
Block
)
Data
GasUsed
()
*
uint64
{
var
data
GasUsed
*
uint64
if
b
.
header
.
Data
GasUsed
!=
nil
{
data
GasUsed
=
new
(
uint64
)
*
dataGasUsed
=
*
b
.
header
.
Data
GasUsed
func
(
b
*
Block
)
Blob
GasUsed
()
*
uint64
{
var
blob
GasUsed
*
uint64
if
b
.
header
.
Blob
GasUsed
!=
nil
{
blob
GasUsed
=
new
(
uint64
)
*
blobGasUsed
=
*
b
.
header
.
Blob
GasUsed
}
return
data
GasUsed
return
blob
GasUsed
}
func
(
b
*
Block
)
Header
()
*
Header
{
return
CopyHeader
(
b
.
header
)
}
...
...
core/types/gen_header_json.go
View file @
57268f7e
...
...
@@ -33,8 +33,8 @@ func (h Header) MarshalJSON() ([]byte, error) {
Nonce
BlockNonce
`json:"nonce"`
BaseFee
*
hexutil
.
Big
`json:"baseFeePerGas" rlp:"optional"`
WithdrawalsHash
*
common
.
Hash
`json:"withdrawalsRoot" rlp:"optional"`
Excess
DataGas
*
hexutil
.
Uint64
`json:"excessData
Gas" rlp:"optional"`
DataGasUsed
*
hexutil
.
Uint64
`json:"data
GasUsed" rlp:"optional"`
Excess
BlobGas
*
hexutil
.
Uint64
`json:"excessBlob
Gas" rlp:"optional"`
BlobGasUsed
*
hexutil
.
Uint64
`json:"blob
GasUsed" rlp:"optional"`
Hash
common
.
Hash
`json:"hash"`
}
var
enc
Header
...
...
@@ -55,8 +55,8 @@ func (h Header) MarshalJSON() ([]byte, error) {
enc
.
Nonce
=
h
.
Nonce
enc
.
BaseFee
=
(
*
hexutil
.
Big
)(
h
.
BaseFee
)
enc
.
WithdrawalsHash
=
h
.
WithdrawalsHash
enc
.
Excess
DataGas
=
(
*
hexutil
.
Uint64
)(
h
.
ExcessData
Gas
)
enc
.
DataGasUsed
=
(
*
hexutil
.
Uint64
)(
h
.
Data
GasUsed
)
enc
.
Excess
BlobGas
=
(
*
hexutil
.
Uint64
)(
h
.
ExcessBlob
Gas
)
enc
.
BlobGasUsed
=
(
*
hexutil
.
Uint64
)(
h
.
Blob
GasUsed
)
enc
.
Hash
=
h
.
Hash
()
return
json
.
Marshal
(
&
enc
)
}
...
...
@@ -81,8 +81,8 @@ func (h *Header) UnmarshalJSON(input []byte) error {
Nonce
*
BlockNonce
`json:"nonce"`
BaseFee
*
hexutil
.
Big
`json:"baseFeePerGas" rlp:"optional"`
WithdrawalsHash
*
common
.
Hash
`json:"withdrawalsRoot" rlp:"optional"`
Excess
DataGas
*
hexutil
.
Uint64
`json:"excessData
Gas" rlp:"optional"`
DataGasUsed
*
hexutil
.
Uint64
`json:"data
GasUsed" rlp:"optional"`
Excess
BlobGas
*
hexutil
.
Uint64
`json:"excessBlob
Gas" rlp:"optional"`
BlobGasUsed
*
hexutil
.
Uint64
`json:"blob
GasUsed" rlp:"optional"`
}
var
dec
Header
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
...
...
@@ -151,11 +151,11 @@ func (h *Header) UnmarshalJSON(input []byte) error {
if
dec
.
WithdrawalsHash
!=
nil
{
h
.
WithdrawalsHash
=
dec
.
WithdrawalsHash
}
if
dec
.
Excess
Data
Gas
!=
nil
{
h
.
Excess
DataGas
=
(
*
uint64
)(
dec
.
ExcessData
Gas
)
if
dec
.
Excess
Blob
Gas
!=
nil
{
h
.
Excess
BlobGas
=
(
*
uint64
)(
dec
.
ExcessBlob
Gas
)
}
if
dec
.
Data
GasUsed
!=
nil
{
h
.
DataGasUsed
=
(
*
uint64
)(
dec
.
Data
GasUsed
)
if
dec
.
Blob
GasUsed
!=
nil
{
h
.
BlobGasUsed
=
(
*
uint64
)(
dec
.
Blob
GasUsed
)
}
return
nil
}
core/types/gen_header_rlp.go
View file @
57268f7e
...
...
@@ -42,8 +42,8 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
w
.
WriteBytes
(
obj
.
Nonce
[
:
])
_tmp1
:=
obj
.
BaseFee
!=
nil
_tmp2
:=
obj
.
WithdrawalsHash
!=
nil
_tmp3
:=
obj
.
Excess
Data
Gas
!=
nil
_tmp4
:=
obj
.
Data
GasUsed
!=
nil
_tmp3
:=
obj
.
Excess
Blob
Gas
!=
nil
_tmp4
:=
obj
.
Blob
GasUsed
!=
nil
if
_tmp1
||
_tmp2
||
_tmp3
||
_tmp4
{
if
obj
.
BaseFee
==
nil
{
w
.
Write
(
rlp
.
EmptyString
)
...
...
@@ -62,17 +62,17 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
}
}
if
_tmp3
||
_tmp4
{
if
obj
.
Excess
Data
Gas
==
nil
{
if
obj
.
Excess
Blob
Gas
==
nil
{
w
.
Write
([]
byte
{
0x80
})
}
else
{
w
.
WriteUint64
((
*
obj
.
Excess
Data
Gas
))
w
.
WriteUint64
((
*
obj
.
Excess
Blob
Gas
))
}
}
if
_tmp4
{
if
obj
.
Data
GasUsed
==
nil
{
if
obj
.
Blob
GasUsed
==
nil
{
w
.
Write
([]
byte
{
0x80
})
}
else
{
w
.
WriteUint64
((
*
obj
.
Data
GasUsed
))
w
.
WriteUint64
((
*
obj
.
Blob
GasUsed
))
}
}
w
.
ListEnd
(
_tmp0
)
...
...
core/types/gen_receipt_json.go
View file @
57268f7e
...
...
@@ -26,8 +26,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
ContractAddress
common
.
Address
`json:"contractAddress"`
GasUsed
hexutil
.
Uint64
`json:"gasUsed" gencodec:"required"`
EffectiveGasPrice
*
hexutil
.
Big
`json:"effectiveGasPrice"`
DataGasUsed
uint64
`json:"data
GasUsed,omitempty"`
DataGasPrice
*
big
.
Int
`json:"data
GasPrice,omitempty"`
BlobGasUsed
uint64
`json:"blob
GasUsed,omitempty"`
BlobGasPrice
*
big
.
Int
`json:"blob
GasPrice,omitempty"`
BlockHash
common
.
Hash
`json:"blockHash,omitempty"`
BlockNumber
*
hexutil
.
Big
`json:"blockNumber,omitempty"`
TransactionIndex
hexutil
.
Uint
`json:"transactionIndex"`
...
...
@@ -43,8 +43,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
enc
.
ContractAddress
=
r
.
ContractAddress
enc
.
GasUsed
=
hexutil
.
Uint64
(
r
.
GasUsed
)
enc
.
EffectiveGasPrice
=
(
*
hexutil
.
Big
)(
r
.
EffectiveGasPrice
)
enc
.
DataGasUsed
=
r
.
Data
GasUsed
enc
.
DataGasPrice
=
r
.
Data
GasPrice
enc
.
BlobGasUsed
=
r
.
Blob
GasUsed
enc
.
BlobGasPrice
=
r
.
Blob
GasPrice
enc
.
BlockHash
=
r
.
BlockHash
enc
.
BlockNumber
=
(
*
hexutil
.
Big
)(
r
.
BlockNumber
)
enc
.
TransactionIndex
=
hexutil
.
Uint
(
r
.
TransactionIndex
)
...
...
@@ -64,8 +64,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
ContractAddress
*
common
.
Address
`json:"contractAddress"`
GasUsed
*
hexutil
.
Uint64
`json:"gasUsed" gencodec:"required"`
EffectiveGasPrice
*
hexutil
.
Big
`json:"effectiveGasPrice"`
DataGasUsed
*
uint64
`json:"data
GasUsed,omitempty"`
DataGasPrice
*
big
.
Int
`json:"data
GasPrice,omitempty"`
BlobGasUsed
*
uint64
`json:"blob
GasUsed,omitempty"`
BlobGasPrice
*
big
.
Int
`json:"blob
GasPrice,omitempty"`
BlockHash
*
common
.
Hash
`json:"blockHash,omitempty"`
BlockNumber
*
hexutil
.
Big
`json:"blockNumber,omitempty"`
TransactionIndex
*
hexutil
.
Uint
`json:"transactionIndex"`
...
...
@@ -109,11 +109,11 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
if
dec
.
EffectiveGasPrice
!=
nil
{
r
.
EffectiveGasPrice
=
(
*
big
.
Int
)(
dec
.
EffectiveGasPrice
)
}
if
dec
.
Data
GasUsed
!=
nil
{
r
.
DataGasUsed
=
*
dec
.
Data
GasUsed
if
dec
.
Blob
GasUsed
!=
nil
{
r
.
BlobGasUsed
=
*
dec
.
Blob
GasUsed
}
if
dec
.
Data
GasPrice
!=
nil
{
r
.
DataGasPrice
=
dec
.
Data
GasPrice
if
dec
.
Blob
GasPrice
!=
nil
{
r
.
BlobGasPrice
=
dec
.
Blob
GasPrice
}
if
dec
.
BlockHash
!=
nil
{
r
.
BlockHash
=
*
dec
.
BlockHash
...
...
core/types/receipt.go
View file @
57268f7e
...
...
@@ -63,8 +63,8 @@ type Receipt struct {
ContractAddress
common
.
Address
`json:"contractAddress"`
GasUsed
uint64
`json:"gasUsed" gencodec:"required"`
EffectiveGasPrice
*
big
.
Int
`json:"effectiveGasPrice"`
// required, but tag omitted for backwards compatibility
DataGasUsed
uint64
`json:"data
GasUsed,omitempty"`
DataGasPrice
*
big
.
Int
`json:"data
GasPrice,omitempty"`
BlobGasUsed
uint64
`json:"blob
GasUsed,omitempty"`
BlobGasPrice
*
big
.
Int
`json:"blob
GasPrice,omitempty"`
// Inclusion information: These fields provide information about the inclusion of the
// transaction corresponding to this receipt.
...
...
@@ -315,7 +315,7 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) {
// DeriveFields fills the receipts with their computed fields based on consensus
// data and contextual infos like containing block and transactions.
func
(
rs
Receipts
)
DeriveFields
(
config
*
params
.
ChainConfig
,
hash
common
.
Hash
,
number
uint64
,
time
uint64
,
baseFee
*
big
.
Int
,
data
GasPrice
*
big
.
Int
,
txs
[]
*
Transaction
)
error
{
func
(
rs
Receipts
)
DeriveFields
(
config
*
params
.
ChainConfig
,
hash
common
.
Hash
,
number
uint64
,
time
uint64
,
baseFee
*
big
.
Int
,
blob
GasPrice
*
big
.
Int
,
txs
[]
*
Transaction
)
error
{
signer
:=
MakeSigner
(
config
,
new
(
big
.
Int
)
.
SetUint64
(
number
),
time
)
logIndex
:=
uint
(
0
)
...
...
@@ -330,8 +330,8 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
// EIP-4844 blob transaction fields
if
txs
[
i
]
.
Type
()
==
BlobTxType
{
rs
[
i
]
.
Data
GasUsed
=
txs
[
i
]
.
BlobGas
()
rs
[
i
]
.
DataGasPrice
=
data
GasPrice
rs
[
i
]
.
Blob
GasUsed
=
txs
[
i
]
.
BlobGas
()
rs
[
i
]
.
BlobGasPrice
=
blob
GasPrice
}
// block location fields
...
...
core/types/receipt_test.go
View file @
57268f7e
...
...
@@ -272,8 +272,8 @@ var (
TxHash
:
txs
[
5
]
.
Hash
(),
GasUsed
:
6
,
EffectiveGasPrice
:
big
.
NewInt
(
1066
),
DataGasUsed
:
params
.
BlobTxData
GasPerBlob
,
Data
GasPrice
:
big
.
NewInt
(
920
),
BlobGasUsed
:
params
.
BlobTxBlob
GasPerBlob
,
Blob
GasPrice
:
big
.
NewInt
(
920
),
BlockHash
:
blockHash
,
BlockNumber
:
blockNumber
,
TransactionIndex
:
5
,
...
...
@@ -287,8 +287,8 @@ var (
TxHash
:
txs
[
6
]
.
Hash
(),
GasUsed
:
7
,
EffectiveGasPrice
:
big
.
NewInt
(
1077
),
DataGasUsed
:
3
*
params
.
BlobTxData
GasPerBlob
,
Data
GasPrice
:
big
.
NewInt
(
920
),
BlobGasUsed
:
3
*
params
.
BlobTxBlob
GasPerBlob
,
Blob
GasPrice
:
big
.
NewInt
(
920
),
BlockHash
:
blockHash
,
BlockNumber
:
blockNumber
,
TransactionIndex
:
6
,
...
...
@@ -309,9 +309,9 @@ func TestDecodeEmptyTypedReceipt(t *testing.T) {
func
TestDeriveFields
(
t
*
testing
.
T
)
{
// Re-derive receipts.
basefee
:=
big
.
NewInt
(
1000
)
data
GasPrice
:=
big
.
NewInt
(
920
)
blob
GasPrice
:=
big
.
NewInt
(
920
)
derivedReceipts
:=
clearComputedFieldsOnReceipts
(
receipts
)
err
:=
Receipts
(
derivedReceipts
)
.
DeriveFields
(
params
.
TestChainConfig
,
blockHash
,
blockNumber
.
Uint64
(),
blockTime
,
basefee
,
data
GasPrice
,
txs
)
err
:=
Receipts
(
derivedReceipts
)
.
DeriveFields
(
params
.
TestChainConfig
,
blockHash
,
blockNumber
.
Uint64
(),
blockTime
,
basefee
,
blob
GasPrice
,
txs
)
if
err
!=
nil
{
t
.
Fatalf
(
"DeriveFields(...) = %v, want <nil>"
,
err
)
}
...
...
@@ -509,8 +509,8 @@ func clearComputedFieldsOnReceipt(receipt *Receipt) *Receipt {
cpy
.
GasUsed
=
0xffffffff
cpy
.
Logs
=
clearComputedFieldsOnLogs
(
receipt
.
Logs
)
cpy
.
EffectiveGasPrice
=
big
.
NewInt
(
0
)
cpy
.
Data
GasUsed
=
0
cpy
.
Data
GasPrice
=
nil
cpy
.
Blob
GasUsed
=
0
cpy
.
Blob
GasPrice
=
nil
return
&
cpy
}
...
...
core/types/transaction_marshalling.go
View file @
57268f7e
...
...
@@ -37,7 +37,7 @@ type txJSON struct {
GasPrice
*
hexutil
.
Big
`json:"gasPrice"`
MaxPriorityFeePerGas
*
hexutil
.
Big
`json:"maxPriorityFeePerGas"`
MaxFeePerGas
*
hexutil
.
Big
`json:"maxFeePerGas"`
MaxFeePer
DataGas
*
hexutil
.
Big
`json:"maxFeePerData
Gas,omitempty"`
MaxFeePer
BlobGas
*
hexutil
.
Big
`json:"maxFeePerBlob
Gas,omitempty"`
Value
*
hexutil
.
Big
`json:"value"`
Input
*
hexutil
.
Bytes
`json:"input"`
AccessList
*
AccessList
`json:"accessList,omitempty"`
...
...
@@ -106,7 +106,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
enc
.
Gas
=
(
*
hexutil
.
Uint64
)(
&
itx
.
Gas
)
enc
.
MaxFeePerGas
=
(
*
hexutil
.
Big
)(
itx
.
GasFeeCap
.
ToBig
())
enc
.
MaxPriorityFeePerGas
=
(
*
hexutil
.
Big
)(
itx
.
GasTipCap
.
ToBig
())
enc
.
MaxFeePer
Data
Gas
=
(
*
hexutil
.
Big
)(
itx
.
BlobFeeCap
.
ToBig
())
enc
.
MaxFeePer
Blob
Gas
=
(
*
hexutil
.
Big
)(
itx
.
BlobFeeCap
.
ToBig
())
enc
.
Value
=
(
*
hexutil
.
Big
)(
itx
.
Value
.
ToBig
())
enc
.
Input
=
(
*
hexutil
.
Bytes
)(
&
itx
.
Data
)
enc
.
AccessList
=
&
itx
.
AccessList
...
...
@@ -309,10 +309,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
return
errors
.
New
(
"missing required field 'maxFeePerGas' for txdata"
)
}
itx
.
GasFeeCap
=
uint256
.
MustFromBig
((
*
big
.
Int
)(
dec
.
MaxFeePerGas
))
if
dec
.
MaxFeePer
Data
Gas
==
nil
{
return
errors
.
New
(
"missing required field 'maxFeePer
Data
Gas' for txdata"
)
if
dec
.
MaxFeePer
Blob
Gas
==
nil
{
return
errors
.
New
(
"missing required field 'maxFeePer
Blob
Gas' for txdata"
)
}
itx
.
BlobFeeCap
=
uint256
.
MustFromBig
((
*
big
.
Int
)(
dec
.
MaxFeePer
Data
Gas
))
itx
.
BlobFeeCap
=
uint256
.
MustFromBig
((
*
big
.
Int
)(
dec
.
MaxFeePer
Blob
Gas
))
if
dec
.
Value
==
nil
{
return
errors
.
New
(
"missing required field 'value' in transaction"
)
}
...
...
core/types/tx_blob.go
View file @
57268f7e
...
...
@@ -35,7 +35,7 @@ type BlobTx struct {
Value
*
uint256
.
Int
Data
[]
byte
AccessList
AccessList
BlobFeeCap
*
uint256
.
Int
// a.k.a. maxFeePer
Data
Gas
BlobFeeCap
*
uint256
.
Int
// a.k.a. maxFeePer
Blob
Gas
BlobHashes
[]
common
.
Hash
// Signature values
...
...
@@ -105,7 +105,7 @@ 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
{
tmp
:=
tx
.
To
;
return
&
tmp
}
func
(
tx
*
BlobTx
)
blobGas
()
uint64
{
return
params
.
BlobTx
Data
GasPerBlob
*
uint64
(
len
(
tx
.
BlobHashes
))
}
func
(
tx
*
BlobTx
)
blobGas
()
uint64
{
return
params
.
BlobTx
Blob
GasPerBlob
*
uint64
(
len
(
tx
.
BlobHashes
))
}
func
(
tx
*
BlobTx
)
blobGasFeeCap
()
*
big
.
Int
{
return
tx
.
BlobFeeCap
.
ToBig
()
}
func
(
tx
*
BlobTx
)
blobHashes
()
[]
common
.
Hash
{
return
tx
.
BlobHashes
}
...
...
core/vm/evm.go
View file @
57268f7e
...
...
@@ -74,7 +74,7 @@ type BlockContext struct {
Difficulty
*
big
.
Int
// Provides information for DIFFICULTY
BaseFee
*
big
.
Int
// Provides information for BASEFEE
Random
*
common
.
Hash
// Provides information for PREVRANDAO
Excess
DataGas
*
uint64
// ExcessData
Gas field in the header, needed to compute the data
Excess
BlobGas
*
uint64
// ExcessBlob
Gas field in the header, needed to compute the data
}
// TxContext provides the EVM with information about a transaction.
...
...
eth/catalyst/api.go
View file @
57268f7e
...
...
@@ -450,7 +450,7 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
return
engine
.
PayloadStatusV1
{
Status
:
engine
.
INVALID
},
engine
.
InvalidParams
.
With
(
errors
.
New
(
"newPayloadV3 called pre-cancun"
))
}
if
params
.
Excess
Data
Gas
==
nil
{
if
params
.
Excess
Blob
Gas
==
nil
{
return
engine
.
PayloadStatusV1
{
Status
:
engine
.
INVALID
},
engine
.
InvalidParams
.
With
(
fmt
.
Errorf
(
"nil excessDataGas post-cancun"
))
}
var
hashes
[]
common
.
Hash
...
...
eth/downloader/queue.go
View file @
57268f7e
...
...
@@ -801,7 +801,7 @@ 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
data
GasUsed
// Count the number of blobs to validate against the header's
blob
GasUsed
blobs
+=
len
(
tx
.
BlobHashes
())
// Validate the data blobs individually too
...
...
@@ -816,8 +816,8 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
}
}
}
if
header
.
Data
GasUsed
!=
nil
{
if
want
:=
*
header
.
DataGasUsed
/
params
.
BlobTxData
GasPerBlob
;
uint64
(
blobs
)
!=
want
{
// div because the header is surely good vs the body might be bloated
if
header
.
Blob
GasUsed
!=
nil
{
if
want
:=
*
header
.
BlobGasUsed
/
params
.
BlobTxBlob
GasPerBlob
;
uint64
(
blobs
)
!=
want
{
// div because the header is surely good vs the body might be bloated
return
errInvalidBody
}
}
else
{
...
...
light/odr_util.go
View file @
57268f7e
...
...
@@ -176,13 +176,13 @@ func GetBlockReceipts(ctx context.Context, odr OdrBackend, hash common.Hash, num
genesis
:=
rawdb
.
ReadCanonicalHash
(
odr
.
Database
(),
0
)
config
:=
rawdb
.
ReadChainConfig
(
odr
.
Database
(),
genesis
)
var
data
GasPrice
*
big
.
Int
excess
DataGas
:=
block
.
ExcessData
Gas
()
if
excess
Data
Gas
!=
nil
{
dataGasPrice
=
eip4844
.
CalcBlobFee
(
*
excessData
Gas
)
var
blob
GasPrice
*
big
.
Int
excess
BlobGas
:=
block
.
ExcessBlob
Gas
()
if
excess
Blob
Gas
!=
nil
{
blobGasPrice
=
eip4844
.
CalcBlobFee
(
*
excessBlob
Gas
)
}
if
err
:=
receipts
.
DeriveFields
(
config
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Time
(),
block
.
BaseFee
(),
data
GasPrice
,
block
.
Transactions
());
err
!=
nil
{
if
err
:=
receipts
.
DeriveFields
(
config
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Time
(),
block
.
BaseFee
(),
blob
GasPrice
,
block
.
Transactions
());
err
!=
nil
{
return
nil
,
err
}
rawdb
.
WriteReceipts
(
odr
.
Database
(),
hash
,
number
,
receipts
)
...
...
params/protocol_params.go
View file @
57268f7e
...
...
@@ -163,11 +163,11 @@ const (
BlobTxBytesPerFieldElement
=
32
// Size in bytes of a field element
BlobTxFieldElementsPerBlob
=
4096
// Number of field elements stored in a single data blob
BlobTxHashVersion
=
0x01
// Version byte of the commitment hash
BlobTxMax
Data
GasPerBlock
=
1
<<
19
// Maximum consumable data gas for data blobs per block
BlobTxTarget
Data
GasPerBlock
=
1
<<
18
// Target consumable data gas for data blobs per block (for 1559-like pricing)
BlobTx
Data
GasPerBlob
=
1
<<
17
// Gas consumption of a single data blob (== blob byte size)
BlobTxMin
Data
Gasprice
=
1
// Minimum gas price for data blobs
BlobTx
Data
GaspriceUpdateFraction
=
2225652
// Controls the maximum rate of change for data gas price
BlobTxMax
Blob
GasPerBlock
=
1
<<
19
// Maximum consumable data gas for data blobs per block
BlobTxTarget
Blob
GasPerBlock
=
1
<<
18
// Target consumable data gas for data blobs per block (for 1559-like pricing)
BlobTx
Blob
GasPerBlob
=
1
<<
17
// Gas consumption of a single data blob (== blob byte size)
BlobTxMin
Blob
Gasprice
=
1
// Minimum gas price for data blobs
BlobTx
Blob
GaspriceUpdateFraction
=
2225652
// Controls the maximum rate of change for data gas price
BlobTxPointEvaluationPrecompileGas
=
50000
// Gas price for the point evaluation precompile.
)
...
...
tests/gen_sttransaction.go
View file @
57268f7e
...
...
@@ -28,7 +28,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) {
Value
[]
string
`json:"value"`
PrivateKey
hexutil
.
Bytes
`json:"secretKey"`
BlobVersionedHashes
[]
common
.
Hash
`json:"blobVersionedHashes,omitempty"`
BlobGasFeeCap
*
math
.
HexOrDecimal256
`json:"maxFeePer
Data
Gas,omitempty"`
BlobGasFeeCap
*
math
.
HexOrDecimal256
`json:"maxFeePer
Blob
Gas,omitempty"`
}
var
enc
stTransaction
enc
.
GasPrice
=
(
*
math
.
HexOrDecimal256
)(
s
.
GasPrice
)
...
...
@@ -65,7 +65,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error {
Value
[]
string
`json:"value"`
PrivateKey
*
hexutil
.
Bytes
`json:"secretKey"`
BlobVersionedHashes
[]
common
.
Hash
`json:"blobVersionedHashes,omitempty"`
BlobGasFeeCap
*
math
.
HexOrDecimal256
`json:"maxFeePer
Data
Gas,omitempty"`
BlobGasFeeCap
*
math
.
HexOrDecimal256
`json:"maxFeePer
Blob
Gas,omitempty"`
}
var
dec
stTransaction
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
...
...
tests/state_test.go
View file @
57268f7e
...
...
@@ -58,6 +58,9 @@ func TestState(t *testing.T) {
// EOF is not part of cancun
st
.
skipLoad
(
`^stEOF/`
)
// EIP-4844 tests need to be regenerated due to the data-to-blob rename
st
.
skipLoad
(
`^stEIP4844-blobtransactions/`
)
// Expected failures:
// These EIP-4844 tests need to be regenerated.
st
.
fails
(
`stEIP4844-blobtransactions/opcodeBlobhashOutOfRange.json`
,
"test has incorrect state root"
)
...
...
tests/state_test_util.go
View file @
57268f7e
...
...
@@ -114,7 +114,7 @@ type stTransaction struct {
Value
[]
string
`json:"value"`
PrivateKey
[]
byte
`json:"secretKey"`
BlobVersionedHashes
[]
common
.
Hash
`json:"blobVersionedHashes,omitempty"`
BlobGasFeeCap
*
big
.
Int
`json:"maxFeePer
Data
Gas,omitempty"`
BlobGasFeeCap
*
big
.
Int
`json:"maxFeePer
Blob
Gas,omitempty"`
}
type
stTransactionMarshaling
struct
{
...
...
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