Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(repo): implement EIP-4844 in client #526

Merged
merged 90 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
91861bd
enable l1 eip4844
mask-pp Jan 22, 2024
9eb5c7d
Merge branch 'main' into eip4844
mask-pp Jan 22, 2024
dc54c0c
revert change
mask-pp Jan 22, 2024
d046f90
Add blob tx
mask-pp Jan 22, 2024
9a96b3f
add blob tx
mask-pp Jan 23, 2024
7aacb28
Merge remote-tracking branch 'origin/main' into eip4844
davidtaikocha Jan 23, 2024
4614b95
add blob tx
mask-pp Jan 23, 2024
b6ea3ad
feat(eip4844): Eip4844 blob tx (#527)
mask-pp Jan 23, 2024
ecdf4a7
order import
mask-pp Jan 23, 2024
03208c5
order import
mask-pp Jan 23, 2024
e7ac54b
fix lint
mask-pp Jan 23, 2024
57a39ef
update blob tx
mask-pp Jan 23, 2024
5244845
update blob tx
mask-pp Jan 23, 2024
847f6e5
feat: add l1 beacon client
davidtaikocha Jan 24, 2024
0b01116
update blob tx
mask-pp Jan 24, 2024
96d446e
Merge branch 'eip4844' into eip4844_blob_tx_2
mask-pp Jan 24, 2024
64020d1
feat(eip4844): update blob tx (#528)
mask-pp Jan 24, 2024
ee72a39
update blob tx
mask-pp Jan 24, 2024
5f122d1
use one blob tx
mask-pp Jan 24, 2024
87013ed
Merge branch 'main' into eip4844
mask-pp Jan 25, 2024
889e499
use eth_filltransaction
mask-pp Jan 25, 2024
14f00b2
Merge branch 'main' into eip4844
mask-pp Jan 25, 2024
f77b7ba
fix bug
mask-pp Jan 26, 2024
826ea30
fix bug
mask-pp Jan 26, 2024
8d4bb85
feat(eip4844): Eip4844 blob tx 3 (#536)
mask-pp Jan 26, 2024
a1497e3
Merge branch 'main' into eip4844
mask-pp Jan 26, 2024
b31213d
Merge branch 'main' into eip4844
davidtaikocha Jan 28, 2024
7ccc57d
add encode and decode func
mask-pp Jan 29, 2024
1689560
Merge branch 'main' into eip4844
davidtaikocha Jan 29, 2024
2bf0cc1
Merge branch 'main' into eip4844
davidtaikocha Jan 31, 2024
0c3d166
fix bug
mask-pp Feb 1, 2024
1a2580b
feat: update bindings
davidtaikocha Jan 31, 2024
b35a4ac
feat: update workflow
davidtaikocha Jan 31, 2024
5a1f999
feat: add l1 beacon client
davidtaikocha Jan 24, 2024
715df07
feat: add decoder
davidtaikocha Jan 25, 2024
ec9cc11
feat: update flags
davidtaikocha Jan 29, 2024
2ef72cd
update
davidtaikocha Jan 30, 2024
7f97017
feat: rename
davidtaikocha Feb 2, 2024
5a4c061
Merge branch 'main' into eip4844
davidtaikocha Feb 2, 2024
538a9c7
update docker
mask-pp Feb 2, 2024
f725fc1
fix overwritten
mask-pp Feb 2, 2024
a90a152
Merge branch 'eip4844' into eip4844_docker
mask-pp Feb 2, 2024
710bfc0
handle ports
mask-pp Feb 2, 2024
a97ee4b
update genesis.json
mask-pp Feb 2, 2024
6f1e9c9
use alpha-6_eip4844 branch
mask-pp Feb 2, 2024
45ebaf8
add genesis.json
mask-pp Feb 2, 2024
710ef14
ignore genesis.json
mask-pp Feb 2, 2024
d6523d6
update docker
mask-pp Feb 2, 2024
f8e5b36
enable blob docker (#542)
mask-pp Feb 2, 2024
34c5298
update docker
mask-pp Feb 2, 2024
5bcfeae
Merge branch 'main' into eip4844
davidtaikocha Feb 2, 2024
85e9bce
update docker compose
mask-pp Feb 3, 2024
245c373
update docker compose
mask-pp Feb 4, 2024
337bb0a
Merge branch 'eip4844' into alpha-6_docker_1
mask-pp Feb 4, 2024
8d83b93
Alpha 6 docker 1 (#544)
mask-pp Feb 4, 2024
7c117dc
add test flag
mask-pp Feb 4, 2024
6fbc16f
fix bug
mask-pp Feb 5, 2024
9637fa3
change replacement
mask-pp Feb 5, 2024
e6859c5
expose 3500 port
mask-pp Feb 5, 2024
8571f4a
update scripts
mask-pp Feb 5, 2024
0d3d561
update git ignore file
mask-pp Feb 5, 2024
fa5abaf
update scripts
mask-pp Feb 5, 2024
9cd0a5f
Merge branch 'main' into eip4844
mask-pp Feb 7, 2024
7b0da7e
update go mod
mask-pp Feb 7, 2024
6e19a32
Merge branch 'main' into eip4844
davidtaikocha Feb 7, 2024
cca1518
feat: add `kZGToVersionedHash`
davidtaikocha Feb 9, 2024
f62dffb
chore: update ci
davidtaikocha Feb 9, 2024
edf4b1a
feat: update blob.go
davidtaikocha Feb 9, 2024
5c6d0fe
feat: fix lint errors
davidtaikocha Feb 10, 2024
5eb8861
test: revert test changes, wait for anvil update
davidtaikocha Feb 10, 2024
568aa28
feat: update ci
davidtaikocha Feb 11, 2024
7a90069
upgrade sidecar encode and decode functions
mask-pp Feb 14, 2024
2011f1b
feat(all): sync state root rather than signal service's storage root
davidtaikocha Feb 14, 2024
d1f1d8f
feat: update tests
davidtaikocha Feb 14, 2024
be64dcc
feat: update tests
davidtaikocha Feb 14, 2024
1516230
Merge branch 'use-state-root' into eip4844
davidtaikocha Feb 14, 2024
3dc71af
test: fix lint error
davidtaikocha Feb 14, 2024
fe1ce39
feat: update flag usage
davidtaikocha Feb 14, 2024
08c2ad9
Merge branch 'main' into eip4844
davidtaikocha Feb 15, 2024
ac8849a
chore(ci): update workflow
davidtaikocha Feb 15, 2024
d1d2dba
Merge branch 'main' into eip4844
davidtaikocha Feb 15, 2024
3b567c9
chore(ci): update workflow
davidtaikocha Feb 15, 2024
041c98b
chore(ci): update workflow
davidtaikocha Feb 15, 2024
7405ba1
enable blob call
mask-pp Feb 15, 2024
44d64ac
add load env function
mask-pp Feb 16, 2024
0dab4e9
trigger ci
mask-pp Feb 16, 2024
f0e50e3
delete taiko-mono's ref
mask-pp Feb 16, 2024
233553d
use rpc.DecodeBlob function
mask-pp Feb 16, 2024
e2aa705
Merge branch 'main' into eip4844
davidtaikocha Feb 16, 2024
d9f492d
Merge branch 'main' into eip4844
mask-pp Feb 17, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
.env
bin
coverage.out
prover/dbPath
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM golang:1.21-alpine as builder

RUN apk add --no-cache gcc musl-dev linux-headers git make
RUN apk update && apk add --no-cache --update gcc musl-dev linux-headers git make build-base

WORKDIR /taiko-client
COPY . .
RUN make build

FROM alpine:latest

RUN apk add --no-cache ca-certificates
RUN apk add --no-cache ca-certificates libstdc++

COPY --from=builder /taiko-client/bin/taiko-client /usr/local/bin/

Expand Down
7 changes: 7 additions & 0 deletions cmd/flags/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ var (
Required: true,
Category: driverCategory,
}
L1BeaconEndpoint = &cli.StringFlag{
Name: "l1.beacon",
Usage: "HTTP RPC endpoint of a L1 consensus client",
Required: true,
Category: driverCategory,
}
JWTSecret = &cli.StringFlag{
Name: "jwtSecret",
Usage: "Path to a JWT secret to use for authenticated RPC endpoints",
Expand Down Expand Up @@ -47,6 +53,7 @@ var (

// DriverFlags All driver flags.
var DriverFlags = MergeFlags(CommonFlags, []cli.Flag{
L1BeaconEndpoint,
L2WSEndpoint,
L2AuthEndpoint,
JWTSecret,
Expand Down
6 changes: 6 additions & 0 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ var (
Value: false,
Category: proposerCategory,
}
BlobAllowed = &cli.BoolFlag{
Name: "blobAllowed",
Usage: "Send EIP-4844 blob transactions when proposing blocks",
Value: false,
}
L1BlockBuilderTip = &cli.Uint64Flag{
Name: "l1BlockBuilderTip",
Usage: "Amount you wish to tip the L1 block builder",
Expand Down Expand Up @@ -160,5 +165,6 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
MaxTierFeePriceBumps,
ProposeBlockIncludeParentMetaHash,
ProposerAssignmentHookAddress,
BlobAllowed,
L1BlockBuilderTip,
})
17 changes: 15 additions & 2 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
anchorTxConstructor "github.com/taikoxyz/taiko-client/driver/anchor_tx_constructor"
"github.com/taikoxyz/taiko-client/driver/chain_syncer/beaconsync"
"github.com/taikoxyz/taiko-client/driver/state"
txlistfetcher "github.com/taikoxyz/taiko-client/driver/txlist_fetcher"
"github.com/taikoxyz/taiko-client/internal/metrics"
eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator"
"github.com/taikoxyz/taiko-client/pkg/rpc"
Expand Down Expand Up @@ -235,11 +236,22 @@ func (s *Syncer) onBlockProposed(
event.Raw.TxIndex,
)
if err != nil {
return fmt.Errorf("failed to fetch original TaikoL1.proposeBlock transaction: %w", err)
return fmt.Errorf("failed to fetch original TaikoL1.ProposeBlock transaction: %w", err)
}

var txListDecoder txlistfetcher.TxListFetcher
if event.Meta.BlobUsed {
txListDecoder = txlistfetcher.NewBlobTxListFetcher(s.rpc)
} else {
txListDecoder = &txlistfetcher.CalldataFetcher{}
}
txListBytes, err := txListDecoder.Fetch(ctx, tx, &event.Meta)
if err != nil {
return fmt.Errorf("failed to decode tx list: %w", err)
}

// Check whether the transactions list is valid.
txListBytes, hint, invalidTxIndex, err := s.txListValidator.ValidateTxList(event.BlockId, tx.Data())
hint, invalidTxIndex, err := s.txListValidator.ValidateTxList(event.BlockId, txListBytes, event.Meta.BlobUsed)
if err != nil {
return fmt.Errorf("failed to validate transactions list: %w", err)
}
Expand All @@ -249,6 +261,7 @@ func (s *Syncer) onBlockProposed(
"blockID", event.BlockId,
"hint", hint,
"invalidTxIndex", invalidTxIndex,
"bytes", len(txListBytes),
)

l1Origin := &rawdb.L1Origin{
Expand Down
1 change: 1 addition & 0 deletions driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
return &Config{
ClientConfig: &rpc.ClientConfig{
L1Endpoint: c.String(flags.L1WSEndpoint.Name),
L1BeaconEndpoint: c.String(flags.L1BeaconEndpoint.Name),
L2Endpoint: c.String(flags.L2WSEndpoint.Name),
L2CheckPoint: l2CheckPoint,
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),
Expand Down
2 changes: 1 addition & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Driver struct {
wg sync.WaitGroup
}

// InitFromCli New initializes the given driver instance based on the command line flags.
// InitFromCli initializes the given driver instance based on the command line flags.
func (d *Driver) InitFromCli(ctx context.Context, c *cli.Context) error {
cfg, err := NewConfigFromCliContext(c)
if err != nil {
Expand Down
59 changes: 59 additions & 0 deletions driver/txlist_fetcher/blob.go
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
}
23 changes: 23 additions & 0 deletions driver/txlist_fetcher/calldata.go
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())
}
19 changes: 19 additions & 0 deletions driver/txlist_fetcher/interface.go
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)
}
Loading
Loading