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

feat(taiko-client): client changes for ontake fork #17746

Merged
merged 102 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
35768ec
feat(protocol): prepare `ontake` fork to support new params & metadat…
dantaik Jul 4, 2024
daa46bb
feat(taiko-client): client changes for `ontake` fork
davidtaikocha Jul 5, 2024
ebfe259
feat: add `BlockParams2`
davidtaikocha Jul 5, 2024
044341d
feat: update configs
davidtaikocha Jul 5, 2024
f14d296
feat: update comments
davidtaikocha Jul 5, 2024
3f93b70
respond to comments
dantaik Jul 6, 2024
96544ce
Update LibProposing.sol
dantaik Jul 6, 2024
39a784e
Update LibProposing.sol
dantaik Jul 6, 2024
a9c1d00
Merge branch 'main' into ontake_fork
dantaik Jul 7, 2024
e878336
Update TaikoL1TestGroupBase.sol
dantaik Jul 7, 2024
c5d7519
more
dantaik Jul 7, 2024
2c58c88
Merge branch 'ontake_fork' into ontake_fork_client
davidtaikocha Jul 8, 2024
b32efc4
feat: update bindings
davidtaikocha Jul 9, 2024
6ca42ea
Merge branch 'main' into ontake_fork
dantaik Jul 11, 2024
2914138
Merge branch 'ontake_fork' into ontake_fork_client
davidtaikocha Jul 11, 2024
235d42f
Merge branch 'main' into ontake_fork
dantaik Jul 11, 2024
78df730
Update TaikoL1Hekla.sol
dantaik Jul 11, 2024
2668736
Merge branch 'main' into ontake_fork
dantaik Jul 11, 2024
a60716e
BlockVerified2
dantaik Jul 11, 2024
35b8e00
more
dantaik Jul 11, 2024
7429b2a
proposeBlock2 nonpayable
dantaik Jul 13, 2024
cdc0f70
Create L1ProverSet.sol
dantaik Jul 13, 2024
2e53985
more
dantaik Jul 13, 2024
1bbf568
more
dantaik Jul 13, 2024
9f6302a
more
dantaik Jul 13, 2024
54421a0
Update ProverSet.sol
dantaik Jul 13, 2024
bf7142e
Update ProverSet.sol
dantaik Jul 13, 2024
4ebe4b6
Update ProverSet.sol
dantaik Jul 13, 2024
e03bbd5
Update ProverSet.sol
dantaik Jul 13, 2024
a5c867a
rename
dantaik Jul 14, 2024
ac422a5
more
dantaik Jul 14, 2024
7eadb0a
Merge branch 'prover_set_opt' into ontake_fork
dantaik Jul 14, 2024
00ba1fa
more
dantaik Jul 14, 2024
7988e9b
Merge branch 'prover_set_opt' into ontake_fork
dantaik Jul 14, 2024
bf6ffb6
Merge branch 'main' into ontake_fork
dantaik Jul 14, 2024
484cd10
fix MainnetTaikoL1 code too large
dantaik Jul 14, 2024
00e1997
Update TaikoEvents.sol
dantaik Jul 14, 2024
bdeaa52
Update DeployOnL1.s.sol
dantaik Jul 14, 2024
31412ef
Merge branch 'reduce_contract_size' into ontake_fork
dantaik Jul 14, 2024
8a50029
more
dantaik Jul 14, 2024
c869666
Merge branch 'main' into ontake_fork
dantaik Jul 15, 2024
751de97
add 3 more parameters
dantaik Jul 16, 2024
c0e89f5
L1_INVALID_BASEFEE_SHARING
dantaik Jul 16, 2024
a87a7bf
Merge branch 'main' into ontake_fork
dantaik Jul 16, 2024
2a406d2
Update LibRollupAddressCache.sol
dantaik Jul 16, 2024
e7afeb5
Merge branch 'main' into ontake_fork
dantaik Jul 17, 2024
20557fc
Update MainnetTierRouter.sol
dantaik Jul 17, 2024
e00507d
Update MainnetTierRouter.sol
dantaik Jul 17, 2024
22d0133
Update MainnetTierRouter.sol
dantaik Jul 17, 2024
a1a14f2
Merge branch 'ontake_fork' into ontake_fork_client
davidtaikocha Jul 17, 2024
d7e0a3c
feat: update bindings
davidtaikocha Jul 17, 2024
6fb0731
feat: add config pkg
davidtaikocha Jul 17, 2024
672e10f
feat: update txlist fetcher
davidtaikocha Jul 17, 2024
c504176
Merge branch 'main' into ontake_fork
dantaik Jul 17, 2024
51d3ed2
feat: introduce mtadata pkg
davidtaikocha Jul 18, 2024
ad85253
feat: introduce new metadata to driver
davidtaikocha Jul 18, 2024
d81705d
feat: introduce new metadata to prover
davidtaikocha Jul 18, 2024
024639e
test: update tests
davidtaikocha Jul 18, 2024
91f0012
test: update tests
davidtaikocha Jul 18, 2024
7a008ec
Merge branch 'main' into ontake_fork
dantaik Jul 19, 2024
08e6a3f
x2 to xV2
dantaik Jul 19, 2024
2359c84
Delete packages/protocol/contracts/L1/access/ProposerRegistry.sol
dantaik Jul 19, 2024
2e745d5
Merge branch 'ontake_fork' into ontake_fork_client
davidtaikocha Jul 19, 2024
1f3ccbe
feat: update bindings
davidtaikocha Jul 19, 2024
397d410
feat: update BlockProposedIterator
davidtaikocha Jul 19, 2024
e5a52d3
feat: update proposer
davidtaikocha Jul 19, 2024
96b5a09
Update ProverSet.sol
dantaik Jul 19, 2024
fca0764
Update TaikoData.sol
dantaik Jul 19, 2024
114a967
fix
dantaik Jul 19, 2024
2727e9d
rename
dantaik Jul 19, 2024
254ef95
Merge branch 'main' into ontake_fork
dantaik Jul 19, 2024
f950912
Merge branch 'ontake_fork' into ontake_fork_client
davidtaikocha Jul 20, 2024
5cdd248
feat: update bindings
davidtaikocha Jul 20, 2024
f843976
feat: update description
davidtaikocha Jul 20, 2024
7e08cf2
test: update tests
davidtaikocha Jul 20, 2024
72a356c
feat: update lint
davidtaikocha Jul 20, 2024
d39aca0
rename
dantaik Jul 21, 2024
f2e2c8f
fix
dantaik Jul 21, 2024
c2df9e6
Merge branch 'main' into ontake_fork
dantaik Jul 21, 2024
66aafb5
Merge branch 'main' into ontake_fork
davidtaikocha Jul 22, 2024
0e34a95
Merge branch 'ontake_fork' into ontake_fork_client
davidtaikocha Jul 22, 2024
89ba434
feat: update bindings
davidtaikocha Jul 22, 2024
1ad61a2
fix: fix a proposer issue
davidtaikocha Jul 22, 2024
88fca19
feat: more changes for prover
davidtaikocha Jul 22, 2024
ea4e592
feat: update driver state
davidtaikocha Jul 22, 2024
4f611cc
feat: update `OntakeForkHeight`
davidtaikocha Jul 22, 2024
98470f9
feat: update meta
davidtaikocha Jul 22, 2024
267bbfa
rename
YoGhurt111 Jul 23, 2024
1a4d5ce
Merge branch 'main' into ontake_fork_client
davidtaikocha Jul 26, 2024
32d96a8
feat: update protocol changes
davidtaikocha Jul 26, 2024
64b4ea9
feat: update bindings && tests
davidtaikocha Jul 26, 2024
640c9a5
feat: set `AnchorBlockId` to `0` in blockParam
davidtaikocha Jul 26, 2024
df5bd91
feat: set `Timestamp` to `0` in blockParam
davidtaikocha Jul 26, 2024
b1e5841
feat: update mainnet / devnet config
davidtaikocha Jul 26, 2024
f42921e
feat: update configs
davidtaikocha Jul 26, 2024
2a6513d
feat: update `ensureGenesisMatched`
davidtaikocha Jul 26, 2024
fbd2542
feat: update `BlobFetcher`
davidtaikocha Jul 26, 2024
24e0a5a
feat: update `GetProtocolConfig`
davidtaikocha Jul 26, 2024
2ef6536
Merge branch 'main' into ontake_fork_client
mask-pp Jul 26, 2024
0a511db
feat: update `BlobFetcher`
davidtaikocha Jul 26, 2024
c34c33a
feat: update `BlobFetcher`
davidtaikocha Jul 26, 2024
00884a8
test: update test
davidtaikocha Jul 26, 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 packages/taiko-client/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ run:
skip-files:
- bindings/gen_taiko_l1.go
- bindings/gen_taiko_l2.go
- bindings/encoding/struct.go

