Skip to content

Commit

Permalink
chore(taiko-client): fix lint errors (#17969)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Aug 24, 2024
1 parent ab601ee commit eedec99
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *AnchorTxConstructor) AssembleAnchorTx(
"baseFee", utils.WeiToGWei(baseFee),
"gasUsed", parentGasUsed,
)

// #nosec G115
return c.rpc.TaikoL2.Anchor(opts, l1Hash, l1Header.Root, l1Height.Uint64(), uint32(parentGasUsed))
}

Expand Down Expand Up @@ -97,7 +97,7 @@ func (c *AnchorTxConstructor) AssembleAnchorV2Tx(
"basefeeAdjustmentQuotient", baseFeeConfig.AdjustmentQuotient,
"baseFee", utils.WeiToGWei(baseFee),
)

// #nosec G115
return c.rpc.TaikoL2.AnchorV2(
opts,
anchorBlockID.Uint64(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (s *Syncer) getBlockPayload(ctx context.Context, blockID uint64) (*engine.E
ts, err := s.rpc.GetTransition(
ctx,
new(big.Int).SetUint64(blockInfo.BlockId),
// #nosec G115
uint32(blockInfo.VerifiedTransitionId.Uint64()),
)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions packages/taiko-client/driver/chain_syncer/blob/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func (s *Syncer) onBlockProposed(
// only happen when testing.
if meta.GetTimestamp() > uint64(time.Now().Unix()) {
log.Warn("Future L2 block, waiting", "L2BlockTimestamp", meta.GetTimestamp(), "now", time.Now().Unix())
// #nosec G115
time.Sleep(time.Until(time.Unix(int64(meta.GetTimestamp()), 0)))
}

Expand Down Expand Up @@ -346,6 +347,7 @@ func (s *Syncer) insertNewHead(
baseFeeInfo, err = s.rpc.TaikoL2.GetBasefee(
&bind.CallOpts{BlockNumber: parent.Number, Context: ctx},
meta.GetRawBlockHeight().Uint64()-1,
// #nosec G115
uint32(parent.GasUsed),
)
if err != nil {
Expand Down Expand Up @@ -403,6 +405,7 @@ func (s *Syncer) insertNewHead(
*meta.GetBaseFeeConfig(),
meta.GetTimestamp()-parent.Time,
parentGasExcess,
// #nosec G115
uint32(parent.GasUsed),
)
if err != nil {
Expand Down Expand Up @@ -631,6 +634,7 @@ func (s *Syncer) retrievePastBlock(
ts, err := s.rpc.GetTransition(
ctx,
new(big.Int).SetUint64(blockInfo.BlockId),
// #nosec G115
uint32(blockInfo.VerifiedTransitionId.Uint64()),
)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (v *TxListDecompressor) TryDecompress(

// If calldata is used, the compressed bytes of the transaction list must be
// less than or equal to maxBytesPerTxList.
// #nosec G115
if !blobUsed && (len(txListBytes) > int(v.maxBytesPerTxList)) {
log.Info("Compressed transactions list binary too large", "length", len(txListBytes), "blockID", blockID)
return []byte{}
Expand Down Expand Up @@ -102,6 +103,7 @@ func (v *TxListDecompressor) TryDecompressHekla(

// If calldata is used, the compressed bytes of the transaction list must be
// less than or equal to maxBytesPerTxList.
// #nosec G115
if !blobUsed && (len(txListBytes) > int(v.maxBytesPerTxList)) {
log.Info("Compressed transactions list binary too large", "length", len(txListBytes), "blockID", blockID)
return []byte{}
Expand Down
2 changes: 2 additions & 0 deletions packages/taiko-client/internal/testutils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (s *ClientTestSuite) ProposeAndInsertValidBlock(
close(sink2)
}()

// #nosec G115
baseFeeInfo, err := s.RPCClient.TaikoL2.GetBasefee(nil, l1Head.Number.Uint64()+1, uint32(l2Head.GasUsed))
s.Nil(err)

Expand Down Expand Up @@ -214,6 +215,7 @@ func (s *ClientTestSuite) ProposeValidBlock(
close(sink)
}()

// #nosec G115
baseFeeInfo, err := s.RPCClient.TaikoL2.GetBasefee(nil, l1Head.Number.Uint64()+1, uint32(l2Head.GasUsed))
s.Nil(err)

Expand Down
1 change: 1 addition & 0 deletions packages/taiko-client/internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func RandUint32(max *big.Int) uint32 {
max.SetUint64(math.MaxUint32)
}
num, _ := rand.Int(rand.Reader, max)
// #nosec G115
return uint32(num.Uint64())
}

Expand Down
3 changes: 2 additions & 1 deletion packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (c *Client) GetPoolContent(
baseFeeInfo, err := c.TaikoL2.GetBasefee(
&bind.CallOpts{Context: ctx},
l1Head.Number.Uint64(),
uint32(l2Head.GasUsed),
uint32(l2Head.GasUsed), // #nosec G115
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -602,6 +602,7 @@ func (c *Client) checkSyncedL1SnippetFromAnchor(
return true, nil
}

// #nosec G115
if parentGasUsed != uint32(parent.GasUsed()) {
log.Info(
"Reorg detected due to parent gas used mismatch",
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/pkg/rpc/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestGetSyncedL1SnippetFromAnchor(t *testing.T) {
l1BlockHash := randomHash()
l1StateRoot := randomHash()
l1Height := randomHash().Big().Uint64()
parentGasUsed := uint32(randomHash().Big().Uint64())
parentGasUsed := uint32(randomHash().Big().Uint64()) // #nosec G115

testAddrPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(encoding.GoldenTouchPrivKey))
require.Nil(t, err)
Expand Down
3 changes: 2 additions & 1 deletion packages/taiko-client/proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (b *BlobTransactionBuilder) Build(
if err != nil {
return nil, err
}
signature[64] = uint8(uint(signature[64])) + 27
signature[64] = signature[64] + 27

var (
to = &b.taikoL1Address
Expand Down Expand Up @@ -128,6 +128,7 @@ func (b *BlobTransactionBuilder) Build(
AnchorBlockId: 0,
Timestamp: 0,
BlobTxListOffset: 0,
// #nosec G115
BlobTxListLength: uint32(len(txListBytes)),
BlobIndex: 0,
}); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (b *CalldataTransactionBuilder) Build(
if err != nil {
return nil, err
}
signature[64] = uint8(uint(signature[64])) + 27
signature[64] = signature[64] + 27

var (
to = &b.taikoL1Address
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/prover/event_handler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ func IsProvingWindowExpired(
now = uint64(time.Now().Unix())
expiredAt = metadata.GetTimestamp() + uint64(provingWindow.Seconds())
)

// #nosec G115
return now > expiredAt, time.Unix(int64(expiredAt), 0), time.Duration(expiredAt-now) * time.Second, nil
}

0 comments on commit eedec99

Please sign in to comment.