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

feat(all): update protocol bindings and some related changes #237

Merged
merged 4 commits into from
May 23, 2023
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
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
285c756c270fa4041c10aa06d95e2067fcc1b69f
8aa0940bc0ff576c30061c7c7e84416698dccbd7
19 changes: 15 additions & 4 deletions bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ var (
Type: "uint8",
},
}
// TODO(Roger): add `TaikoData.EthDeposit[] depositsProcessed` field to `blockMetadataComponents`
// depositProcessedComponents = []abi.ArgumentMarshaling{
// {
// Name: "recipient",
// Type: "address",
// },
// {
// Name: "amount",
// Type: "uint96",
// },
// }
blockMetadataComponents = []abi.ArgumentMarshaling{
{
Name: "id",
Expand All @@ -55,10 +66,6 @@ var (
Name: "l1Height",
Type: "uint64",
},
{
Name: "gasLimit",
Type: "uint32",
},
{
Name: "l1Hash",
Type: "bytes32",
Expand All @@ -79,6 +86,10 @@ var (
Name: "txListByteEnd",
Type: "uint24",
},
{
Name: "gasLimit",
Type: "uint32",
},
{
Name: "beneficiary",
Type: "address",
Expand Down
35 changes: 16 additions & 19 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ func NewSyncer(
progressTracker: progressTracker,
anchorConstructor: constructor,
txListValidator: txListValidator.NewTxListValidator(
configs.BlockMaxGasLimit.Uint64(),
configs.MaxTransactionsPerBlock.Uint64(),
configs.MaxBytesPerTxList.Uint64(),
configs.MinTxGasLimit.Uint64(),
configs.BlockMaxGasLimit,
configs.MaxTransactionsPerBlock,
configs.MaxBytesPerTxList,
rpc.L2ChainID,
),
}, nil
Expand Down
31 changes: 0 additions & 31 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,37 +147,6 @@ func (s *CalldataSyncerTestSuite) TestHandleReorgToNoneGenesis() {
s.Greater(s.s.lastInsertedBlockID.Uint64(), uint64(1))
}

func (s *CalldataSyncerTestSuite) TestWithdrawRootCalculation() {
depositReceiptPrivKey, err := crypto.ToECDSA(
common.Hex2Bytes("2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"),
)
s.Nil(err)

depositReceipt := crypto.PubkeyToAddress(depositReceiptPrivKey.PublicKey)
balance, err := s.RpcClient.L2.BalanceAt(context.Background(), depositReceipt, nil)
s.Nil(err)

testutils.DepositEtherToL2(&s.ClientTestSuite, depositReceiptPrivKey)

for _, e := range testutils.ProposeAndInsertEmptyBlocks(&s.ClientTestSuite, s.p, s.s) {
header, err := s.s.rpc.L2.HeaderByNumber(context.Background(), e.Id)
s.Nil(err)
s.NotEmpty(e.Meta.DepositsRoot)
s.Equal(common.BytesToHash(e.Meta.DepositsRoot[:]), *header.WithdrawalsHash)

for _, deposit := range e.Meta.DepositsProcessed {
if depositReceipt == deposit.Recipient {
balance = new(big.Int).Add(balance, deposit.Amount)
}
}
}

balanceAfter, err := s.RpcClient.L2.BalanceAt(context.Background(), depositReceipt, nil)
s.Nil(err)

s.Zero(balanceAfter.Cmp(balance))
}

func (s *CalldataSyncerTestSuite) TestTreasuryIncomeAllAnchors() {
treasury := common.HexToAddress(os.Getenv("TREASURY"))
s.NotZero(treasury.Big().Uint64())
Expand Down
16 changes: 8 additions & 8 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
// syncProgressRecheckDelay is the time delay of rechecking the L2 execution engine's sync progress again,
// if the previous check failed.
syncProgressRecheckDelay = 12 * time.Second
minTxGasLimit = 21000
)

// ensureGenesisMatched fetches the L2 genesis block from TaikoL1 contract,
Expand Down Expand Up @@ -196,10 +197,9 @@ func (c *Client) WaitL1Origin(ctx context.Context, blockID *big.Int) (*rawdb.L1O
// upper limit.
func (c *Client) GetPoolContent(
ctx context.Context,
maxTransactionsPerBlock *big.Int,
blockMaxGasLimit *big.Int,
maxBytesPerTxList *big.Int,
minTxGasLimit *big.Int,
maxTransactionsPerBlock uint64,
blockMaxGasLimit uint64,
maxBytesPerTxList uint64,
locals []common.Address,
) ([]types.Transactions, error) {
var localsArg []string
Expand All @@ -212,10 +212,10 @@ func (c *Client) GetPoolContent(
ctx,
&result,
"taiko_txPoolContent",
maxTransactionsPerBlock.Uint64(),
blockMaxGasLimit.Uint64(),
maxBytesPerTxList.Uint64(),
minTxGasLimit.Uint64(),
maxTransactionsPerBlock,
blockMaxGasLimit,
maxBytesPerTxList,
minTxGasLimit,
localsArg,
)

Expand Down
11 changes: 0 additions & 11 deletions pkg/tx_list_validator/tx_list_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ type InvalidTxListReason uint8
// All invalid transactions list reasons.
const (
HintNone InvalidTxListReason = iota
HintTxGasLimitTooSmall
HintOK
)

type TxListValidator struct {
blockMaxGasLimit uint64
maxTransactionsPerBlock uint64
maxBytesPerTxList uint64
minTxGasLimit uint64
chainID *big.Int
}

Expand All @@ -32,14 +30,12 @@ func NewTxListValidator(
blockMaxGasLimit uint64,
maxTransactionsPerBlock uint64,
maxBytesPerTxList uint64,
minTxGasLimit uint64,
chainID *big.Int,
) *TxListValidator {
return &TxListValidator{
blockMaxGasLimit: blockMaxGasLimit,
maxTransactionsPerBlock: maxTransactionsPerBlock,
maxBytesPerTxList: maxBytesPerTxList,
minTxGasLimit: minTxGasLimit,
chainID: chainID,
}
}
Expand Down Expand Up @@ -95,13 +91,6 @@ func (v *TxListValidator) isTxListValid(blockID *big.Int, txListBytes []byte) (h
return HintNone, 0
}

for i, tx := range txs {
if tx.Gas() < v.minTxGasLimit {
log.Info("Transaction gas limit too small", "gasLimit", tx.Gas())
return HintTxGasLimitTooSmall, i
}
}

log.Info("Transaction list is valid", "blockID", blockID)
return HintOK, 0
}
3 changes: 0 additions & 3 deletions pkg/tx_list_validator/tx_list_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var (
maxBlocksGasLimit = uint64(50)
maxBlockNumTxs = uint64(11)
maxTxlistBytes = uint64(10000)
minTxGasLimit = uint64(1)
chainID = genesis.Config.ChainID
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
Expand All @@ -36,7 +35,6 @@ func TestValidateTxList(t *testing.T) {
maxBlocksGasLimit,
maxBlockNumTxs,
maxTxlistBytes,
minTxGasLimit,
chainID,
)

Expand All @@ -51,7 +49,6 @@ func TestIsTxListValid(t *testing.T) {
maxBlocksGasLimit,
maxBlockNumTxs,
maxTxlistBytes,
minTxGasLimit,
chainID,
)
tests := []struct {
Expand Down
3 changes: 1 addition & 2 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
p.protocolConfigs = &protocolConfigs

if cfg.MinBlockGasLimit != 0 {
if cfg.MinBlockGasLimit > p.protocolConfigs.BlockMaxGasLimit.Uint64() {
if cfg.MinBlockGasLimit > p.protocolConfigs.BlockMaxGasLimit {
return fmt.Errorf(
"minimal block gas limit too large, set: %d, limit: %d",
cfg.MinBlockGasLimit,
Expand Down Expand Up @@ -194,7 +194,6 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
p.protocolConfigs.MaxTransactionsPerBlock,
p.protocolConfigs.BlockMaxGasLimit,
p.protocolConfigs.MaxBytesPerTxList,
p.protocolConfigs.MinTxGasLimit,
p.locals,
)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {

p.submitProofTxMutex = &sync.Mutex{}
p.txListValidator = txListValidator.NewTxListValidator(
p.protocolConfigs.BlockMaxGasLimit.Uint64(),
p.protocolConfigs.MaxTransactionsPerBlock.Uint64(),
p.protocolConfigs.MaxBytesPerTxList.Uint64(),
p.protocolConfigs.MinTxGasLimit.Uint64(),
p.protocolConfigs.BlockMaxGasLimit,
p.protocolConfigs.MaxTransactionsPerBlock,
p.protocolConfigs.MaxBytesPerTxList,
p.rpc.L2ChainID,
)
p.proverAddress = crypto.PubkeyToAddress(p.cfg.L1ProverPrivKey.PublicKey)
Expand Down
6 changes: 1 addition & 5 deletions testutils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ProposeInvalidTxListBytes(s *ClientTestSuite, proposer Proposer) {

s.Nil(proposer.ProposeTxList(context.Background(), &encoding.TaikoL1BlockMetadataInput{
Beneficiary: proposer.L2SuggestedFeeRecipient(),
GasLimit: uint32(rand.Int63n(configs.BlockMaxGasLimit.Int64())),
GasLimit: uint32(rand.Int63n(int64(configs.BlockMaxGasLimit))),
TxListHash: crypto.Keccak256Hash(invalidTxListBytes),
TxListByteStart: common.Big0,
TxListByteEnd: new(big.Int).SetUint64(uint64(len(invalidTxListBytes))),
Expand Down Expand Up @@ -74,10 +74,6 @@ func ProposeAndInsertEmptyBlocks(

events = append(events, []*bindings.TaikoL1ClientBlockProposed{<-sink, <-sink, <-sink}...)

for _, e := range events {
s.NotEmpty(e.Meta.DepositsRoot)
}

_, isPending, err := s.RpcClient.L1.TransactionByHash(context.Background(), events[len(events)-1].Raw.TxHash)
s.Nil(err)
s.False(isPending)
Expand Down