issues:
# List of regexps of issue texts to exclude.
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c370c7e0976bbe1160b074be665d751410367d16
32d96a816926e32da61f8495d257a8b10e26f83b
180 changes: 170 additions & 10 deletions packages/taiko-client/bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/metadata"
)

// ABI arguments marshaling components.
Expand Down Expand Up @@ -70,6 +71,96 @@ var (
Type: "address",
},
}
blockMetadataV2Components = []abi.ArgumentMarshaling{
{
Name: "anchorBlockHash",
Type: "bytes32",
},
{
Name: "difficulty",
Type: "bytes32",
},
{
Name: "blobHash",
Type: "bytes32",
},
{
Name: "extraData",
Type: "bytes32",
},
{
Name: "coinbase",
Type: "address",
},
{
Name: "id",
Type: "uint64",
},
{
Name: "gasLimit",
Type: "uint32",
},
{
Name: "timestamp",
Type: "uint64",
},
{
Name: "anchorBlockId",
Type: "uint64",
},
{
Name: "minTier",
Type: "uint16",
},
{
Name: "blobUsed",
Type: "bool",
},
{
Name: "parentMetaHash",
Type: "bytes32",
},
{
Name: "proposer",
Type: "address",
},
{
Name: "livenessBond",
Type: "uint96",
},
{
Name: "proposedAt",
Type: "uint64",
},
{
Name: "proposedIn",
Type: "uint64",
},
{
Name: "blobTxListOffset",
Type: "uint32",
},
{
Name: "blobTxListLength",
Type: "uint32",
},
{
Name: "blobIndex",
Type: "uint8",
},
{
Name: "basefeeAdjustmentQuotient",
Type: "uint8",
},
{
Name: "basefeeSharingPctg",
Type: "uint8",
},
{
Name: "blockGasIssuance",
Type: "uint32",
},
}
transitionComponents = []abi.ArgumentMarshaling{
{
Name: "parentHash",
Expand Down Expand Up @@ -134,19 +225,61 @@ var (
Type: "bytes",
},
}
blockParamsV2Components = []abi.ArgumentMarshaling{
{
Name: "coinbase",
Type: "address",
},
{
Name: "extraData",
Type: "bytes32",
},
{
Name: "parentMetaHash",
Type: "bytes32",
},
{
Name: "anchorBlockId",
Type: "uint64",
},
{
Name: "timestamp",
Type: "uint64",
},
{
Name: "blobTxListOffset",
Type: "uint32",
},
{
Name: "blobTxListLength",
Type: "uint32",
},
{
Name: "blobIndex",
Type: "uint8",
},
}
)

