mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
Update getBlobsV2 and getPayloadV5
This commit is contained in:
parent
c4be2bbd19
commit
df2a3c8782
4 changed files with 68 additions and 37 deletions
|
|
@ -112,17 +112,21 @@ type ExecutionPayloadEnvelope struct {
|
||||||
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't necessarily have to change to V2 (since it has the same fields as V1) in this PoC implementation.
|
||||||
type BlobsBundleV1 struct {
|
type BlobsBundleV1 struct {
|
||||||
Commitments []hexutil.Bytes `json:"commitments"`
|
Commitments []hexutil.Bytes `json:"commitments"`
|
||||||
Proofs []hexutil.Bytes `json:"proofs"`
|
Proofs []hexutil.Bytes `json:"proofs"`
|
||||||
Blobs []hexutil.Bytes `json:"blobs"`
|
Blobs []hexutil.Bytes `json:"blobs"`
|
||||||
CellProofs []hexutil.Bytes `json:"cellProofs"` // Added in Osaka for 7594
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlobAndProofV1 struct {
|
type BlobAndProofV1 struct {
|
||||||
Blob hexutil.Bytes `json:"blob"`
|
Blob hexutil.Bytes `json:"blob"`
|
||||||
Proof hexutil.Bytes `json:"proof"`
|
Proof hexutil.Bytes `json:"proof"`
|
||||||
CellProofs []hexutil.Bytes `json:"cellProofs"` // Added in Osaka for 7594
|
}
|
||||||
|
|
||||||
|
type BlobAndProofV2 struct {
|
||||||
|
Blob hexutil.Bytes `json:"blob"`
|
||||||
|
Proofs []hexutil.Bytes `json:"proofs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON type overrides for ExecutionPayloadEnvelope.
|
// JSON type overrides for ExecutionPayloadEnvelope.
|
||||||
|
|
@ -328,7 +332,6 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
|
||||||
Commitments: make([]hexutil.Bytes, 0),
|
Commitments: make([]hexutil.Bytes, 0),
|
||||||
Blobs: make([]hexutil.Bytes, 0),
|
Blobs: make([]hexutil.Bytes, 0),
|
||||||
Proofs: make([]hexutil.Bytes, 0),
|
Proofs: make([]hexutil.Bytes, 0),
|
||||||
CellProofs: make([]hexutil.Bytes, 0),
|
|
||||||
}
|
}
|
||||||
for _, sidecar := range sidecars {
|
for _, sidecar := range sidecars {
|
||||||
for j := range sidecar.Blobs {
|
for j := range sidecar.Blobs {
|
||||||
|
|
|
||||||
|
|
@ -106,23 +106,30 @@ type blobTxMeta struct {
|
||||||
evictionExecTip *uint256.Int // Worst gas tip across all previous nonces
|
evictionExecTip *uint256.Int // Worst gas tip across all previous nonces
|
||||||
evictionExecFeeJumps float64 // Worst base fee (converted to fee jumps) across all previous nonces
|
evictionExecFeeJumps float64 // Worst base fee (converted to fee jumps) across all previous nonces
|
||||||
evictionBlobFeeJumps float64 // Worse blob fee (converted to fee jumps) across all previous nonces
|
evictionBlobFeeJumps float64 // Worse blob fee (converted to fee jumps) across all previous nonces
|
||||||
|
|
||||||
|
proofVersion uint64 // Version of the proof to use for this transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
// newBlobTxMeta retrieves the indexed metadata fields from a blob transaction
|
// newBlobTxMeta retrieves the indexed metadata fields from a blob transaction
|
||||||
// and assembles a helper struct to track in memory.
|
// and assembles a helper struct to track in memory.
|
||||||
func newBlobTxMeta(id uint64, size uint32, tx *types.Transaction) *blobTxMeta {
|
func newBlobTxMeta(id uint64, size uint32, tx *types.Transaction) *blobTxMeta {
|
||||||
|
proofVersion := uint64(0)
|
||||||
|
if len(tx.BlobTxSidecar().Blobs) != len(tx.BlobTxSidecar().Proofs) {
|
||||||
|
proofVersion = 1 // cell proofs
|
||||||
|
}
|
||||||
meta := &blobTxMeta{
|
meta := &blobTxMeta{
|
||||||
hash: tx.Hash(),
|
hash: tx.Hash(),
|
||||||
vhashes: tx.BlobHashes(),
|
vhashes: tx.BlobHashes(),
|
||||||
id: id,
|
id: id,
|
||||||
size: size,
|
size: size,
|
||||||
nonce: tx.Nonce(),
|
nonce: tx.Nonce(),
|
||||||
costCap: uint256.MustFromBig(tx.Cost()),
|
costCap: uint256.MustFromBig(tx.Cost()),
|
||||||
execTipCap: uint256.MustFromBig(tx.GasTipCap()),
|
execTipCap: uint256.MustFromBig(tx.GasTipCap()),
|
||||||
execFeeCap: uint256.MustFromBig(tx.GasFeeCap()),
|
execFeeCap: uint256.MustFromBig(tx.GasFeeCap()),
|
||||||
blobFeeCap: uint256.MustFromBig(tx.BlobGasFeeCap()),
|
blobFeeCap: uint256.MustFromBig(tx.BlobGasFeeCap()),
|
||||||
execGas: tx.Gas(),
|
execGas: tx.Gas(),
|
||||||
blobGas: tx.BlobGas(),
|
blobGas: tx.BlobGas(),
|
||||||
|
proofVersion: proofVersion,
|
||||||
}
|
}
|
||||||
meta.basefeeJumps = dynamicFeeJumps(meta.execFeeCap)
|
meta.basefeeJumps = dynamicFeeJumps(meta.execFeeCap)
|
||||||
meta.blobfeeJumps = dynamicFeeJumps(meta.blobFeeCap)
|
meta.blobfeeJumps = dynamicFeeJumps(meta.blobFeeCap)
|
||||||
|
|
@ -1639,6 +1646,11 @@ func (p *BlobPool) Pending(filter txpool.PendingFilter) map[common.Address][]*tx
|
||||||
break // blobfee too low, cannot be included, discard rest of txs from the account
|
break // blobfee too low, cannot be included, discard rest of txs from the account
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if filter.OnlyBlobTxWithCellProofs && tx.proofVersion == 0 {
|
||||||
|
continue // not a blob tx with cell proofs, skip
|
||||||
|
}
|
||||||
|
|
||||||
// Transaction was accepted according to the filter, append to the pending list
|
// Transaction was accepted according to the filter, append to the pending list
|
||||||
lazies = append(lazies, &txpool.LazyTransaction{
|
lazies = append(lazies, &txpool.LazyTransaction{
|
||||||
Pool: p,
|
Pool: p,
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,9 @@ type PendingFilter struct {
|
||||||
BaseFee *uint256.Int // Minimum 1559 basefee needed to include a transaction
|
BaseFee *uint256.Int // Minimum 1559 basefee needed to include a transaction
|
||||||
BlobFee *uint256.Int // Minimum 4844 blobfee needed to include a blob transaction
|
BlobFee *uint256.Int // Minimum 4844 blobfee needed to include a blob transaction
|
||||||
|
|
||||||
OnlyPlainTxs bool // Return only plain EVM transactions (peer-join announces, block space filling)
|
OnlyPlainTxs bool // Return only plain EVM transactions (peer-join announces, block space filling)
|
||||||
OnlyBlobTxs bool // Return only blob transactions (block blob-space filling)
|
OnlyBlobTxs bool // Return only blob transactions (block blob-space filling)
|
||||||
|
OnlyBlobTxWithCellProofs bool // Return only blob transactions with cell proofs
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubPool represents a specialized transaction pool that lives on its own (e.g.
|
// SubPool represents a specialized transaction pool that lives on its own (e.g.
|
||||||
|
|
|
||||||
|
|
@ -521,6 +521,14 @@ func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.Execu
|
||||||
return api.getPayload(payloadID, false)
|
return api.getPayload(payloadID, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPayloadV5 returns a cached payload by id.
|
||||||
|
func (api *ConsensusAPI) GetPayloadV5(payloadID engine.PayloadID) (*engine.ExecutionPayloadEnvelope, error) {
|
||||||
|
if !payloadID.Is(engine.PayloadV3) {
|
||||||
|
return nil, engine.UnsupportedFork
|
||||||
|
}
|
||||||
|
return api.getPayload(payloadID, false)
|
||||||
|
}
|
||||||
|
|
||||||
func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID, full bool) (*engine.ExecutionPayloadEnvelope, error) {
|
func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID, full bool) (*engine.ExecutionPayloadEnvelope, error) {
|
||||||
log.Trace("Engine API request received", "method", "GetPayload", "id", payloadID)
|
log.Trace("Engine API request received", "method", "GetPayload", "id", payloadID)
|
||||||
data := api.localBlocks.get(payloadID, full)
|
data := api.localBlocks.get(payloadID, full)
|
||||||
|
|
@ -538,27 +546,34 @@ func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProo
|
||||||
res := make([]*engine.BlobAndProofV1, len(hashes))
|
res := make([]*engine.BlobAndProofV1, len(hashes))
|
||||||
|
|
||||||
blobs, proofs := api.eth.TxPool().GetBlobs(hashes)
|
blobs, proofs := api.eth.TxPool().GetBlobs(hashes)
|
||||||
// after Osaka, the proofs are returned as cell proofs.
|
for i := 0; i < len(blobs); i++ {
|
||||||
if len(blobs) != len(proofs) {
|
if blobs[i] != nil {
|
||||||
for i := range blobs {
|
res[i] = &engine.BlobAndProofV1{
|
||||||
if blobs[i] != nil {
|
Blob: (*blobs[i])[:],
|
||||||
cellProofs := make([]hexutil.Bytes, gokzg4844.CellsPerExtBlob)
|
Proof: (*proofs[i])[:],
|
||||||
for j := range cellProofs {
|
|
||||||
cellProofs[j] = hexutil.Bytes((*proofs[i*gokzg4844.CellsPerExtBlob+j])[:])
|
|
||||||
}
|
|
||||||
res[i] = &engine.BlobAndProofV1{
|
|
||||||
Blob: (*blobs[i])[:],
|
|
||||||
CellProofs: cellProofs,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for i := 0; i < len(blobs); i++ {
|
|
||||||
if blobs[i] != nil {
|
return res, nil
|
||||||
res[i] = &engine.BlobAndProofV1{
|
}
|
||||||
Blob: (*blobs[i])[:],
|
|
||||||
Proof: (*proofs[i])[:],
|
func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProofV2, error) {
|
||||||
}
|
if len(hashes) > 128 {
|
||||||
|
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
|
||||||
|
}
|
||||||
|
res := make([]*engine.BlobAndProofV2, len(hashes))
|
||||||
|
|
||||||
|
blobs, proofs := api.eth.TxPool().GetBlobs(hashes)
|
||||||
|
for i := 0; i < len(blobs); i++ {
|
||||||
|
if blobs[i] != nil {
|
||||||
|
res[i] = &engine.BlobAndProofV2{
|
||||||
|
Blob: (*blobs[i])[:],
|
||||||
|
Proofs: make([]hexutil.Bytes, gokzg4844.CellsPerExtBlob),
|
||||||
|
}
|
||||||
|
|
||||||
|
for j := 0; j < gokzg4844.CellsPerExtBlob; j++ {
|
||||||
|
res[i].Proofs[j] = hexutil.Bytes((*proofs[i*gokzg4844.CellsPerExtBlob+j])[:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue