Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bunch of bugs found during development of EIP-4844 tooling #5

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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