var (
blockParamsComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockParams", blockParamsComponents)
blockParamsComponentsArgs = abi.Arguments{{Name: "TaikoData.BlockParams", Type: blockParamsComponentsType}}
blockMetadataComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockMetadata", blockMetadataComponents)
transitionComponentsType, _ = abi.NewType("tuple", "TaikoData.Transition", transitionComponents)
tierProofComponentsType, _ = abi.NewType("tuple", "TaikoData.TierProof", tierProofComponents)
proveBlockInputArgs = abi.Arguments{
blockParamsComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockParams", blockParamsComponents)
blockParamsComponentsArgs = abi.Arguments{{Name: "TaikoData.BlockParams", Type: blockParamsComponentsType}}
blockParamsV2ComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockParamsV2", blockParamsV2Components)
blockParamsV2ComponentsArgs = abi.Arguments{{Name: "TaikoData.BlockParamsV2", Type: blockParamsV2ComponentsType}}
blockMetadataComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockMetadata", blockMetadataComponents)
blockMetadataV2ComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockMetadataV2", blockMetadataV2Components)
transitionComponentsType, _ = abi.NewType("tuple", "TaikoData.Transition", transitionComponents)
tierProofComponentsType, _ = abi.NewType("tuple", "TaikoData.TierProof", tierProofComponents)
proveBlockInputArgs = abi.Arguments{
{Name: "TaikoData.BlockMetadata", Type: blockMetadataComponentsType},
{Name: "TaikoData.Transition", Type: transitionComponentsType},
{Name: "TaikoData.TierProof", Type: tierProofComponentsType},
}
proveOntakeBlockInputArgs = abi.Arguments{
{Name: "TaikoData.BlockMetadataV2", Type: blockMetadataV2ComponentsType},
{Name: "TaikoData.Transition", Type: transitionComponentsType},
{Name: "TaikoData.TierProof", Type: tierProofComponentsType},
}
)

// Contract ABIs.
Expand Down Expand Up @@ -236,16 +369,43 @@ func EncodeBlockParams(params *BlockParams) ([]byte, error) {
return b, nil
}

// EncodeBlockParamsOntake performs the solidity `abi.encode` for the given ontake blockParams.
func EncodeBlockParamsOntake(params *BlockParamsV2) ([]byte, error) {
b, err := blockParamsV2ComponentsArgs.Pack(params)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode ontake block params, %w", err)
}
return b, nil
}

