Skip to content

Commit

Permalink
Merge pull request #5 from asn-d6/eip4844-tooling
Browse files Browse the repository at this point in the history
Fix a bunch of bugs found during development of EIP-4844 tooling
  • Loading branch information
protolambda authored Mar 22, 2022
2 parents 6f21779 + f87c6d6 commit d6fb210
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
9 changes: 6 additions & 3 deletions core/types/data_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,18 @@ func (blobs Blobs) copy() Blobs {
return cpy
}

func (blobs Blobs) ComputeCommitments() (commitments []KZGCommitment, ok bool) {
// Return KZG commitments and versioned hashes that correspond to these blobs
func (blobs Blobs) ComputeCommitments() (commitments []KZGCommitment, versionedHashes []common.Hash, ok bool) {
commitments = make([]KZGCommitment, len(blobs))
versionedHashes = make([]common.Hash, len(blobs))
for i, blob := range blobs {
commitments[i], ok = blob.ComputeCommitment()
if !ok {
return nil, false
return nil, nil, false
}
versionedHashes[i] = commitments[i].ComputeVersionedHash()
}
return commitments, true
return commitments, versionedHashes, true
}

type BlobTxWrapper struct {
Expand Down
2 changes: 1 addition & 1 deletion core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (tx *Transaction) UnmarshalBinary(b []byte) error {
if err != nil {
return err
}
tx.setDecoded(inner, len(b))
tx.setDecoded(inner, 0)
tx.wrapData = wrapData
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func LatestSignerForChainID(chainID *big.Int) Signer {
if chainID == nil {
return HomesteadSigner{}
}
return NewLondonSigner(chainID)
return NewDankSigner(chainID)

}

// SignTx signs the transaction using the given signer and private key.
Expand Down
8 changes: 5 additions & 3 deletions internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
msg.Value.SetFromBig((*big.Int)(args.Value))
msg.Data = args.data()
msg.AccessList = types.AccessListView(al)
kzgs, ok := types.Blobs(args.Blobs).ComputeCommitments()
if ok { // if blobs are invalid we will omit the wrap-data
commitments, versionedHashes, ok := types.Blobs(args.Blobs).ComputeCommitments()
// XXX if blobs are invalid we will omit the wrap-data (and an error will pop-up later)
if ok {
opts = append(opts, types.WithTxWrapData(&types.BlobTxWrapData{
BlobKzgs: kzgs,
BlobKzgs: commitments,
Blobs: args.Blobs,
}))
msg.BlobVersionedHashes = versionedHashes
}
data = &types.SignedBlobTx{Message: msg}
case args.MaxFeePerGas != nil:
Expand Down

0 comments on commit d6fb210

Please sign in to comment.