This repository has been archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repo): implement EIP-4844 in client (#526)
Co-authored-by: maskpp <[email protected]>
- Loading branch information
1 parent
6fefa6e
commit 103cad2
Showing
29 changed files
with
1,846 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*.dll | ||
*.so | ||
*.dylib | ||
.env | ||
bin | ||
coverage.out | ||
prover/dbPath | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package txlistdecoder | ||
|
||
import ( | ||
"context" | ||
"crypto/sha256" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/crypto/kzg4844" | ||
"github.com/ethereum/go-ethereum/log" | ||
|
||
"github.com/taikoxyz/taiko-client/bindings" | ||
"github.com/taikoxyz/taiko-client/pkg/rpc" | ||
) | ||
|
||
type BlobFetcher struct { | ||
rpc *rpc.Client | ||
} | ||
|
||
func NewBlobTxListFetcher(rpc *rpc.Client) *BlobFetcher { | ||
return &BlobFetcher{rpc} | ||
} | ||
|
||
func (d *BlobFetcher) Fetch( | ||
ctx context.Context, | ||
tx *types.Transaction, | ||
meta *bindings.TaikoDataBlockMetadata, | ||
) ([]byte, error) { | ||
if !meta.BlobUsed { | ||
return nil, errBlobUnused | ||
} | ||
|
||
sidecars, err := d.rpc.GetBlobs(ctx, new(big.Int).SetUint64(meta.L1Height+1)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
log.Info("Fetch sidecars", "slot", meta.L1Height+1, "sidecars", len(sidecars)) | ||
|
||
for i, sidecar := range sidecars { | ||
log.Info( | ||
"Block sidecar", | ||
"index", i, | ||
"KzgCommitment", sidecar.KzgCommitment, | ||
"blobHash", common.Bytes2Hex(meta.BlobHash[:]), | ||
) | ||
|
||
commitment := kzg4844.Commitment(common.FromHex(sidecar.KzgCommitment)) | ||
if kzg4844.CalcBlobHashV1( | ||
sha256.New(), | ||
&commitment, | ||
) == common.BytesToHash(meta.BlobHash[:]) { | ||
return rpc.DecodeBlob(common.FromHex(sidecar.Blob)) | ||
} | ||
} | ||
|
||
return nil, errSidecarNotFound | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package txlistdecoder | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/taikoxyz/taiko-client/bindings" | ||
"github.com/taikoxyz/taiko-client/bindings/encoding" | ||
) | ||
|
||
type CalldataFetcher struct{} | ||
|
||
func (d *CalldataFetcher) Fetch( | ||
ctx context.Context, | ||
tx *types.Transaction, | ||
meta *bindings.TaikoDataBlockMetadata, | ||
) ([]byte, error) { | ||
if meta.BlobUsed { | ||
return nil, errBlobUsed | ||
} | ||
|
||
return encoding.UnpackTxListBytes(tx.Data()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package txlistdecoder | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/taikoxyz/taiko-client/bindings" | ||
) | ||
|
||
var ( | ||
errBlobUsed = errors.New("blob is used") | ||
errBlobUnused = errors.New("blob is not used") | ||
errSidecarNotFound = errors.New("sidecar not found") | ||
) | ||
|
||
type TxListFetcher interface { | ||
Fetch(ctx context.Context, tx *types.Transaction, meta *bindings.TaikoDataBlockMetadata) ([]byte, error) | ||
} |
Oops, something went wrong.