// EncodeProveBlockInput performs the solidity `abi.encode` for the given TaikoL1.proveBlock input.
func EncodeProveBlockInput(
meta *bindings.TaikoDataBlockMetadata,
meta metadata.TaikoBlockMetaData,
transition *bindings.TaikoDataTransition,
tierProof *bindings.TaikoDataTierProof,
) ([]byte, error) {
b, err := proveBlockInputArgs.Pack(meta, transition, tierProof)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode TakoL1.proveBlock input, %w", err)
var (
b []byte
err error
)
if meta.IsOntakeBlock() {
if b, err = proveOntakeBlockInputArgs.Pack(
meta.(*metadata.TaikoDataBlockMetadataOntake).InnerMetadata(),
transition,
tierProof,
); err != nil {
return nil, fmt.Errorf("failed to abi.encode TakoL1.proveBlock input after ontake fork, %w", err)
}
} else {
if b, err = proveBlockInputArgs.Pack(
meta.(*metadata.TaikoDataBlockMetadataLegacy).InnerMetadata(),
transition,
tierProof,
); err != nil {
return nil, fmt.Errorf("failed to abi.encode TakoL1.proveBlock input, %w", err)
}
}

return b, nil
}

Expand Down
67 changes: 67 additions & 0 deletions packages/taiko-client/bindings/encoding/protocol_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package encoding

import (
"math/big"

"github.com/ethereum/go-ethereum/params"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
)

var (
livenessBond, _ = new(big.Int).SetString("125000000000000000000", 10)
InternlDevnetProtocolConfig = &bindings.TaikoDataConfig{
ChainId: params.TaikoInternalL2ANetworkID.Uint64(),
BlockMaxProposals: 324_000,
BlockRingBufferSize: 360_000,
MaxBlocksToVerify: 16,
BlockMaxGasLimit: 240_000_000,
LivenessBond: livenessBond,
StateRootSyncInternal: 16,
MaxAnchorHeightOffset: 64,
BasefeeAdjustmentQuotient: 8,
BasefeeSharingPctg: 75,
BlockGasIssuance: 20_000_000,
OntakeForkHeight: 374_400,
}
HeklaProtocolConfig = &bindings.TaikoDataConfig{
ChainId: params.HeklaNetworkID.Uint64(),
BlockMaxProposals: 324_000,
BlockRingBufferSize: 324_512,
MaxBlocksToVerify: 16,
BlockMaxGasLimit: 240_000_000,
LivenessBond: livenessBond,
StateRootSyncInternal: 16,
MaxAnchorHeightOffset: 64,
BasefeeAdjustmentQuotient: 8,
BasefeeSharingPctg: 75,
BlockGasIssuance: 20_000_000,
OntakeForkHeight: 540_000,
}
MainnetProtocolConfig = &bindings.TaikoDataConfig{
ChainId: params.TaikoMainnetNetworkID.Uint64(),
BlockMaxProposals: 324_000,
BlockRingBufferSize: 360_000,
MaxBlocksToVerify: 16,
BlockMaxGasLimit: 240_000_000,
LivenessBond: livenessBond,
StateRootSyncInternal: 16,
MaxAnchorHeightOffset: 64,
BasefeeAdjustmentQuotient: 8,
BasefeeSharingPctg: 75,
BlockGasIssuance: 20_000_000,
OntakeForkHeight: 374_400,
}
)

