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

Commit

Permalink
chore(ci): upgrade golangci to v1.56.2 (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp authored Mar 11, 2024
1 parent 58c2d10 commit 9461b05
Show file tree
Hide file tree
Showing 28 changed files with 39 additions and 87 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ clean:
@rm -rf bin/*

lint:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1 \
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2 \
&& golangci-lint run

test:
Expand Down
2 changes: 1 addition & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (d *Driver) Start() error {
}

// Close closes the driver instance.
func (d *Driver) Close(ctx context.Context) {
func (d *Driver) Close(_ context.Context) {
d.l1HeadSub.Unsubscribe()
d.state.Close()
d.wg.Wait()
Expand Down
2 changes: 1 addition & 1 deletion driver/txlist_fetcher/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewBlobTxListFetcher(rpc *rpc.Client) *BlobFetcher {

func (d *BlobFetcher) Fetch(
ctx context.Context,
tx *types.Transaction,
_ *types.Transaction,
meta *bindings.TaikoDataBlockMetadata,
) ([]byte, error) {
if !meta.BlobUsed {
Expand Down
2 changes: 1 addition & 1 deletion driver/txlist_fetcher/calldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type CalldataFetcher struct{}

func (d *CalldataFetcher) Fetch(
ctx context.Context,
_ context.Context,
tx *types.Transaction,
meta *bindings.TaikoDataBlockMetadata,
) ([]byte, error) {
Expand Down
30 changes: 15 additions & 15 deletions pkg/chain_iterator/block_batch_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func (s *BlockBatchIteratorTestSuite) TestIter() {
StartHeight: common.Big0,
EndHeight: new(big.Int).SetUint64(headHeight),
OnBlocks: func(
ctx context.Context,
_ context.Context,
start, end *types.Header,
updateCurrentFunc UpdateCurrentFunc,
endIterFunc EndIterFunc,
_ UpdateCurrentFunc,
_ EndIterFunc,
) error {
s.Equal(lastEnd.Uint64(), start.Number.Uint64())
lastEnd = end.Number
Expand Down Expand Up @@ -63,9 +63,9 @@ func (s *BlockBatchIteratorTestSuite) TestIterEndFunc() {
StartHeight: common.Big0,
EndHeight: new(big.Int).SetUint64(headHeight),
OnBlocks: func(
ctx context.Context,
_ context.Context,
start, end *types.Header,
updateCurrentFunc UpdateCurrentFunc,
_ UpdateCurrentFunc,
endIterFunc EndIterFunc,
) error {
s.Equal(lastEnd.Uint64(), start.Number.Uint64())
Expand Down Expand Up @@ -93,9 +93,9 @@ func (s *BlockBatchIteratorTestSuite) TestIterCtxCancel() {
StartHeight: common.Big0,
EndHeight: new(big.Int).SetUint64(headHeight),
OnBlocks: func(
ctx context.Context,
_ context.Context,
start, end *types.Header,
updateCurrentFunc UpdateCurrentFunc,
_ UpdateCurrentFunc,
endIterFunc EndIterFunc,
) error {
s.Equal(lastEnd.Uint64(), start.Number.Uint64())
Expand Down Expand Up @@ -128,9 +128,9 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() {
_, err3 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{
Client: s.RPCClient.L1,
OnBlocks: func(
ctx context.Context,
_ context.Context,
start, end *types.Header,
updateCurrentFunc UpdateCurrentFunc,
_ UpdateCurrentFunc,
endIterFunc EndIterFunc,
) error {
s.Equal(lastEnd.Uint64(), start.Number.Uint64())
Expand All @@ -145,9 +145,9 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() {
_, err4 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{
Client: s.RPCClient.L1,
OnBlocks: func(
ctx context.Context,
_ context.Context,
start, end *types.Header,
updateCurrentFunc UpdateCurrentFunc,
_ UpdateCurrentFunc,
endIterFunc EndIterFunc,
) error {
s.Equal(lastEnd.Uint64(), start.Number.Uint64())
Expand All @@ -163,9 +163,9 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() {
_, err6 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{
Client: s.RPCClient.L1,
OnBlocks: func(
ctx context.Context,
_ context.Context,
start, end *types.Header,
updateCurrentFunc UpdateCurrentFunc,
_ UpdateCurrentFunc,
endIterFunc EndIterFunc,
) error {
s.Equal(lastEnd.Uint64(), start.Number.Uint64())
Expand All @@ -181,9 +181,9 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() {
_, err7 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{
Client: s.RPCClient.L1,
OnBlocks: func(
ctx context.Context,
_ context.Context,
start, end *types.Header,
updateCurrentFunc UpdateCurrentFunc,
_ UpdateCurrentFunc,
endIterFunc EndIterFunc,
) error {
s.Equal(lastEnd.Uint64(), start.Number.Uint64())
Expand Down
2 changes: 0 additions & 2 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ func (c *Client) checkSyncedL1SnippetFromAnchor(
}

l1BlockHash, l1StateRoot, l1HeightInAnchor, parentGasUsed, err := c.getSyncedL1SnippetFromAnchor(
ctx,
block.Transactions()[0],
)
if err != nil {
Expand Down Expand Up @@ -576,7 +575,6 @@ func (c *Client) checkSyncedL1SnippetFromAnchor(

// getSyncedL1SnippetFromAnchor parses the anchor transaction calldata, and returns the synced L1 snippet,
func (c *Client) getSyncedL1SnippetFromAnchor(
ctx context.Context,
tx *types.Transaction,
) (
l1BlockHash common.Hash,
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestGetSyncedL1SnippetFromAnchor(t *testing.T) {
syncedL1StateRoot,
syncedL1Height,
syncedParentGasUsed,
err := client.getSyncedL1SnippetFromAnchor(context.Background(), tx)
err := client.getSyncedL1SnippetFromAnchor(tx)
require.Nil(t, err)
require.Equal(t, l1BlockHash, syncedL1BlockHash)
require.Equal(t, l1StateRoot, syncedL1StateRoot)
Expand Down
4 changes: 2 additions & 2 deletions pkg/rpc/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

func TestSubscribeEvent(t *testing.T) {
require.NotNil(t, SubscribeEvent("test", func(ctx context.Context) (event.Subscription, error) {
return event.NewSubscription(func(c <-chan struct{}) error { return nil }), nil
require.NotNil(t, SubscribeEvent("test", func(_ context.Context) (event.Subscription, error) {
return event.NewSubscription(func(_ <-chan struct{}) error { return nil }), nil
}))
}

Expand Down
2 changes: 1 addition & 1 deletion proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (p *Proposer) eventLoop() {
}

// Close closes the proposer instance.
func (p *Proposer) Close(ctx context.Context) {
func (p *Proposer) Close(_ context.Context) {
p.sender.Close()
p.wg.Wait()
}
Expand Down
12 changes: 0 additions & 12 deletions proposer/prover_selector/eth_fee_eoa_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/url"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -89,15 +88,6 @@ func (s *ETHFeeEOASelector) AssignProver(
tierFees []encoding.TierFee,
txListHash common.Hash,
) (*encoding.ProverAssignment, common.Address, *big.Int, error) {
guardianProverAddress, err := s.rpc.TaikoL1.Resolve0(
&bind.CallOpts{Context: ctx},
rpc.StringToBytes32("guardian"),
true,
)
if err != nil {
return nil, common.Address{}, nil, err
}

var (
expiry = uint64(time.Now().Add(s.proposalExpiry).Unix())
fees = make([]encoding.TierFee, len(tierFees))
Expand Down Expand Up @@ -133,7 +123,6 @@ func (s *ETHFeeEOASelector) AssignProver(
s.assignmentHookAddress,
txListHash,
s.requestTimeout,
guardianProverAddress,
)
if err != nil {
log.Warn("Failed to assign prover", "endpoint", endpoint, "error", err)
Expand Down Expand Up @@ -185,7 +174,6 @@ func assignProver(
assignmentHookAddress common.Address,
txListHash common.Hash,
timeout time.Duration,
guardianProverAddress common.Address,
) (*encoding.ProverAssignment, common.Address, error) {
log.Info(
"Attempting to assign prover",
Expand Down
4 changes: 2 additions & 2 deletions prover/anchor_tx_validator/anchor_tx_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func New(taikoL2Address common.Address, chainID *big.Int, rpc *rpc.Client) (*Anc
return &AnchorTxValidator{taikoL2Address, goldenTouchAddress, chainID, rpc}, nil
}

// validateAnchorTx checks whether the given transaction is a valid `TaikoL2.anchor` transaction.
func (v *AnchorTxValidator) ValidateAnchorTx(ctx context.Context, tx *types.Transaction) error {
// ValidateAnchorTx checks whether the given transaction is a valid `TaikoL2.anchor` transaction.
func (v *AnchorTxValidator) ValidateAnchorTx(tx *types.Transaction) error {
if tx.To() == nil || *tx.To() != v.taikoL2Address {
return fmt.Errorf("invalid TaikoL2.anchor transaction to: %s, want: %s", tx.To(), v.taikoL2Address)
}
Expand Down
6 changes: 3 additions & 3 deletions prover/anchor_tx_validator/anchor_tx_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *AnchorTxValidatorTestSuite) TestValidateAnchorTx() {
0,
common.BytesToAddress(testutils.RandomBytes(1024)), common.Big0, 0, common.Big0, []byte{},
)
s.ErrorContains(s.v.ValidateAnchorTx(context.Background(), tx), "invalid TaikoL2.anchor transaction to")
s.ErrorContains(s.v.ValidateAnchorTx(tx), "invalid TaikoL2.anchor transaction to")

// invalid sender
dynamicFeeTxTx := &types.DynamicFeeTx{
Expand All @@ -59,12 +59,12 @@ func (s *AnchorTxValidatorTestSuite) TestValidateAnchorTx() {
tx = types.MustSignNewTx(wrongPrivKey, signer, dynamicFeeTxTx)

s.ErrorContains(
s.v.ValidateAnchorTx(context.Background(), tx), "invalid TaikoL2.anchor transaction sender",
s.v.ValidateAnchorTx(tx), "invalid TaikoL2.anchor transaction sender",
)

// invalid method selector
tx = types.MustSignNewTx(goldenTouchPriKey, signer, dynamicFeeTxTx)
s.ErrorContains(s.v.ValidateAnchorTx(context.Background(), tx), "invalid TaikoL2.anchor transaction selector")
s.ErrorContains(s.v.ValidateAnchorTx(tx), "invalid TaikoL2.anchor transaction selector")
}

func (s *AnchorTxValidatorTestSuite) TestGetAndValidateAnchorTxReceipt() {
Expand Down
4 changes: 2 additions & 2 deletions prover/event_handler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func getBlockProposedEventFromBlockID(
proposedIn *big.Int,
) (e *bindings.TaikoL1ClientBlockProposed, err error) {
callback := func(
ctx context.Context,
_ context.Context,
event *bindings.TaikoL1ClientBlockProposed,
end eventIterator.EndBlockProposedEventIterFunc,
_ eventIterator.EndBlockProposedEventIterFunc,
) error {
// Only filter for exact blockID we want.
if event.BlockId.Cmp(id) != 0 {
Expand Down
2 changes: 0 additions & 2 deletions prover/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func (p *Prover) setApprovalAmount(ctx context.Context, contract common.Address)

// initProofSubmitters initializes the proof submitters from the given tiers in protocol.
func (p *Prover) initProofSubmitters(
ctx context.Context,
sender *sender.Sender,
txBuilder *transaction.ProveBlockTxBuilder,
) error {
Expand Down Expand Up @@ -132,7 +131,6 @@ func (p *Prover) initProofSubmitters(
}

if submitter, err = proofSubmitter.New(
ctx,
p.rpc,
producer,
p.proofGenerationCh,
Expand Down
2 changes: 0 additions & 2 deletions prover/proof_producer/dummy_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package producer

import (
"bytes"
"context"
"math/big"

"github.com/ethereum/go-ethereum/core/types"
Expand All @@ -15,7 +14,6 @@ type DummyProofProducer struct{}

// RequestProof returns a dummy proof to the result channel.
func (o *DummyProofProducer) RequestProof(
ctx context.Context,
opts *ProofRequestOptions,
blockID *big.Int,
meta *bindings.TaikoDataBlockMetadata,
Expand Down
2 changes: 0 additions & 2 deletions prover/proof_producer/dummy_producer_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package producer

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -36,7 +35,6 @@ func TestDummyProducerRequestProof(t *testing.T) {
blockID = common.Big32
)
res, err := producer.RequestProof(
context.Background(),
&ProofRequestOptions{},
blockID,
&bindings.TaikoDataBlockMetadata{},
Expand Down
9 changes: 2 additions & 7 deletions prover/proof_producer/guardian_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewGuardianProofProducer(returnLivenessBond bool) *GuardianProofProducer {

// RequestProof implements the ProofProducer interface.
func (g *GuardianProofProducer) RequestProof(
ctx context.Context,
_ context.Context,
opts *ProofRequestOptions,
blockID *big.Int,
meta *bindings.TaikoDataBlockMetadata,
Expand All @@ -57,7 +57,7 @@ func (g *GuardianProofProducer) RequestProof(
}, nil
}

return g.DummyProofProducer.RequestProof(ctx, opts, blockID, meta, header, g.Tier())
return g.DummyProofProducer.RequestProof(opts, blockID, meta, header, g.Tier())
}

// Tier implements the ProofProducer interface.
Expand All @@ -69,8 +69,3 @@ func (g *GuardianProofProducer) Tier() uint16 {
func (g *GuardianProofProducer) Cancellable() bool {
return false
}

// Cancel cancels an existing proof generation.
func (g *GuardianProofProducer) Cancel(ctx context.Context, blockID *big.Int) error {
return nil
}
9 changes: 2 additions & 7 deletions prover/proof_producer/optimistic_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type OptimisticProofProducer struct{ *DummyProofProducer }

// RequestProof implements the ProofProducer interface.
func (o *OptimisticProofProducer) RequestProof(
ctx context.Context,
_ context.Context,
opts *ProofRequestOptions,
blockID *big.Int,
meta *bindings.TaikoDataBlockMetadata,
Expand All @@ -30,7 +30,7 @@ func (o *OptimisticProofProducer) RequestProof(
"hash", header.Hash(),
)

return o.DummyProofProducer.RequestProof(ctx, opts, blockID, meta, header, o.Tier())
return o.DummyProofProducer.RequestProof(opts, blockID, meta, header, o.Tier())
}

// Tier implements the ProofProducer interface.
Expand All @@ -42,8 +42,3 @@ func (o *OptimisticProofProducer) Tier() uint16 {
func (o *OptimisticProofProducer) Cancellable() bool {
return false
}

// Cancel cancels an existing proof generation.
func (o *OptimisticProofProducer) Cancel(ctx context.Context, blockID *big.Int) error {
return nil
}
3 changes: 0 additions & 3 deletions prover/proof_producer/optimistic_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ func TestProofCancel(t *testing.T) {
header,
)
require.Nil(t, err)

// Cancel the proof request, should return nil
require.Nil(t, optimisticProofProducer.Cancel(context.Background(), blockID))
}

func randHash() common.Hash {
Expand Down
1 change: 0 additions & 1 deletion prover/proof_producer/proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@ type ProofProducer interface {
header *types.Header,
) (*ProofWithHeader, error)
Cancellable() bool
Cancel(ctx context.Context, blockID *big.Int) error
Tier() uint16
}
9 changes: 1 addition & 8 deletions prover/proof_producer/sgx_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (s *SGXProofProducer) RequestProof(
)

if s.DummyProofProducer != nil {
return s.DummyProofProducer.RequestProof(ctx, opts, blockID, meta, header, s.Tier())
return s.DummyProofProducer.RequestProof(opts, blockID, meta, header, s.Tier())
}

proof, err := s.callProverDaemon(ctx, opts)
Expand Down Expand Up @@ -219,10 +219,3 @@ func (s *SGXProofProducer) Tier() uint16 {
func (s *SGXProofProducer) Cancellable() bool {
return false
}

// Cancel cancels an existing proof generation.
//
//nolint:golint
func (s *SGXProofProducer) Cancel(ctx context.Context, blockID *big.Int) error {
return nil
}
Loading

0 comments on commit 9461b05

Please sign in to comment.