Skip to content

Commit

Permalink
feat(taiko-client): propose blocks with revert protection (#18590)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Dec 16, 2024
1 parent 0984103 commit c3951cb
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/taiko-client/bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5b4b0cd271534aa72d865afa5fc55e0ee4b16b73
ab50d406172e879e7436c70a41bda674bfc6e441
44 changes: 22 additions & 22 deletions packages/taiko-client/bindings/gen_prover_set.go

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/taiko-client/cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ var (
Value: false,
EnvVars: []string{"L1_BLOB_ALLOWED"},
}
RevertProtectionEnabled = &cli.BoolFlag{
Name: "revertProtection",
Usage: "Enable revert protection with the support of endpoint and contract",
Value: false,
Category: proposerCategory,
EnvVars: []string{"REVERT_PROTECTION"},
}
)

// ProposerFlags All proposer flags.
Expand All @@ -134,4 +141,5 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
MaxProposedTxListsPerEpoch,
ProposeBlockIncludeParentMetaHash,
BlobAllowed,
RevertProtectionEnabled,
}, TxmgrFlags)
2 changes: 2 additions & 0 deletions packages/taiko-client/proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Config struct {
ProposeBlockTxGasLimit uint64
IncludeParentMetaHash bool
BlobAllowed bool
RevertProtectionEnabled bool
TxmgrConfigs *txmgr.CLIConfig
PrivateTxmgrConfigs *txmgr.CLIConfig
}
Expand Down Expand Up @@ -105,6 +106,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
ProposeBlockTxGasLimit: c.Uint64(flags.TxGasLimit.Name),
IncludeParentMetaHash: c.Bool(flags.ProposeBlockIncludeParentMetaHash.Name),
BlobAllowed: c.Bool(flags.BlobAllowed.Name),
RevertProtectionEnabled: c.Bool(flags.RevertProtectionEnabled.Name),
TxmgrConfigs: pkgFlags.InitTxmgrConfigsFromCli(
c.String(flags.L1WSEndpoint.Name),
l1ProposerPrivKey,
Expand Down
2 changes: 2 additions & 0 deletions packages/taiko-client/proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (p *Proposer) InitFromConfig(
cfg.ProposeBlockTxGasLimit,
cfg.ExtraData,
chainConfig,
cfg.RevertProtectionEnabled,
)
} else {
p.txBuilder = builder.NewCalldataTransactionBuilder(
Expand All @@ -140,6 +141,7 @@ func (p *Proposer) InitFromConfig(
cfg.ProposeBlockTxGasLimit,
cfg.ExtraData,
chainConfig,
cfg.RevertProtectionEnabled,
)
}

Expand Down
1 change: 1 addition & 0 deletions packages/taiko-client/proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func (s *ProposerTestSuite) TestProposeTxLists() {
cfg.ProposeBlockTxGasLimit,
cfg.ExtraData,
config.NewChainConfig(s.p.protocolConfigs),
false,
)

emptyTxListBytes, err := rlp.EncodeToBytes(types.Transactions{})
Expand Down
9 changes: 8 additions & 1 deletion packages/taiko-client/proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type BlobTransactionBuilder struct {
gasLimit uint64
extraData string
chainConfig *config.ChainConfig
revertProtectionEnabled bool
}

// NewBlobTransactionBuilder creates a new BlobTransactionBuilder instance based on giving configurations.
Expand All @@ -42,6 +43,7 @@ func NewBlobTransactionBuilder(
gasLimit uint64,
extraData string,
chainConfig *config.ChainConfig,
revertProtectionEnabled bool,
) *BlobTransactionBuilder {
return &BlobTransactionBuilder{
rpc,
Expand All @@ -52,6 +54,7 @@ func NewBlobTransactionBuilder(
gasLimit,
extraData,
chainConfig,
revertProtectionEnabled,
}
}

Expand Down Expand Up @@ -190,7 +193,11 @@ func (b *BlobTransactionBuilder) BuildOntake(
}
txListArray := make([][]byte, len(encodedParamsArray))
if b.proverSetAddress != rpc.ZeroAddress {
data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListArray)
if b.revertProtectionEnabled {
data, err = encoding.ProverSetABI.Pack("proposeBlocksV2Conditionally", encodedParamsArray, txListArray)
} else {
data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListArray)
}
if err != nil {
return nil, err
}
Expand Down
10 changes: 8 additions & 2 deletions packages/taiko-client/proposer/transaction_builder/calldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type CalldataTransactionBuilder struct {
gasLimit uint64
extraData string
chainConfig *config.ChainConfig
revertProtectionEnabled bool
}

// NewCalldataTransactionBuilder creates a new CalldataTransactionBuilder instance based on giving configurations.
Expand All @@ -39,6 +40,7 @@ func NewCalldataTransactionBuilder(
gasLimit uint64,
extraData string,
chainConfig *config.ChainConfig,
revertProtectionEnabled bool,
) *CalldataTransactionBuilder {
return &CalldataTransactionBuilder{
rpc,
Expand All @@ -49,6 +51,7 @@ func NewCalldataTransactionBuilder(
gasLimit,
extraData,
chainConfig,
revertProtectionEnabled,
}
}

Expand Down Expand Up @@ -157,8 +160,11 @@ func (b *CalldataTransactionBuilder) BuildOntake(

if b.proverSetAddress != rpc.ZeroAddress {
to = &b.proverSetAddress

data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListBytesArray)
if b.revertProtectionEnabled {
data, err = encoding.ProverSetABI.Pack("proposeBlocksV2Conditionally", encodedParamsArray, txListBytesArray)
} else {
data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListBytesArray)
}
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (s *TransactionBuilderTestSuite) SetupTest() {
0,
"test",
chainConfig,
false,
)
s.blobTxBuiler = NewBlobTransactionBuilder(
s.RPCClient,
Expand All @@ -51,6 +52,7 @@ func (s *TransactionBuilderTestSuite) SetupTest() {
10_000_000,
"test",
chainConfig,
false,
)
}

Expand Down

0 comments on commit c3951cb

Please sign in to comment.