// GetProtocolConfig returns the protocol config for the given chain ID.
func GetProtocolConfig(chainID uint64) *bindings.TaikoDataConfig {
switch chainID {
case params.HeklaNetworkID.Uint64():
return HeklaProtocolConfig
case params.TaikoMainnetNetworkID.Uint64():
return MainnetProtocolConfig
default:
return InternlDevnetProtocolConfig
}
}
59 changes: 59 additions & 0 deletions packages/taiko-client/bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
)

// Tier IDs defined in protocol.
Expand Down Expand Up @@ -41,6 +43,18 @@ type BlockParams struct {
Signature []byte
}

// BlockParamsV2 should be same with TaikoData.BlockParamsV2.
type BlockParamsV2 struct {
Coinbase common.Address
ExtraData [32]byte
ParentMetaHash [32]byte
AnchorBlockId uint64
Timestamp uint64
BlobTxListOffset uint32
BlobTxListLength uint32
BlobIndex uint8
}

// TierFee should be same with TaikoData.TierFee.
type TierFee struct {
Tier uint16
Expand Down Expand Up @@ -73,6 +87,51 @@ func ToExecutableData(header *types.Header) *engine.ExecutableData {
return executableData
}

// TransitionProvedEventToV2 converts a *bindings.TaikoL1ClientTransitionProved
// to *bindings.TaikoL1ClientTransitionProvedV2.
func TransitionProvedEventToV2(
e *bindings.TaikoL1ClientTransitionProved,
proposedIn uint64,
) *bindings.TaikoL1ClientTransitionProvedV2 {
return &bindings.TaikoL1ClientTransitionProvedV2{
BlockId: e.BlockId,
Tran: e.Tran,
Prover: e.Prover,
ValidityBond: e.ValidityBond,
Tier: e.Tier,
ProposedIn: proposedIn,
Raw: e.Raw,
}
}

// TransitionContestedEventToV2 converts a *bindings.TaikoL1ClientTransitionContested
// to *bindings.TaikoL1ClientTransitionContestedV2.
func TransitionContestedEventToV2(
e *bindings.TaikoL1ClientTransitionContested,
proposedIn uint64,
) *bindings.TaikoL1ClientTransitionContestedV2 {
return &bindings.TaikoL1ClientTransitionContestedV2{
BlockId: e.BlockId,
Tran: e.Tran,
Contester: e.Contester,
ContestBond: e.ContestBond,
Tier: e.Tier,
ProposedIn: proposedIn,
Raw: e.Raw,
}
}

// BlockVerifiedEventToV2 converts a *bindings.TaikoL1ClientBlockVerified to *bindings.TaikoL1ClientBlockVerifiedV2.
func BlockVerifiedEventToV2(e *bindings.TaikoL1ClientBlockVerified) *bindings.TaikoL1ClientBlockVerifiedV2 {
return &bindings.TaikoL1ClientBlockVerifiedV2{
BlockId: e.BlockId,
Prover: e.Prover,
BlockHash: e.BlockHash,
Tier: e.Tier,
Raw: e.Raw,
}
}

// BloomToBytes converts a types.Bloom to [8][32]byte slice.
func BloomToBytes(bloom types.Bloom) [8][32]byte {
b := [8][32]byte{}
Expand Down
Loading
Loading