mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
core/types: encode blob tx version decode blobtx sidecar
This commit is contained in:
parent
21c5a287f9
commit
60f003024e
1 changed files with 19 additions and 0 deletions
|
|
@ -50,6 +50,7 @@ type txJSON struct {
|
||||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||||
|
|
||||||
// Blob transaction sidecar encoding:
|
// Blob transaction sidecar encoding:
|
||||||
|
Version *hexutil.Uint64 `json:"version,omitempty"`
|
||||||
Blobs []kzg4844.Blob `json:"blobs,omitempty"`
|
Blobs []kzg4844.Blob `json:"blobs,omitempty"`
|
||||||
Commitments []kzg4844.Commitment `json:"commitments,omitempty"`
|
Commitments []kzg4844.Commitment `json:"commitments,omitempty"`
|
||||||
Proofs []kzg4844.Proof `json:"proofs,omitempty"`
|
Proofs []kzg4844.Proof `json:"proofs,omitempty"`
|
||||||
|
|
@ -150,6 +151,8 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
|
||||||
yparity := itx.V.Uint64()
|
yparity := itx.V.Uint64()
|
||||||
enc.YParity = (*hexutil.Uint64)(&yparity)
|
enc.YParity = (*hexutil.Uint64)(&yparity)
|
||||||
if sidecar := itx.Sidecar; sidecar != nil {
|
if sidecar := itx.Sidecar; sidecar != nil {
|
||||||
|
version := uint64(sidecar.Version)
|
||||||
|
enc.Version = (*hexutil.Uint64)(&version)
|
||||||
enc.Blobs = itx.Sidecar.Blobs
|
enc.Blobs = itx.Sidecar.Blobs
|
||||||
enc.Commitments = itx.Sidecar.Commitments
|
enc.Commitments = itx.Sidecar.Commitments
|
||||||
enc.Proofs = itx.Sidecar.Proofs
|
enc.Proofs = itx.Sidecar.Proofs
|
||||||
|
|
@ -429,6 +432,22 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(dec.Blobs) > 0 || len(dec.Commitments) > 0 || len(dec.Proofs) > 0 {
|
||||||
|
if len(dec.Blobs) != len(dec.Commitments) || len(dec.Blobs) != len(dec.Proofs) {
|
||||||
|
return errors.New("blob transaction sidecar fields 'blobs', 'commitments', and 'proofs' must all have the same length")
|
||||||
|
}
|
||||||
|
version := BlobSidecarVersion0
|
||||||
|
if dec.Version != nil {
|
||||||
|
version = byte(*dec.Version)
|
||||||
|
}
|
||||||
|
itx.Sidecar = &BlobTxSidecar{
|
||||||
|
Version: version,
|
||||||
|
Blobs: dec.Blobs,
|
||||||
|
Commitments: dec.Commitments,
|
||||||
|
Proofs: dec.Proofs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case SetCodeTxType:
|
case SetCodeTxType:
|
||||||
var itx SetCodeTx
|
var itx SetCodeTx
|
||||||
inner = &itx
|
inner = &itx
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue