From d824d037ba40996391fb7d757e7af6f5f2f8f652 Mon Sep 17 00:00:00 2001 From: maskpp Date: Sun, 14 Jan 2024 10:42:21 +0800 Subject: [PATCH] chore(style): update `golangci` lint (#500) Co-authored-by: David --- .golangci.yml | 56 +++++++++++++++---- bindings/encoding/custom_error.go | 4 +- bindings/encoding/custom_error_test.go | 16 +++--- bindings/encoding/struct.go | 18 +++--- bindings/encoding/struct_test.go | 21 +++---- cmd/flags/common.go | 6 +- cmd/flags/driver.go | 6 +- cmd/flags/proposer.go | 4 +- cmd/flags/prover.go | 2 +- cmd/logger/logger.go | 2 +- cmd/main.go | 2 +- common/utils/utils.go | 27 ++++++++- docs/docs.go | 2 +- .../anchor_tx_constructor.go | 2 +- .../anchor_tx_constructor_test.go | 10 ++-- .../beaconsync/progress_tracker.go | 4 +- .../beaconsync/progress_tracker_test.go | 2 +- driver/chain_syncer/calldata/syncer.go | 6 +- driver/chain_syncer/calldata/syncer_test.go | 33 +++++------ driver/chain_syncer/chain_syncer.go | 4 +- driver/chain_syncer/chain_syncer_test.go | 24 ++++---- driver/config.go | 2 +- driver/config_test.go | 4 +- driver/driver.go | 4 +- driver/driver_test.go | 18 +++--- driver/state/state_test.go | 13 +++-- metrics/metrics.go | 8 ++- pkg/chain_iterator/block_batch_iterator.go | 7 +-- .../block_batch_iterator_test.go | 30 +++++----- pkg/rpc/dial.go | 4 +- pkg/rpc/fallback.go | 2 +- pkg/rpc/methods.go | 19 +++---- pkg/rpc/methods_test.go | 4 +- .../tx_list_validator.go | 2 +- .../tx_list_validator_test.go | 2 +- proposer/config.go | 3 +- proposer/config_test.go | 10 ++-- proposer/proposer.go | 4 +- proposer/proposer_test.go | 10 ++-- .../prover_selector/eth_fee_eoa_selector.go | 4 +- .../eth_fee_eoa_selector_test.go | 4 +- .../anchor_tx_validator.go | 2 +- .../anchor_tx_validator_test.go | 6 +- prover/config.go | 2 +- prover/db/db.go | 4 +- .../guardian_prover_sender/guardian_prover.go | 1 + prover/proof_producer/sgx_producer.go | 32 ++++++----- prover/proof_producer/zkevm_rpcd_producer.go | 8 +-- .../proof_submitter/proof_submitter_test.go | 10 ++-- .../transaction/builder_test.go | 4 +- prover/proof_submitter/transaction/sender.go | 6 +- .../transaction/sender_test.go | 14 ++--- prover/prover.go | 6 +- prover/prover_test.go | 10 ++-- prover/server/server.go | 4 +- prover/server/server_test.go | 10 +++- testutils/helper.go | 44 +++++++-------- testutils/suite.go | 22 ++++---- version/version.go | 11 ++-- 59 files changed, 334 insertions(+), 267 deletions(-) rename pkg/{tx_list_validator => txlistvalidator}/tx_list_validator.go (98%) rename pkg/{tx_list_validator => txlistvalidator}/tx_list_validator_test.go (99%) diff --git a/.golangci.yml b/.golangci.yml index c66aa4509..a3a1da31f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,21 +9,21 @@ run: - bindings/gen_taiko_l2.go issues: - exclude-rules: - - path: bindings/encoding/custom_error.go - linters: - - errorlint - - path: pkg/tx_list_validator/tx_list_validator_test.go - linters: - - typecheck - - path: prover/proof_submitter/merkle_proof_test.go - linters: - - typecheck + # List of regexps of issue texts to exclude. + # + # But independently of this option we use default exclude patterns, + # it can be disabled by `exclude-use-default: false`. + # To list all excluded by default patterns execute `golangci-lint run --help` + # + # Default: https://golangci-lint.run/usage/false-positives/#default-exclusions + exclude: + - abcdef linters: disable-all: true enable: - bidichk + - bodyclose - durationcheck - exportloopref - errcheck @@ -35,11 +35,20 @@ linters: - goimports - gosimple - govet + - gosec + - gofmt - ineffassign + - importas - lll - makezero - misspell + - misspell + - megacheck + - revive + - staticcheck + - sqlclosecheck - staticcheck + - stylecheck - typecheck - unconvert - unused @@ -51,3 +60,30 @@ linters-settings: goconst: min-len: 3 min-occurrences: 6 + +severity: + # Set the default severity for issues. + # + # If severity rules are defined and the issues do not match or no severity is provided to the rule + # this will be the default severity applied. + # Severities should match the supported severity names of the selected out format. + # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity + # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#SeverityLevel + # - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message + # - TeamCity: https://www.jetbrains.com/help/teamcity/service-messages.html#Inspection+Instance + # + # Default: "" + default-severity: error + # If set to true `severity-rules` regular expressions become case-sensitive. + # Default: false + case-sensitive: true + # When a list of severity rules are provided, severity information will be added to lint issues. + # Severity rules have the same filtering capability as exclude rules + # except you are allowed to specify one matcher per severity rule. + # Only affects out formats that support setting severity information. + # + # Default: [] + rules: + - linters: + - dupl + severity: info diff --git a/bindings/encoding/custom_error.go b/bindings/encoding/custom_error.go index 95d89e09b..b3d5846d0 100644 --- a/bindings/encoding/custom_error.go +++ b/bindings/encoding/custom_error.go @@ -40,9 +40,9 @@ func TryParsingCustomError(originalError error) error { // getErrorData tries to parse the actual custom error data from the given error. func getErrorData(err error) string { // Geth node custom errors, the actual struct of this error is go-ethereum's . - gethJsonError, ok := err.(interface{ ErrorData() interface{} }) + gethJSONError, ok := err.(interface{ ErrorData() interface{} }) // nolint: errorlint if ok { - if errData, ok := gethJsonError.ErrorData().(string); ok { + if errData, ok := gethJSONError.ErrorData().(string); ok { return errData } } diff --git a/bindings/encoding/custom_error_test.go b/bindings/encoding/custom_error_test.go index 3ed9526b9..a7cf6d691 100644 --- a/bindings/encoding/custom_error_test.go +++ b/bindings/encoding/custom_error_test.go @@ -9,17 +9,17 @@ import ( "github.com/stretchr/testify/require" ) -type testJsonError struct{} +type testJSONError struct{} -func (e *testJsonError) Error() string { return common.Bytes2Hex(randomBytes(10)) } +func (e *testJSONError) Error() string { return common.Bytes2Hex(randomBytes(10)) } -func (e *testJsonError) ErrorData() interface{} { return "0x8a1c400f" } +func (e *testJSONError) ErrorData() interface{} { return "0x8a1c400f" } -type emptyTestJsonError struct{} +type emptyTestJSONError struct{} -func (e *emptyTestJsonError) Error() string { return "execution reverted" } +func (e *emptyTestJSONError) Error() string { return "execution reverted" } -func (e *emptyTestJsonError) ErrorData() interface{} { return "0x" } +func (e *emptyTestJSONError) ErrorData() interface{} { return "0x" } func TestTryParsingCustomError(t *testing.T) { randomErr := common.Bytes2Hex(randomBytes(10)) @@ -32,11 +32,11 @@ func TestTryParsingCustomError(t *testing.T) { require.True(t, strings.HasPrefix(err.Error(), "L1_INVALID_BLOCK_ID")) - err = TryParsingCustomError(&testJsonError{}) + err = TryParsingCustomError(&testJSONError{}) require.True(t, strings.HasPrefix(err.Error(), "L1_INVALID_BLOCK_ID")) - err = TryParsingCustomError(&emptyTestJsonError{}) + err = TryParsingCustomError(&emptyTestJSONError{}) require.Equal(t, err.Error(), "execution reverted") } diff --git a/bindings/encoding/struct.go b/bindings/encoding/struct.go index 9ee1fddb0..f882ee1fd 100644 --- a/bindings/encoding/struct.go +++ b/bindings/encoding/struct.go @@ -10,13 +10,13 @@ import ( // Tier IDs defined in protocol. var ( - TierOptimisticID uint16 = 100 - TierSgxID uint16 = 200 - TierPseZkevmID uint16 = 300 - TierSgxAndPseZkevmID uint16 = 400 - TierGuardianID uint16 = 1000 - ProtocolTiers []uint16 = []uint16{TierOptimisticID, TierSgxID, TierSgxAndPseZkevmID, TierGuardianID} - AnchorTxGasLimit uint64 = 250_000 + TierOptimisticID uint16 = 100 + TierSgxID uint16 = 200 + TierPseZkevmID uint16 = 300 + TierSgxAndPseZkevmID uint16 = 400 + TierGuardianID uint16 = 1000 + ProtocolTiers = []uint16{TierOptimisticID, TierSgxID, TierSgxAndPseZkevmID, TierGuardianID} + AnchorTxGasLimit uint64 = 250_000 ) // BlockHeader represents an Ethereum block header. @@ -67,7 +67,7 @@ type TierFee struct { type ProverAssignment struct { FeeToken common.Address Expiry uint64 - MaxBlockId uint64 + MaxBlockId uint64 // nolint: revive,stylecheck MaxProposedIn uint64 MetaHash [32]byte TierFees []TierFee @@ -82,7 +82,7 @@ type AssignmentHookInput struct { // ZKEvmProof should be same as PseZkVerifier.ZkEvmProof type ZKEvmProof struct { - VerifierId uint16 + VerifierId uint16 // nolint: revive, stylecheck Zkp []byte PointProof []byte } diff --git a/bindings/encoding/struct_test.go b/bindings/encoding/struct_test.go index 03355fbab..a8713fc44 100644 --- a/bindings/encoding/struct_test.go +++ b/bindings/encoding/struct_test.go @@ -1,9 +1,8 @@ package encoding import ( - cryptoRand "crypto/rand" + "crypto/rand" "math/big" - "math/rand" "testing" "time" @@ -11,6 +10,8 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/stretchr/testify/require" + + "github.com/taikoxyz/taiko-client/common/utils" ) var ( @@ -22,15 +23,15 @@ var ( TxHash: randomHash(), ReceiptHash: randomHash(), Bloom: types.BytesToBloom(randomHash().Bytes()), - Difficulty: new(big.Int).SetUint64(rand.Uint64()), - Number: new(big.Int).SetUint64(rand.Uint64()), - GasLimit: rand.Uint64(), - GasUsed: rand.Uint64(), + Difficulty: new(big.Int).SetUint64(utils.RandUint64(nil)), + Number: new(big.Int).SetUint64(utils.RandUint64(nil)), + GasLimit: utils.RandUint64(nil), + GasUsed: utils.RandUint64(nil), Time: uint64(time.Now().Unix()), Extra: randomHash().Bytes(), MixDigest: randomHash(), - Nonce: types.EncodeNonce(rand.Uint64()), - BaseFee: new(big.Int).SetUint64(rand.Uint64()), + Nonce: types.EncodeNonce(utils.RandUint64(nil)), + BaseFee: new(big.Int).SetUint64(utils.RandUint64(nil)), } ) @@ -102,7 +103,7 @@ func TestToExecutableData(t *testing.T) { // randomHash generates a random blob of data and returns it as a hash. func randomHash() common.Hash { var hash common.Hash - if n, err := cryptoRand.Read(hash[:]); n != common.HashLength || err != nil { + if n, err := rand.Read(hash[:]); n != common.HashLength || err != nil { panic(err) } return hash @@ -111,7 +112,7 @@ func randomHash() common.Hash { // randomBytes generates a random bytes. func randomBytes(size int) (b []byte) { b = make([]byte, size) - if _, err := cryptoRand.Read(b); err != nil { + if _, err := rand.Read(b); err != nil { log.Crit("Generate random bytes error", "error", err) } return diff --git a/cmd/flags/common.go b/cmd/flags/common.go index a868b5a47..76822e22e 100644 --- a/cmd/flags/common.go +++ b/cmd/flags/common.go @@ -67,7 +67,7 @@ var ( Value: 3, Category: loggingCategory, } - LogJson = &cli.BoolFlag{ + LogJSON = &cli.BoolFlag{ Name: "log.json", Usage: "Format logs with JSON", Category: loggingCategory, @@ -116,7 +116,7 @@ var ( } ) -// All common flags. +// CommonFlags All common flags. var CommonFlags = []cli.Flag{ // Required L1WSEndpoint, @@ -124,7 +124,7 @@ var CommonFlags = []cli.Flag{ TaikoL2Address, // Optional Verbosity, - LogJson, + LogJSON, MetricsEnabled, MetricsAddr, MetricsPort, diff --git a/cmd/flags/driver.go b/cmd/flags/driver.go index 3b02a3e04..15a75f3d3 100644 --- a/cmd/flags/driver.go +++ b/cmd/flags/driver.go @@ -38,19 +38,19 @@ var ( Value: 1 * time.Hour, Category: driverCategory, } - CheckPointSyncUrl = &cli.StringFlag{ + CheckPointSyncURL = &cli.StringFlag{ Name: "p2p.checkPointSyncUrl", Usage: "HTTP RPC endpoint of another synced L2 execution engine node", Category: driverCategory, } ) -// All driver flags. +// DriverFlags All driver flags. var DriverFlags = MergeFlags(CommonFlags, []cli.Flag{ L2WSEndpoint, L2AuthEndpoint, JWTSecret, P2PSyncVerifiedBlocks, P2PSyncTimeout, - CheckPointSyncUrl, + CheckPointSyncURL, }) diff --git a/cmd/flags/proposer.go b/cmd/flags/proposer.go index c381652f2..a7d252ffa 100644 --- a/cmd/flags/proposer.go +++ b/cmd/flags/proposer.go @@ -77,7 +77,7 @@ var ( ExtraData = &cli.StringFlag{ Name: "extraData", Usage: "Block extra data set by the proposer (default = client version)", - Value: version.VersionWithCommit(), + Value: version.CommitVersion(), Category: proposerCategory, } // Transactions pool related. @@ -123,7 +123,7 @@ var ( } ) -// All proposer flags. +// ProposerFlags All proposer flags. var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{ L2HTTPEndpoint, TaikoTokenAddress, diff --git a/cmd/flags/prover.go b/cmd/flags/prover.go index c25c94e3d..8e34fde8a 100644 --- a/cmd/flags/prover.go +++ b/cmd/flags/prover.go @@ -185,7 +185,7 @@ var ( } ) -// All prover flags. +// ProverFlags All prover flags. var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{ L1HTTPEndpoint, L2WSEndpoint, diff --git a/cmd/logger/logger.go b/cmd/logger/logger.go index 2b7ec7f53..61239e856 100644 --- a/cmd/logger/logger.go +++ b/cmd/logger/logger.go @@ -14,7 +14,7 @@ func InitLogger(c *cli.Context) { slogVerbosity = log.FromLegacyLevel(c.Int(flags.Verbosity.Name)) ) - if c.Bool(flags.LogJson.Name) { + if c.Bool(flags.LogJSON.Name) { glogger := log.NewGlogHandler(log.NewGlogHandler(log.JSONHandler(os.Stdout))) glogger.Verbosity(slogVerbosity) log.SetDefault(log.NewLogger(glogger)) diff --git a/cmd/main.go b/cmd/main.go index b0efdd54c..46eeacc0b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -19,7 +19,7 @@ func main() { app.Name = "Taiko Clients" app.Usage = "The taiko client software command line interface" app.Copyright = "Copyright 2021-2022 Taiko Labs" - app.Version = version.VersionWithCommit() + app.Version = version.CommitVersion() app.Description = "Client software implementation in Golang for Taiko protocol" app.Authors = []*cli.Author{{Name: "Taiko Labs", Email: "info@taiko.xyz"}} app.EnableBashCompletion = true diff --git a/common/utils/utils.go b/common/utils/utils.go index 5dceaffdc..3c6bc88dc 100644 --- a/common/utils/utils.go +++ b/common/utils/utils.go @@ -1,6 +1,31 @@ package utils -import "github.com/modern-go/reflect2" +import ( + "crypto/rand" + "math/big" + + "github.com/ethereum/go-ethereum/common/math" + "github.com/modern-go/reflect2" +) + +func RandUint64(max *big.Int) uint64 { + if max == nil { + max = new(big.Int) + max.SetUint64(math.MaxUint64) + } + num, _ := rand.Int(rand.Reader, max) + + return num.Uint64() +} + +func RandUint32(max *big.Int) uint32 { + if max == nil { + max = new(big.Int) + max.SetUint64(math.MaxUint32) + } + num, _ := rand.Int(rand.Reader, max) + return uint32(num.Uint64()) +} // IsNil checks if the interface is empty. func IsNil(i interface{}) bool { diff --git a/docs/docs.go b/docs/docs.go index efb2d4e63..5456bfcba 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -19,7 +19,7 @@ const docTemplate = `{ "name": "MIT", "url": "https://github.com/taikoxyz/taiko-client/blob/main/LICENSE.md" }, - "version": "{{.Version}}" + "version": "{{.JsonRPC}}" }, "host": "{{.Host}}", "basePath": "{{.BasePath}}", diff --git a/driver/anchor_tx_constructor/anchor_tx_constructor.go b/driver/anchor_tx_constructor/anchor_tx_constructor.go index 29c11670a..feec1605d 100644 --- a/driver/anchor_tx_constructor/anchor_tx_constructor.go +++ b/driver/anchor_tx_constructor/anchor_tx_constructor.go @@ -1,4 +1,4 @@ -package anchorTxConstructor +package anchortxconstructor import ( "context" diff --git a/driver/anchor_tx_constructor/anchor_tx_constructor_test.go b/driver/anchor_tx_constructor/anchor_tx_constructor_test.go index b6dff0e08..f0a00fed1 100644 --- a/driver/anchor_tx_constructor/anchor_tx_constructor_test.go +++ b/driver/anchor_tx_constructor/anchor_tx_constructor_test.go @@ -1,4 +1,4 @@ -package anchorTxConstructor +package anchortxconstructor import ( "context" @@ -23,11 +23,11 @@ type AnchorTxConstructorTestSuite struct { func (s *AnchorTxConstructorTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() c, err := New( - s.RpcClient, + s.RPCClient, common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")), ) s.Nil(err) - head, err := s.RpcClient.L1.BlockByNumber(context.Background(), nil) + head, err := s.RPCClient.L1.BlockByNumber(context.Background(), nil) s.Nil(err) s.l1Height = head.Number() s.l1Hash = head.Hash() @@ -45,11 +45,11 @@ func (s *AnchorTxConstructorTestSuite) TestAssembleAnchorTx() { } func (s *AnchorTxConstructorTestSuite) TestNewAnchorTransactor() { - goldenTouchAddress, err := s.RpcClient.TaikoL2.GOLDENTOUCHADDRESS(nil) + goldenTouchAddress, err := s.RPCClient.TaikoL2.GOLDENTOUCHADDRESS(nil) s.Nil(err) c, err := New( - s.RpcClient, + s.RPCClient, common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")), ) s.Nil(err) diff --git a/driver/chain_syncer/beaconsync/progress_tracker.go b/driver/chain_syncer/beaconsync/progress_tracker.go index 85dcf24c3..520896205 100644 --- a/driver/chain_syncer/beaconsync/progress_tracker.go +++ b/driver/chain_syncer/beaconsync/progress_tracker.go @@ -131,7 +131,7 @@ func (t *SyncProgressTracker) track(ctx context.Context) { } } -// UpdateMeta updates the inner beacon sync meta data. +// UpdateMeta updates the inner beacon sync metadata. func (t *SyncProgressTracker) UpdateMeta(id *big.Int, blockHash common.Hash) { t.mutex.Lock() defer t.mutex.Unlock() @@ -147,7 +147,7 @@ func (t *SyncProgressTracker) UpdateMeta(id *big.Int, blockHash common.Hash) { t.lastSyncedVerifiedBlockHash = blockHash } -// ClearMeta cleans the inner beacon sync meta data. +// ClearMeta cleans the inner beacon sync metadata. func (t *SyncProgressTracker) ClearMeta() { t.mutex.Lock() defer t.mutex.Unlock() diff --git a/driver/chain_syncer/beaconsync/progress_tracker_test.go b/driver/chain_syncer/beaconsync/progress_tracker_test.go index 470ef26d7..c84c9f564 100644 --- a/driver/chain_syncer/beaconsync/progress_tracker_test.go +++ b/driver/chain_syncer/beaconsync/progress_tracker_test.go @@ -19,7 +19,7 @@ type BeaconSyncProgressTrackerTestSuite struct { func (s *BeaconSyncProgressTrackerTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - s.t = NewSyncProgressTracker(s.RpcClient.L2, 30*time.Second) + s.t = NewSyncProgressTracker(s.RPCClient.L2, 30*time.Second) } func (s *BeaconSyncProgressTrackerTestSuite) TestSyncProgressed() { diff --git a/driver/chain_syncer/calldata/syncer.go b/driver/chain_syncer/calldata/syncer.go index 62ec16efb..e17c1d286 100644 --- a/driver/chain_syncer/calldata/syncer.go +++ b/driver/chain_syncer/calldata/syncer.go @@ -22,7 +22,7 @@ import ( "github.com/taikoxyz/taiko-client/metrics" eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator" "github.com/taikoxyz/taiko-client/pkg/rpc" - txListValidator "github.com/taikoxyz/taiko-client/pkg/tx_list_validator" + txListValidator "github.com/taikoxyz/taiko-client/pkg/txlistvalidator" ) var ( @@ -78,7 +78,7 @@ func NewSyncer( } // ProcessL1Blocks fetches all `TaikoL1.BlockProposed` events between given -// L1 block heights, and then tries inserting them into L2 execution engine's block chain. +// L1 block heights, and then tries inserting them into L2 execution engine's blockchain. func (s *Syncer) ProcessL1Blocks(ctx context.Context, l1End *types.Header) error { firstTry := true for firstTry || s.reorgDetectedFlag { @@ -218,7 +218,7 @@ func (s *Syncer) onBlockProposed( parent, err = s.rpc.L2.HeaderByHash(ctx, s.progressTracker.LastSyncedVerifiedBlockHash()) } else { - parent, err = s.rpc.L2ParentByBlockId(ctx, event.BlockId) + parent, err = s.rpc.L2ParentByBlockID(ctx, event.BlockId) } if err != nil { diff --git a/driver/chain_syncer/calldata/syncer_test.go b/driver/chain_syncer/calldata/syncer_test.go index 518d61992..e4be9b2da 100644 --- a/driver/chain_syncer/calldata/syncer_test.go +++ b/driver/chain_syncer/calldata/syncer_test.go @@ -3,7 +3,6 @@ package calldata import ( "context" "math/big" - "math/rand" "os" "testing" "time" @@ -17,6 +16,8 @@ import ( "github.com/taikoxyz/taiko-client/driver/state" "github.com/taikoxyz/taiko-client/proposer" "github.com/taikoxyz/taiko-client/testutils" + + "github.com/taikoxyz/taiko-client/common/utils" ) type CalldataSyncerTestSuite struct { @@ -28,14 +29,14 @@ type CalldataSyncerTestSuite struct { func (s *CalldataSyncerTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - state, err := state.New(context.Background(), s.RpcClient) + state, err := state.New(context.Background(), s.RPCClient) s.Nil(err) syncer, err := NewSyncer( context.Background(), - s.RpcClient, + s.RPCClient, state, - beaconsync.NewSyncProgressTracker(s.RpcClient.L2, 1*time.Hour), + beaconsync.NewSyncProgressTracker(s.RPCClient.L2, 1*time.Hour), common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")), ) s.Nil(err) @@ -73,7 +74,7 @@ func (s *CalldataSyncerTestSuite) TestCancelNewSyncer() { cancel() syncer, err := NewSyncer( ctx, - s.RpcClient, + s.RPCClient, s.s.state, s.s.progressTracker, common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")), @@ -124,7 +125,7 @@ func (s *CalldataSyncerTestSuite) TestInsertNewHead() { Coinbase: common.BytesToAddress(testutils.RandomBytes(1024)), BlobHash: testutils.RandomHash(), Difficulty: testutils.RandomHash(), - GasLimit: rand.Uint32(), + GasLimit: utils.RandUint32(nil), Timestamp: uint64(time.Now().Unix()), }, }, @@ -144,18 +145,18 @@ func (s *CalldataSyncerTestSuite) TestTreasuryIncomeAllAnchors() { treasury := common.HexToAddress(os.Getenv("TREASURY")) s.NotZero(treasury.Big().Uint64()) - balance, err := s.RpcClient.L2.BalanceAt(context.Background(), treasury, nil) + balance, err := s.RPCClient.L2.BalanceAt(context.Background(), treasury, nil) s.Nil(err) - headBefore, err := s.RpcClient.L2.BlockNumber(context.Background()) + headBefore, err := s.RPCClient.L2.BlockNumber(context.Background()) s.Nil(err) testutils.ProposeAndInsertEmptyBlocks(&s.ClientTestSuite, s.p, s.s) - headAfter, err := s.RpcClient.L2.BlockNumber(context.Background()) + headAfter, err := s.RPCClient.L2.BlockNumber(context.Background()) s.Nil(err) - balanceAfter, err := s.RpcClient.L2.BalanceAt(context.Background(), treasury, nil) + balanceAfter, err := s.RPCClient.L2.BalanceAt(context.Background(), treasury, nil) s.Nil(err) s.Greater(headAfter, headBefore) @@ -166,19 +167,19 @@ func (s *CalldataSyncerTestSuite) TestTreasuryIncome() { treasury := common.HexToAddress(os.Getenv("TREASURY")) s.NotZero(treasury.Big().Uint64()) - balance, err := s.RpcClient.L2.BalanceAt(context.Background(), treasury, nil) + balance, err := s.RPCClient.L2.BalanceAt(context.Background(), treasury, nil) s.Nil(err) - headBefore, err := s.RpcClient.L2.BlockNumber(context.Background()) + headBefore, err := s.RPCClient.L2.BlockNumber(context.Background()) s.Nil(err) testutils.ProposeAndInsertEmptyBlocks(&s.ClientTestSuite, s.p, s.s) testutils.ProposeAndInsertValidBlock(&s.ClientTestSuite, s.p, s.s) - headAfter, err := s.RpcClient.L2.BlockNumber(context.Background()) + headAfter, err := s.RPCClient.L2.BlockNumber(context.Background()) s.Nil(err) - balanceAfter, err := s.RpcClient.L2.BalanceAt(context.Background(), treasury, nil) + balanceAfter, err := s.RPCClient.L2.BalanceAt(context.Background(), treasury, nil) s.Nil(err) s.Greater(headAfter, headBefore) @@ -186,7 +187,7 @@ func (s *CalldataSyncerTestSuite) TestTreasuryIncome() { var hasNoneAnchorTxs bool for i := headBefore + 1; i <= headAfter; i++ { - block, err := s.RpcClient.L2.BlockByNumber(context.Background(), new(big.Int).SetUint64(i)) + block, err := s.RPCClient.L2.BlockByNumber(context.Background(), new(big.Int).SetUint64(i)) s.Nil(err) s.GreaterOrEqual(block.Transactions().Len(), 1) s.Greater(block.BaseFee().Uint64(), uint64(0)) @@ -197,7 +198,7 @@ func (s *CalldataSyncerTestSuite) TestTreasuryIncome() { } hasNoneAnchorTxs = true - receipt, err := s.RpcClient.L2.TransactionReceipt(context.Background(), tx.Hash()) + receipt, err := s.RPCClient.L2.TransactionReceipt(context.Background(), tx.Hash()) s.Nil(err) fee := new(big.Int).Mul(block.BaseFee(), new(big.Int).SetUint64(receipt.GasUsed)) diff --git a/driver/chain_syncer/chain_syncer.go b/driver/chain_syncer/chain_syncer.go index 1995ff67c..b07041039 100644 --- a/driver/chain_syncer/chain_syncer.go +++ b/driver/chain_syncer/chain_syncer.go @@ -1,4 +1,4 @@ -package chainSyncer +package chainsyncer import ( "context" @@ -124,7 +124,7 @@ func (s *L2ChainSyncer) AheadOfProtocolVerifiedHead() bool { // we also mark the triggered P2P sync progress as finished to prevent a potential `InsertBlockWithoutSetHead` in // execution engine, which may cause errors since we do not pass all transactions in ExecutePayload when calling // NewPayloadV1. - verifiedHeightToCompare -= 1 + verifiedHeightToCompare-- } if s.state.GetL2Head().Number.Uint64() < verifiedHeightToCompare { diff --git a/driver/chain_syncer/chain_syncer_test.go b/driver/chain_syncer/chain_syncer_test.go index a64c133b9..03094fd06 100644 --- a/driver/chain_syncer/chain_syncer_test.go +++ b/driver/chain_syncer/chain_syncer_test.go @@ -1,4 +1,4 @@ -package chainSyncer +package chainsyncer import ( "bytes" @@ -29,12 +29,12 @@ type ChainSyncerTestSuite struct { func (s *ChainSyncerTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - state, err := state.New(context.Background(), s.RpcClient) + state, err := state.New(context.Background(), s.RPCClient) s.Nil(err) syncer, err := New( context.Background(), - s.RpcClient, + s.RPCClient, state, false, 1*time.Hour, @@ -78,7 +78,7 @@ func (s *ChainSyncerTestSuite) TestGetInnerSyncers() { } func (s *ChainSyncerTestSuite) TestSync() { - head, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + head, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) s.Nil(s.s.Sync(head)) } @@ -92,13 +92,13 @@ func (s *ChainSyncerTestSuite) TestAheadOfProtocolVerifiedHead2() { // generate transactopts to interact with TaikoL1 contract with. privKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) - opts, err := bind.NewKeyedTransactorWithChainID(privKey, s.RpcClient.L1ChainID) + opts, err := bind.NewKeyedTransactorWithChainID(privKey, s.RPCClient.L1ChainID) s.Nil(err) - head, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + head, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) - l2Head, err := s.RpcClient.L2.HeaderByNumber(context.Background(), nil) + l2Head, err := s.RPCClient.L2.HeaderByNumber(context.Background(), nil) s.Nil(err) s.Equal("test", string(bytes.TrimRight(l2Head.Extra, "\x00"))) log.Info("L1HeaderByNumber head", "number", head.Number) @@ -114,10 +114,10 @@ func (s *ChainSyncerTestSuite) TestAheadOfProtocolVerifiedHead2() { s.Nil(err) s.NotNil(tx) - head2, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + head2, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) - l2Head2, err := s.RpcClient.L2.HeaderByNumber(context.Background(), nil) + l2Head2, err := s.RPCClient.L2.HeaderByNumber(context.Background(), nil) s.Nil(err) log.Info("L1HeaderByNumber head2", "number", head2.Number) @@ -133,15 +133,15 @@ func TestChainSyncerTestSuite(t *testing.T) { func (s *ChainSyncerTestSuite) TakeSnapshot() { // record snapshot state to revert to before changes - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &s.snapshotID, "evm_snapshot")) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &s.snapshotID, "evm_snapshot")) } func (s *ChainSyncerTestSuite) RevertSnapshot() { // revert to the snapshot state so protocol configs are unaffected var revertRes bool - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", s.snapshotID)) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", s.snapshotID)) s.True(revertRes) - s.Nil(rpc.SetHead(context.Background(), s.RpcClient.L2RawRPC, common.Big0)) + s.Nil(rpc.SetHead(context.Background(), s.RPCClient.L2RawRPC, common.Big0)) } func (s *ChainSyncerTestSuite) TestAheadOfProtocolVerifiedHead() { diff --git a/driver/config.go b/driver/config.go index 646946cc2..443a2a673 100644 --- a/driver/config.go +++ b/driver/config.go @@ -36,7 +36,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { var ( p2pSyncVerifiedBlocks = c.Bool(flags.P2PSyncVerifiedBlocks.Name) - l2CheckPoint = c.String(flags.CheckPointSyncUrl.Name) + l2CheckPoint = c.String(flags.CheckPointSyncURL.Name) ) if p2pSyncVerifiedBlocks && len(l2CheckPoint) == 0 { diff --git a/driver/config_test.go b/driver/config_test.go index 82836dc21..c48bdc1ca 100644 --- a/driver/config_test.go +++ b/driver/config_test.go @@ -50,7 +50,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() { "--" + flags.P2PSyncTimeout.Name, "120s", "--" + flags.RPCTimeout.Name, "5s", "--" + flags.P2PSyncVerifiedBlocks.Name, - "--" + flags.CheckPointSyncUrl.Name, "http://localhost:8545", + "--" + flags.CheckPointSyncURL.Name, "http://localhost:8545", })) } @@ -84,7 +84,7 @@ func (s *DriverTestSuite) SetupApp() *cli.App { &cli.BoolFlag{Name: flags.P2PSyncVerifiedBlocks.Name}, &cli.DurationFlag{Name: flags.P2PSyncTimeout.Name}, &cli.DurationFlag{Name: flags.RPCTimeout.Name}, - &cli.StringFlag{Name: flags.CheckPointSyncUrl.Name}, + &cli.StringFlag{Name: flags.CheckPointSyncURL.Name}, } app.Action = func(ctx *cli.Context) error { _, err := NewConfigFromCliContext(ctx) diff --git a/driver/driver.go b/driver/driver.go index 119535ec3..0f48a726d 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -40,7 +40,7 @@ type Driver struct { wg sync.WaitGroup } -// New initializes the given driver instance based on the command line flags. +// InitFromCli New initializes the given driver instance based on the command line flags. func (d *Driver) InitFromCli(ctx context.Context, c *cli.Context) error { cfg, err := NewConfigFromCliContext(c) if err != nil { @@ -164,7 +164,7 @@ func (d *Driver) eventLoop() { // doSync fetches all `BlockProposed` events emitted from local // L1 sync cursor to the L1 head, and then applies all corresponding -// L2 blocks into node's local block chain. +// L2 blocks into node's local blockchain. func (d *Driver) doSync() error { // Check whether the application is closing. if d.ctx.Err() != nil { diff --git a/driver/driver_test.go b/driver/driver_test.go index 4f939dd48..b602d0934 100644 --- a/driver/driver_test.go +++ b/driver/driver_test.go @@ -122,7 +122,7 @@ func (s *DriverTestSuite) TestProcessL1Blocks() { func (s *DriverTestSuite) TestCheckL1ReorgToHigherFork() { var testnetL1SnapshotID string - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &testnetL1SnapshotID, "evm_snapshot")) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &testnetL1SnapshotID, "evm_snapshot")) s.NotEmpty(testnetL1SnapshotID) l1Head1, err := s.d.rpc.L1.HeaderByNumber(context.Background(), nil) @@ -142,13 +142,13 @@ func (s *DriverTestSuite) TestCheckL1ReorgToHigherFork() { s.Greater(l2Head2.Number.Uint64(), l2Head1.Number.Uint64()) s.Greater(l1Head2.Number.Uint64(), l1Head1.Number.Uint64()) - reorged, _, _, err := s.RpcClient.CheckL1ReorgFromL2EE(context.Background(), l2Head2.Number) + reorged, _, _, err := s.RPCClient.CheckL1ReorgFromL2EE(context.Background(), l2Head2.Number) s.Nil(err) s.False(reorged) // Reorg back to l2Head1 var revertRes bool - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", testnetL1SnapshotID)) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", testnetL1SnapshotID)) s.True(revertRes) l1Head3, err := s.d.rpc.L1.HeaderByNumber(context.Background(), nil) @@ -181,7 +181,7 @@ func (s *DriverTestSuite) TestCheckL1ReorgToHigherFork() { func (s *DriverTestSuite) TestCheckL1ReorgToLowerFork() { var testnetL1SnapshotID string - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &testnetL1SnapshotID, "evm_snapshot")) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &testnetL1SnapshotID, "evm_snapshot")) s.NotEmpty(testnetL1SnapshotID) l1Head1, err := s.d.rpc.L1.HeaderByNumber(context.Background(), nil) @@ -201,13 +201,13 @@ func (s *DriverTestSuite) TestCheckL1ReorgToLowerFork() { s.Greater(l2Head2.Number.Uint64(), l2Head1.Number.Uint64()) s.Greater(l1Head2.Number.Uint64(), l1Head1.Number.Uint64()) - reorged, _, _, err := s.RpcClient.CheckL1ReorgFromL2EE(context.Background(), l2Head2.Number) + reorged, _, _, err := s.RPCClient.CheckL1ReorgFromL2EE(context.Background(), l2Head2.Number) s.Nil(err) s.False(reorged) // Reorg back to l2Head1 var revertRes bool - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", testnetL1SnapshotID)) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", testnetL1SnapshotID)) s.True(revertRes) l1Head3, err := s.d.rpc.L1.HeaderByNumber(context.Background(), nil) @@ -237,7 +237,7 @@ func (s *DriverTestSuite) TestCheckL1ReorgToLowerFork() { func (s *DriverTestSuite) TestCheckL1ReorgToSameHeightFork() { var testnetL1SnapshotID string - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &testnetL1SnapshotID, "evm_snapshot")) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &testnetL1SnapshotID, "evm_snapshot")) s.NotEmpty(testnetL1SnapshotID) l1Head1, err := s.d.rpc.L1.HeaderByNumber(context.Background(), nil) @@ -257,13 +257,13 @@ func (s *DriverTestSuite) TestCheckL1ReorgToSameHeightFork() { s.Greater(l2Head2.Number.Uint64(), l2Head1.Number.Uint64()) s.Greater(l1Head2.Number.Uint64(), l1Head1.Number.Uint64()) - reorged, _, _, err := s.RpcClient.CheckL1ReorgFromL2EE(context.Background(), l2Head2.Number) + reorged, _, _, err := s.RPCClient.CheckL1ReorgFromL2EE(context.Background(), l2Head2.Number) s.Nil(err) s.False(reorged) // Reorg back to l2Head1 var revertRes bool - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", testnetL1SnapshotID)) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", testnetL1SnapshotID)) s.True(revertRes) l1Head3, err := s.d.rpc.L1.HeaderByNumber(context.Background(), nil) diff --git a/driver/state/state_test.go b/driver/state/state_test.go index a9d969c67..fad9d9b5a 100644 --- a/driver/state/state_test.go +++ b/driver/state/state_test.go @@ -3,13 +3,14 @@ package state import ( "context" "math/big" - "math/rand" "testing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/suite" "github.com/taikoxyz/taiko-client/testutils" + + "github.com/taikoxyz/taiko-client/common/utils" ) type DriverStateTestSuite struct { @@ -19,13 +20,13 @@ type DriverStateTestSuite struct { func (s *DriverStateTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - state, err := New(context.Background(), s.RpcClient) + state, err := New(context.Background(), s.RPCClient) s.Nil(err) s.s = state } func (s *DriverStateTestSuite) TestVerifyL2Block() { - head, err := s.RpcClient.L2.HeaderByNumber(context.Background(), nil) + head, err := s.RPCClient.L2.HeaderByNumber(context.Background(), nil) s.Nil(err) s.Nil(s.s.VerifyL2Block(context.Background(), head.Number, head.Hash())) @@ -50,7 +51,7 @@ func (s *DriverStateTestSuite) TestClose() { } func (s *DriverStateTestSuite) TestGetL2Head() { - testHeight := rand.Uint64() + testHeight := utils.RandUint64(nil) s.s.setL2Head(nil) s.s.setL2Head(&types.Header{Number: new(big.Int).SetUint64(testHeight)}) @@ -63,7 +64,7 @@ func (s *DriverStateTestSuite) TestSubL1HeadsFeed() { } func (s *DriverStateTestSuite) TestGetSyncedHeaderID() { - l2Genesis, err := s.RpcClient.L2.BlockByNumber(context.Background(), common.Big0) + l2Genesis, err := s.RPCClient.L2.BlockByNumber(context.Background(), common.Big0) s.Nil(err) id, err := s.s.getSyncedHeaderID(context.Background(), s.s.GenesisL1Height.Uint64(), l2Genesis.Hash()) @@ -74,7 +75,7 @@ func (s *DriverStateTestSuite) TestGetSyncedHeaderID() { func (s *DriverStateTestSuite) TestNewDriverContextErr() { ctx, cancel := context.WithCancel(context.Background()) cancel() - state, err := New(ctx, s.RpcClient) + state, err := New(ctx, s.RPCClient) s.Nil(state) s.ErrorContains(err, "context canceled") } diff --git a/metrics/metrics.go b/metrics/metrics.go index f6e9b87b7..1eb58413f 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -5,6 +5,7 @@ import ( "net" "net/http" "strconv" + "time" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" @@ -54,9 +55,10 @@ func Serve(ctx context.Context, c *cli.Context) error { strconv.Itoa(c.Int(flags.MetricsPort.Name)), ) - server := &http.Server{ - Addr: address, - Handler: prometheus.Handler(metrics.DefaultRegistry), + server := http.Server{ + ReadHeaderTimeout: time.Minute, + Addr: address, + Handler: prometheus.Handler(metrics.DefaultRegistry), } go func() { diff --git a/pkg/chain_iterator/block_batch_iterator.go b/pkg/chain_iterator/block_batch_iterator.go index 14a89ff39..e8631b90f 100644 --- a/pkg/chain_iterator/block_batch_iterator.go +++ b/pkg/chain_iterator/block_batch_iterator.go @@ -99,10 +99,9 @@ func NewBlockBatchIterator(ctx context.Context, cfg *BlockBatchIteratorConfig) ( var endHeader *types.Header if cfg.Reverse && cfg.EndHeight == nil { return nil, fmt.Errorf("missing end height") - } else { - if endHeader, err = cfg.Client.HeaderByNumber(ctx, cfg.EndHeight); err != nil { - return nil, fmt.Errorf("failed to get end header, height: %s, error: %w", cfg.EndHeight, err) - } + } + if endHeader, err = cfg.Client.HeaderByNumber(ctx, cfg.EndHeight); err != nil { + return nil, fmt.Errorf("failed to get end header, height: %s, error: %w", cfg.EndHeight, err) } iterator := &BlockBatchIterator{ diff --git a/pkg/chain_iterator/block_batch_iterator_test.go b/pkg/chain_iterator/block_batch_iterator_test.go index 064199a31..82669e37a 100644 --- a/pkg/chain_iterator/block_batch_iterator_test.go +++ b/pkg/chain_iterator/block_batch_iterator_test.go @@ -19,14 +19,14 @@ type BlockBatchIteratorTestSuite struct { func (s *BlockBatchIteratorTestSuite) TestIter() { var maxBlocksReadPerEpoch uint64 = 2 - headHeight, err := s.RpcClient.L1.BlockNumber(context.Background()) + headHeight, err := s.RPCClient.L1.BlockNumber(context.Background()) s.Nil(err) s.Greater(headHeight, uint64(0)) lastEnd := common.Big0 iter, err := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, MaxBlocksReadPerEpoch: &maxBlocksReadPerEpoch, StartHeight: common.Big0, EndHeight: new(big.Int).SetUint64(headHeight), @@ -50,17 +50,17 @@ func (s *BlockBatchIteratorTestSuite) TestIter() { func (s *BlockBatchIteratorTestSuite) TestIterReverse() { var ( maxBlocksReadPerEpoch uint64 = 2 - startHeight uint64 = 0 + startHeight uint64 ) - headHeight, err := s.RpcClient.L1.BlockNumber(context.Background()) + headHeight, err := s.RPCClient.L1.BlockNumber(context.Background()) s.Nil(err) s.Greater(headHeight, startHeight) lastStart := new(big.Int).SetUint64(headHeight) iter, err := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, MaxBlocksReadPerEpoch: &maxBlocksReadPerEpoch, StartHeight: new(big.Int).SetUint64(startHeight), EndHeight: new(big.Int).SetUint64(headHeight), @@ -85,14 +85,14 @@ func (s *BlockBatchIteratorTestSuite) TestIterReverse() { func (s *BlockBatchIteratorTestSuite) TestIterEndFunc() { var maxBlocksReadPerEpoch uint64 = 2 - headHeight, err := s.RpcClient.L1.BlockNumber(context.Background()) + headHeight, err := s.RPCClient.L1.BlockNumber(context.Background()) s.Nil(err) s.Greater(headHeight, maxBlocksReadPerEpoch) lastEnd := common.Big0 iter, err := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, MaxBlocksReadPerEpoch: &maxBlocksReadPerEpoch, StartHeight: common.Big0, EndHeight: new(big.Int).SetUint64(headHeight), @@ -116,13 +116,13 @@ func (s *BlockBatchIteratorTestSuite) TestIterEndFunc() { func (s *BlockBatchIteratorTestSuite) TestIterCtxCancel() { lastEnd := common.Big0 - headHeight, err := s.RpcClient.L1.BlockNumber(context.Background()) + headHeight, err := s.RPCClient.L1.BlockNumber(context.Background()) s.Nil(err) ctx, cancel := context.WithCancel(context.Background()) retry := 5 * time.Second itr, err := NewBlockBatchIterator(ctx, &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, MaxBlocksReadPerEpoch: nil, RetryInterval: &retry, StartHeight: common.Big0, @@ -154,14 +154,14 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() { s.ErrorContains(err, "invalid RPC client") _, err2 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, OnBlocks: nil, }) s.ErrorContains(err2, "invalid callback") lastEnd := common.Big0 _, err3 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, OnBlocks: func( ctx context.Context, start, end *types.Header, @@ -178,7 +178,7 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() { s.ErrorContains(err3, "invalid start height") _, err4 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, OnBlocks: func( ctx context.Context, start, end *types.Header, @@ -196,7 +196,7 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() { s.ErrorContains(err4, "start height (2) > end height (0)") _, err5 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, OnBlocks: func( ctx context.Context, start, end *types.Header, @@ -215,7 +215,7 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() { s.ErrorContains(err5, "missing end height") _, err6 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, OnBlocks: func( ctx context.Context, start, end *types.Header, @@ -233,7 +233,7 @@ func (s *BlockBatchIteratorTestSuite) TestBlockBatchIteratorConfig() { s.ErrorContains(err6, "failed to get start header") _, err7 := NewBlockBatchIterator(context.Background(), &BlockBatchIteratorConfig{ - Client: s.RpcClient.L1, + Client: s.RPCClient.L1, OnBlocks: func( ctx context.Context, start, end *types.Header, diff --git a/pkg/rpc/dial.go b/pkg/rpc/dial.go index 964c8b59b..00dc933e9 100644 --- a/pkg/rpc/dial.go +++ b/pkg/rpc/dial.go @@ -78,12 +78,12 @@ func DialEngineClientWithBackoff( // DialEngineClient initializes an RPC connection with authentication headers. // Taken from https://github.com/prysmaticlabs/prysm/blob/v2.1.4/beacon-chain/execution/rpc_connection.go#L151 -func DialEngineClient(ctx context.Context, endpointUrl string, jwtSecret string) (*rpc.Client, error) { +func DialEngineClient(ctx context.Context, endpointURL string, jwtSecret string) (*rpc.Client, error) { ctxWithTimeout, cancel := ctxWithTimeoutOrDefault(ctx, defaultTimeout) defer cancel() endpoint := network.Endpoint{ - Url: endpointUrl, + Url: endpointURL, Auth: network.AuthorizationData{ Method: authorization.Bearer, Value: jwtSecret, diff --git a/pkg/rpc/fallback.go b/pkg/rpc/fallback.go index 454e9067b..6237f2105 100644 --- a/pkg/rpc/fallback.go +++ b/pkg/rpc/fallback.go @@ -11,7 +11,7 @@ import ( var ( //lint:ignore ST1005 allow `errMaxPriorityFeePerGasNotFound` to be capitalized. errMaxPriorityFeePerGasNotFound = errors.New( - "Method eth_maxPriorityFeePerGas not found", + "method eth_maxPriorityFeePerGas not found", ) // FallbackGasTipCap is the default fallback gasTipCap used when we are diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index 27ff54d65..3de804a60 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -60,7 +60,7 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error { return err } - for iter.Next() { + if iter.Next() { l2GenesisHash := iter.Event.BlockHash log.Debug("Genesis hash", "node", nodeGenesis.Hash(), "TaikoL1", common.BytesToHash(l2GenesisHash[:])) @@ -72,11 +72,8 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error { nodeGenesis.Hash(), common.BytesToHash(l2GenesisHash[:]), ) - } else { - return nil } } - log.Warn("Genesis block not found in TaikoL1") return nil @@ -162,26 +159,26 @@ func (c *Client) GetGenesisL1Header(ctx context.Context) (*types.Header, error) return c.L1.HeaderByNumber(ctxWithTimeout, new(big.Int).SetUint64(stateVars.A.GenesisHeight)) } -// L2ParentByBlockId fetches the block header from L2 execution engine with the largest block id that +// L2ParentByBlockID fetches the block header from L2 execution engine with the largest block id that // smaller than the given `blockId`. -func (c *Client) L2ParentByBlockId(ctx context.Context, blockID *big.Int) (*types.Header, error) { +func (c *Client) L2ParentByBlockID(ctx context.Context, blockID *big.Int) (*types.Header, error) { ctxWithTimeout, cancel := ctxWithTimeoutOrDefault(ctx, defaultTimeout) defer cancel() - parentBlockId := new(big.Int).Sub(blockID, common.Big1) + parentBlockID := new(big.Int).Sub(blockID, common.Big1) - log.Debug("Get parent block by block ID", "parentBlockId", parentBlockId) + log.Debug("Get parent block by block ID", "parentBlockID", parentBlockID) - if parentBlockId.Cmp(common.Big0) == 0 { + if parentBlockID.Cmp(common.Big0) == 0 { return c.L2.HeaderByNumber(ctxWithTimeout, common.Big0) } - l1Origin, err := c.L2.L1OriginByID(ctxWithTimeout, parentBlockId) + l1Origin, err := c.L2.L1OriginByID(ctxWithTimeout, parentBlockID) if err != nil { return nil, err } - log.Debug("Parent block L1 origin", "l1Origin", l1Origin, "parentBlockId", parentBlockId) + log.Debug("Parent block L1 origin", "l1Origin", l1Origin, "parentBlockID", parentBlockID) return c.L2.HeaderByHash(ctxWithTimeout, l1Origin.L2BlockHash) } diff --git a/pkg/rpc/methods_test.go b/pkg/rpc/methods_test.go index 9f4c1f449..9272ced7d 100644 --- a/pkg/rpc/methods_test.go +++ b/pkg/rpc/methods_test.go @@ -45,11 +45,11 @@ func TestLatestL2KnownL1Header(t *testing.T) { func TestL2ParentByBlockId(t *testing.T) { client := newTestClient(t) - header, err := client.L2ParentByBlockId(context.Background(), common.Big1) + header, err := client.L2ParentByBlockID(context.Background(), common.Big1) require.Nil(t, err) require.Zero(t, header.Number.Uint64()) - _, err = client.L2ParentByBlockId(context.Background(), common.Big2) + _, err = client.L2ParentByBlockID(context.Background(), common.Big2) require.NotNil(t, err) } diff --git a/pkg/tx_list_validator/tx_list_validator.go b/pkg/txlistvalidator/tx_list_validator.go similarity index 98% rename from pkg/tx_list_validator/tx_list_validator.go rename to pkg/txlistvalidator/tx_list_validator.go index 639117535..53bfe2bd3 100644 --- a/pkg/tx_list_validator/tx_list_validator.go +++ b/pkg/txlistvalidator/tx_list_validator.go @@ -1,4 +1,4 @@ -package tx_list_validator +package txlistvalidator import ( "math/big" diff --git a/pkg/tx_list_validator/tx_list_validator_test.go b/pkg/txlistvalidator/tx_list_validator_test.go similarity index 99% rename from pkg/tx_list_validator/tx_list_validator_test.go rename to pkg/txlistvalidator/tx_list_validator_test.go index b8bc10220..282866d79 100644 --- a/pkg/tx_list_validator/tx_list_validator_test.go +++ b/pkg/txlistvalidator/tx_list_validator_test.go @@ -1,4 +1,4 @@ -package tx_list_validator +package txlistvalidator import ( "crypto/rand" diff --git a/proposer/config.go b/proposer/config.go index 91b8c87b3..ecb08ac7c 100644 --- a/proposer/config.go +++ b/proposer/config.go @@ -73,9 +73,8 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { for _, account := range strings.Split(c.String(flags.TxPoolLocals.Name), ",") { if trimmed := strings.TrimSpace(account); !common.IsHexAddress(trimmed) { return nil, fmt.Errorf("invalid account in --txpool.locals: %s", trimmed) - } else { - localAddresses = append(localAddresses, common.HexToAddress(account)) } + localAddresses = append(localAddresses, common.HexToAddress(account)) } } diff --git a/proposer/config_test.go b/proposer/config_test.go index 09740d757..0a265b1cb 100644 --- a/proposer/config_test.go +++ b/proposer/config_test.go @@ -26,10 +26,10 @@ var ( ) func (s *ProposerTestSuite) TestNewConfigFromCliContext() { - goldenTouchAddress, err := s.RpcClient.TaikoL2.GOLDENTOUCHADDRESS(nil) + goldenTouchAddress, err := s.RPCClient.TaikoL2.GOLDENTOUCHADDRESS(nil) s.Nil(err) - goldenTouchPrivKey, err := s.RpcClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) + goldenTouchPrivKey, err := s.RPCClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) s.Nil(err) app := s.SetupApp() @@ -101,7 +101,7 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContextPrivKeyErr() { } func (s *ProposerTestSuite) TestNewConfigFromCliContextTxPoolLocalsErr() { - goldenTouchPrivKey, err := s.RpcClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) + goldenTouchPrivKey, err := s.RPCClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) s.Nil(err) app := s.SetupApp() @@ -116,10 +116,10 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContextTxPoolLocalsErr() { } func (s *ProposerTestSuite) TestNewConfigFromCliContextReplMultErr() { - goldenTouchAddress, err := s.RpcClient.TaikoL2.GOLDENTOUCHADDRESS(nil) + goldenTouchAddress, err := s.RPCClient.TaikoL2.GOLDENTOUCHADDRESS(nil) s.Nil(err) - goldenTouchPrivKey, err := s.RpcClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) + goldenTouchPrivKey, err := s.RPCClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) s.Nil(err) app := s.SetupApp() diff --git a/proposer/proposer.go b/proposer/proposer.go index 1168d1bcd..02f107377 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -370,7 +370,7 @@ func (p *Proposer) sendProposeBlockTx( } } - var parentMetaHash [32]byte = [32]byte{} + var parentMetaHash = [32]byte{} if p.cfg.IncludeParentMetaHash { state, err := p.rpc.TaikoL1.State(&bind.CallOpts{Context: ctx}) if err != nil { @@ -525,7 +525,7 @@ func (p *Proposer) updateProposingTicker() { duration = *p.proposingInterval } else { // Random number between 12 - 120 - randomSeconds := rand.Intn(120-11) + 12 + randomSeconds := rand.Intn(120-11) + 12 // nolint: gosec duration = time.Duration(randomSeconds) * time.Second } diff --git a/proposer/proposer_test.go b/proposer/proposer_test.go index 4832af01f..44385d402 100644 --- a/proposer/proposer_test.go +++ b/proposer/proposer_test.go @@ -87,7 +87,7 @@ func (s *ProposerTestSuite) TestProposeOp() { to := common.BytesToAddress(testutils.RandomBytes(32)) tx := types.NewTx(&types.DynamicFeeTx{ - ChainID: s.RpcClient.L2ChainID, + ChainID: s.RPCClient.L2ChainID, Nonce: nonce, GasTipCap: common.Big0, GasFeeCap: new(big.Int).SetUint64(baseFee.Uint64() * 2), @@ -152,13 +152,13 @@ func (s *ProposerTestSuite) TestSendProposeBlockTx() { context.Background(), s.p.rpc.L1, s.p.proposerPrivKey, - s.RpcClient.L1ChainID, + s.RPCClient.L1ChainID, fee, ) s.Nil(err) s.Greater(opts.GasTipCap.Uint64(), uint64(0)) - nonce, err := s.RpcClient.L1.PendingNonceAt(context.Background(), s.p.proposerAddress) + nonce, err := s.RPCClient.L1.PendingNonceAt(context.Background(), s.p.proposerAddress) s.Nil(err) tx := types.NewTransaction( @@ -173,9 +173,9 @@ func (s *ProposerTestSuite) TestSendProposeBlockTx() { s.SetL1Automine(false) defer s.SetL1Automine(true) - signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(s.RpcClient.L1ChainID), s.p.proposerPrivKey) + signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(s.RPCClient.L1ChainID), s.p.proposerPrivKey) s.Nil(err) - s.Nil(s.RpcClient.L1.SendTransaction(context.Background(), signedTx)) + s.Nil(s.RPCClient.L1.SendTransaction(context.Background(), signedTx)) var emptyTxs []types.Transaction encoded, err := rlp.EncodeToBytes(emptyTxs) diff --git a/proposer/prover_selector/eth_fee_eoa_selector.go b/proposer/prover_selector/eth_fee_eoa_selector.go index 28c14bdee..448952c95 100644 --- a/proposer/prover_selector/eth_fee_eoa_selector.go +++ b/proposer/prover_selector/eth_fee_eoa_selector.go @@ -204,7 +204,7 @@ func assignProver( } result = server.ProposeBlockResponse{} ) - requestUrl, err := url.JoinPath(endpoint.String(), "/assignment") + requestURL, err := url.JoinPath(endpoint.String(), "/assignment") if err != nil { return nil, common.Address{}, err } @@ -218,7 +218,7 @@ func assignProver( SetHeader("Accept", "application/json"). SetBody(reqBody). SetResult(&result). - Post(requestUrl) + Post(requestURL) if err != nil { return nil, common.Address{}, err } diff --git a/proposer/prover_selector/eth_fee_eoa_selector_test.go b/proposer/prover_selector/eth_fee_eoa_selector_test.go index 70428806b..aef8cc4bb 100644 --- a/proposer/prover_selector/eth_fee_eoa_selector_test.go +++ b/proposer/prover_selector/eth_fee_eoa_selector_test.go @@ -27,12 +27,12 @@ func (s *ProverSelectorTestSuite) SetupTest() { s.Nil(err) s.proverAddress = crypto.PubkeyToAddress(l1ProverPrivKey.PublicKey) - protocolConfigs, err := s.RpcClient.TaikoL1.GetConfig(nil) + protocolConfigs, err := s.RPCClient.TaikoL1.GetConfig(nil) s.Nil(err) s.s, err = NewETHFeeEOASelector( &protocolConfigs, - s.RpcClient, + s.RPCClient, common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), []encoding.TierFee{}, diff --git a/prover/anchor_tx_validator/anchor_tx_validator.go b/prover/anchor_tx_validator/anchor_tx_validator.go index de2febb37..912688229 100644 --- a/prover/anchor_tx_validator/anchor_tx_validator.go +++ b/prover/anchor_tx_validator/anchor_tx_validator.go @@ -1,4 +1,4 @@ -package anchorTxValidator +package anchortxvalidator import ( "context" diff --git a/prover/anchor_tx_validator/anchor_tx_validator_test.go b/prover/anchor_tx_validator/anchor_tx_validator_test.go index 0414986d2..73ab2c6fa 100644 --- a/prover/anchor_tx_validator/anchor_tx_validator_test.go +++ b/prover/anchor_tx_validator/anchor_tx_validator_test.go @@ -1,4 +1,4 @@ -package anchorTxValidator +package anchortxvalidator import ( "context" @@ -20,7 +20,7 @@ type AnchorTxValidatorTestSuite struct { func (s *AnchorTxValidatorTestSuite) SetupTest() { s.ClientTestSuite.SetupTest() - validator, err := New(common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), s.RpcClient.L2ChainID, s.RpcClient) + validator, err := New(common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), s.RPCClient.L2ChainID, s.RPCClient) s.Nil(err) s.v = validator } @@ -29,7 +29,7 @@ func (s *AnchorTxValidatorTestSuite) TestValidateAnchorTx() { wrongPrivKey, err := crypto.HexToECDSA("2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200") s.Nil(err) - goldenTouchPrivKey, err := s.RpcClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) + goldenTouchPrivKey, err := s.RPCClient.TaikoL2.GOLDENTOUCHPRIVATEKEY(nil) s.Nil(err) // 0x92954368afd3caa1f3ce3ead0069c1af414054aefe1ef9aeacc1bf426222ce38 diff --git a/prover/config.go b/prover/config.go index fcdc1cca9..f3d8a4a28 100644 --- a/prover/config.go +++ b/prover/config.go @@ -94,7 +94,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { proveBlockMaxTxGasTipCap = new(big.Int).SetUint64(c.Uint64(flags.ProveBlockMaxTxGasTipCap.Name)) } - var allowance *big.Int = common.Big0 + var allowance = common.Big0 if c.IsSet(flags.Allowance.Name) { amt, ok := new(big.Int).SetString(c.String(flags.Allowance.Name), 10) if !ok { diff --git a/prover/db/db.go b/prover/db/db.go index 811707e94..a44b03db3 100644 --- a/prover/db/db.go +++ b/prover/db/db.go @@ -9,7 +9,7 @@ import ( ) var ( - BlockKeyPrefix = "block-" + blockKeyPrefix = "block-" separator = "++" ) @@ -24,7 +24,7 @@ type SignedBlockData struct { func BuildBlockKey(blockTimestamp uint64) []byte { return bytes.Join( [][]byte{ - []byte(BlockKeyPrefix), + []byte(blockKeyPrefix), []byte(strconv.Itoa(int(blockTimestamp))), }, []byte{}) } diff --git a/prover/guardian_prover_sender/guardian_prover.go b/prover/guardian_prover_sender/guardian_prover.go index 9b555393e..abcd3cf27 100644 --- a/prover/guardian_prover_sender/guardian_prover.go +++ b/prover/guardian_prover_sender/guardian_prover.go @@ -74,6 +74,7 @@ func (s *GuardianProverBlockSender) post(ctx context.Context, route string, req if err != nil { return err } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return fmt.Errorf( diff --git a/prover/proof_producer/sgx_producer.go b/prover/proof_producer/sgx_producer.go index 3cb3087ac..1ae81b64c 100644 --- a/prover/proof_producer/sgx_producer.go +++ b/prover/proof_producer/sgx_producer.go @@ -30,13 +30,13 @@ type SGXProofProducer struct { // SGXRequestProofBody represents the JSON body for requesting the proof. type SGXRequestProofBody struct { - JsonRPC string `json:"jsonrpc"` + JsonRPC string `json:"jsonrpc"` //nolint:revive,stylecheck ID *big.Int `json:"id"` Method string `json:"method"` Params []*SGXRequestProofBodyParam `json:"params"` } -// SGXRequestProofBody represents the JSON body of RequestProofBody's `param` field. +// SGXRequestProofBodyParam represents the JSON body of RequestProofBody's `param` field. type SGXRequestProofBodyParam struct { Type string `json:"type"` Block *big.Int `json:"block"` @@ -48,7 +48,7 @@ type SGXRequestProofBodyParam struct { // SGXRequestProofBodyResponse represents the JSON body of the response of the proof requests. type SGXRequestProofBodyResponse struct { - JsonRPC string `json:"jsonrpc"` + JsonRPC string `json:"jsonrpc"` //nolint:revive,stylecheck ID *big.Int `json:"id"` Result *RaikoHostOutput `json:"result"` Error *struct { @@ -77,7 +77,7 @@ func NewSGXProducer( } // RequestProof implements the ProofProducer interface. -func (p *SGXProofProducer) RequestProof( +func (s *SGXProofProducer) RequestProof( ctx context.Context, opts *ProofRequestOptions, blockID *big.Int, @@ -93,11 +93,11 @@ func (p *SGXProofProducer) RequestProof( "hash", header.Hash(), ) - if p.DummyProofProducer != nil { - return p.DummyProofProducer.RequestProof(ctx, opts, blockID, meta, header, p.Tier(), resultCh) + if s.DummyProofProducer != nil { + return s.DummyProofProducer.RequestProof(ctx, opts, blockID, meta, header, s.Tier(), resultCh) } - proof, err := p.callProverDaemon(ctx, opts) + proof, err := s.callProverDaemon(ctx, opts) if err != nil { return err } @@ -109,7 +109,7 @@ func (p *SGXProofProducer) RequestProof( Proof: proof, Degree: 0, Opts: opts, - Tier: p.Tier(), + Tier: s.Tier(), } metrics.ProverSgxProofGeneratedCounter.Inc(1) @@ -118,7 +118,7 @@ func (p *SGXProofProducer) RequestProof( } // callProverDaemon keeps polling the proverd service to get the requested proof. -func (p *SGXProofProducer) callProverDaemon(ctx context.Context, opts *ProofRequestOptions) ([]byte, error) { +func (s *SGXProofProducer) callProverDaemon(ctx context.Context, opts *ProofRequestOptions) ([]byte, error) { var ( proof []byte start = time.Now() @@ -127,9 +127,9 @@ func (p *SGXProofProducer) callProverDaemon(ctx context.Context, opts *ProofRequ if ctx.Err() != nil { return nil } - output, err := p.requestProof(opts) + output, err := s.requestProof(opts) if err != nil { - log.Error("Failed to request proof", "height", opts.BlockID, "err", err, "endpoint", p.RaikoHostEndpoint) + log.Error("Failed to request proof", "height", opts.BlockID, "err", err, "endpoint", s.RaikoHostEndpoint) return err } @@ -161,7 +161,7 @@ func (p *SGXProofProducer) callProverDaemon(ctx context.Context, opts *ProofRequ } // requestProof sends a RPC request to proverd to try to get the requested proof. -func (p *SGXProofProducer) requestProof(opts *ProofRequestOptions) (*RaikoHostOutput, error) { +func (s *SGXProofProducer) requestProof(opts *ProofRequestOptions) (*RaikoHostOutput, error) { reqBody := SGXRequestProofBody{ JsonRPC: "2.0", ID: common.Big1, @@ -169,8 +169,8 @@ func (p *SGXProofProducer) requestProof(opts *ProofRequestOptions) (*RaikoHostOu Params: []*SGXRequestProofBodyParam{{ Type: "Sgx", Block: opts.BlockID, - L2RPC: p.L2Endpoint, - L1RPC: p.L1Endpoint, + L2RPC: s.L2Endpoint, + L1RPC: s.L1Endpoint, Prover: opts.ProverAddress.Hex()[2:], Graffiti: opts.Graffiti, }}, @@ -181,7 +181,7 @@ func (p *SGXProofProducer) requestProof(opts *ProofRequestOptions) (*RaikoHostOu return nil, err } - res, err := http.Post(p.RaikoHostEndpoint, "application/json", bytes.NewBuffer(jsonValue)) + res, err := http.Post(s.RaikoHostEndpoint, "application/json", bytes.NewBuffer(jsonValue)) if err != nil { return nil, err } @@ -219,6 +219,8 @@ func (s *SGXProofProducer) Cancellable() bool { } // Cancel cancels an existing proof generation. +// +//nolint:golint func (s *SGXProofProducer) Cancel(ctx context.Context, blockID *big.Int) error { return nil } diff --git a/prover/proof_producer/zkevm_rpcd_producer.go b/prover/proof_producer/zkevm_rpcd_producer.go index 062a1308f..3ffbee032 100644 --- a/prover/proof_producer/zkevm_rpcd_producer.go +++ b/prover/proof_producer/zkevm_rpcd_producer.go @@ -40,13 +40,13 @@ type ZkevmRpcdProducer struct { // RequestProofBody represents the JSON body for requesting the proof. type RequestProofBody struct { - JsonRPC string `json:"jsonrpc"` + JsonRPC string `json:"jsonrpc"` //nolint:revive,stylecheck ID *big.Int `json:"id"` Method string `json:"method"` Params []*RequestProofBodyParam `json:"params"` } -// RequestProofBody represents the JSON body of RequestProofBody's `param` field. +// RequestProofBodyParam represents the JSON body of RequestProofBody's `param` field. type RequestProofBodyParam struct { Circuit string `json:"circuit"` Block *big.Int `json:"block"` @@ -78,7 +78,7 @@ type RequestMetaData struct { ParentMetaHash string `json:"parent_metahash"` } -// RequestProofBody represents the JSON body of RequestProofBody.Param's `protocol_instance` field. +// ProtocolInstance represents the JSON body of RequestProofBody.Param's `protocol_instance` field. type ProtocolInstance struct { L1SignalService string `json:"l1_signal_service"` L2SignalService string `json:"l2_signal_service"` @@ -101,7 +101,7 @@ type ProtocolInstance struct { // RequestProofBodyResponse represents the JSON body of the response of the proof requests. type RequestProofBodyResponse struct { - JsonRPC string `json:"jsonrpc"` + JsonRPC string `json:"jsonrpc"` //nolint:revive,stylecheck ID *big.Int `json:"id"` Result *RpcdOutput `json:"result"` Error *struct { diff --git a/prover/proof_submitter/proof_submitter_test.go b/prover/proof_submitter/proof_submitter_test.go index d484e2b52..f7efcc811 100644 --- a/prover/proof_submitter/proof_submitter_test.go +++ b/prover/proof_submitter/proof_submitter_test.go @@ -39,7 +39,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { s.proofCh = make(chan *proofProducer.ProofWithHeader, 1024) s.submitter, err = New( - s.RpcClient, + s.RPCClient, &proofProducer.OptimisticProofProducer{}, s.proofCh, common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")), @@ -54,7 +54,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { ) s.Nil(err) s.contester, err = NewProofContester( - s.RpcClient, + s.RPCClient, l1ProverPrivKey, nil, 2, @@ -67,14 +67,14 @@ func (s *ProofSubmitterTestSuite) SetupTest() { s.Nil(err) // Init calldata syncer - testState, err := state.New(context.Background(), s.RpcClient) + testState, err := state.New(context.Background(), s.RPCClient) s.Nil(err) - tracker := beaconsync.NewSyncProgressTracker(s.RpcClient.L2, 30*time.Second) + tracker := beaconsync.NewSyncProgressTracker(s.RPCClient.L2, 30*time.Second) s.calldataSyncer, err = calldata.NewSyncer( context.Background(), - s.RpcClient, + s.RPCClient, testState, tracker, common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")), diff --git a/prover/proof_submitter/transaction/builder_test.go b/prover/proof_submitter/transaction/builder_test.go index 55023536b..47d62a352 100644 --- a/prover/proof_submitter/transaction/builder_test.go +++ b/prover/proof_submitter/transaction/builder_test.go @@ -8,11 +8,11 @@ import ( ) func (s *TransactionTestSuite) TestGetProveBlocksTxOpts() { - optsL1, err := getProveBlocksTxOpts(context.Background(), s.RpcClient.L1, s.RpcClient.L1ChainID, s.TestAddrPrivKey) + optsL1, err := getProveBlocksTxOpts(context.Background(), s.RPCClient.L1, s.RPCClient.L1ChainID, s.TestAddrPrivKey) s.Nil(err) s.Greater(optsL1.GasTipCap.Uint64(), uint64(0)) - optsL2, err := getProveBlocksTxOpts(context.Background(), s.RpcClient.L2, s.RpcClient.L2ChainID, s.TestAddrPrivKey) + optsL2, err := getProveBlocksTxOpts(context.Background(), s.RPCClient.L2, s.RPCClient.L2ChainID, s.TestAddrPrivKey) s.Nil(err) s.Greater(optsL2.GasTipCap.Uint64(), uint64(0)) } diff --git a/prover/proof_submitter/transaction/sender.go b/prover/proof_submitter/transaction/sender.go index e2b16660e..fa9501065 100644 --- a/prover/proof_submitter/transaction/sender.go +++ b/prover/proof_submitter/transaction/sender.go @@ -172,12 +172,12 @@ func (s *Sender) validateProof(ctx context.Context, proofWithHeader *proofProduc ) return false, err } - latestVerifiedId := stateVars.B.LastVerifiedBlockId - if new(big.Int).SetUint64(latestVerifiedId).Cmp(proofWithHeader.BlockID) >= 0 { + latestVerifiedID := stateVars.B.LastVerifiedBlockId + if new(big.Int).SetUint64(latestVerifiedID).Cmp(proofWithHeader.BlockID) >= 0 { log.Info( "Block is already verified, skip current proof submission", "blockID", proofWithHeader.BlockID.Uint64(), - "latestVerifiedId", latestVerifiedId, + "latestVerifiedID", latestVerifiedID, ) return false, nil } diff --git a/prover/proof_submitter/transaction/sender_test.go b/prover/proof_submitter/transaction/sender_test.go index 51663dfb4..d14dc614c 100644 --- a/prover/proof_submitter/transaction/sender_test.go +++ b/prover/proof_submitter/transaction/sender_test.go @@ -34,8 +34,8 @@ func (s *TransactionTestSuite) SetupTest() { l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) - s.sender = NewSender(s.RpcClient, 5*time.Second, nil, 1*time.Minute) - s.builder = NewProveBlockTxBuilder(s.RpcClient, l1ProverPrivKey, nil, common.Big256, common.Big2) + s.sender = NewSender(s.RPCClient, 5*time.Second, nil, 1*time.Minute) + s.builder = NewProveBlockTxBuilder(s.RPCClient, l1ProverPrivKey, nil, common.Big256, common.Big2) } func (s *TransactionTestSuite) TestIsSubmitProofTxErrorRetryable() { @@ -46,9 +46,9 @@ func (s *TransactionTestSuite) TestIsSubmitProofTxErrorRetryable() { } func (s *TransactionTestSuite) TestSendTxWithBackoff() { - l1Head, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + l1Head, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) - l1HeadChild, err := s.RpcClient.L1.HeaderByNumber(context.Background(), new(big.Int).Sub(l1Head.Number, common.Big1)) + l1HeadChild, err := s.RPCClient.L1.HeaderByNumber(context.Background(), new(big.Int).Sub(l1Head.Number, common.Big1)) s.Nil(err) meta := &bindings.TaikoDataBlockMetadata{L1Height: l1HeadChild.Number.Uint64(), L1Hash: l1HeadChild.Hash()} s.NotNil(s.sender.Send( @@ -71,17 +71,17 @@ func (s *TransactionTestSuite) TestSendTxWithBackoff() { Opts: &proofProducer.ProofRequestOptions{EventL1Hash: l1Head.Hash()}, }, func(nonce *big.Int) (*types.Transaction, error) { - height, err := s.RpcClient.L1.BlockNumber(context.Background()) + height, err := s.RPCClient.L1.BlockNumber(context.Background()) s.Nil(err) var block *types.Block for { - block, err = s.RpcClient.L1.BlockByNumber(context.Background(), new(big.Int).SetUint64(height)) + block, err = s.RPCClient.L1.BlockByNumber(context.Background(), new(big.Int).SetUint64(height)) s.Nil(err) if block.Transactions().Len() != 0 { break } - height -= 1 + height-- } return block.Transactions()[0], nil diff --git a/prover/prover.go b/prover/prover.go index 586c92a35..95e897653 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -286,7 +286,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { TaikoL1Address: p.cfg.TaikoL1Address, AssignmentHookAddress: p.cfg.AssignmentHookAddress, ProposeConcurrencyGuard: p.proposeConcurrencyGuard, - Rpc: p.rpc, + RPC: p.rpc, ProtocolConfigs: &protocolConfigs, LivenessBond: protocolConfigs.LivenessBond, IsGuardian: p.IsGuardianProver(), @@ -930,7 +930,7 @@ func (p *Prover) onTransitionContested(ctx context.Context, e *bindings.TaikoL1C // onBlockVerified update the latestVerified block in current state, and cancels // the block being proven if it's verified. -func (p *Prover) onBlockVerified(ctx context.Context, e *bindings.TaikoL1ClientBlockVerified) error { +func (p *Prover) onBlockVerified(_ context.Context, e *bindings.TaikoL1ClientBlockVerified) error { metrics.ProverLatestVerifiedIDGauge.Update(e.BlockId.Int64()) p.latestVerifiedL1Height = e.Raw.BlockNumber @@ -1086,7 +1086,7 @@ func (p *Prover) isValidProof( blockHash common.Hash, signalRoot common.Hash, ) (bool, error) { - parent, err := p.rpc.L2ParentByBlockId(ctx, blockID) + parent, err := p.rpc.L2ParentByBlockID(ctx, blockID) if err != nil { return false, err } diff --git a/prover/prover_test.go b/prover/prover_test.go index 2260eac93..da58e702a 100644 --- a/prover/prover_test.go +++ b/prover/prover_test.go @@ -41,11 +41,11 @@ func (s *ProverTestSuite) SetupTest() { l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) - proverServerUrl := testutils.LocalRandomProverEndpoint() - port, err := strconv.Atoi(proverServerUrl.Port()) + proverServerURL := testutils.LocalRandomProverEndpoint() + port, err := strconv.Atoi(proverServerURL.Port()) s.Nil(err) - decimal, err := s.RpcClient.TaikoToken.Decimals(nil) + decimal, err := s.RPCClient.TaikoToken.Decimals(nil) s.Nil(err) allowance := new(big.Int).Exp(big.NewInt(1_000_000_100), new(big.Int).SetUint64(uint64(decimal)), nil) @@ -78,7 +78,7 @@ func (s *ProverTestSuite) SetupTest() { p.srv = testutils.NewTestProverServer( &s.ClientTestSuite, l1ProverPrivKey, - proverServerUrl, + proverServerURL, ) p.guardianProverSender = guardianproversender.New( @@ -126,7 +126,7 @@ func (s *ProverTestSuite) SetupTest() { ProposeInterval: &proposeInterval, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, - ProverEndpoints: []*url.URL{proverServerUrl}, + ProverEndpoints: []*url.URL{proverServerURL}, OptimisticTierFee: common.Big256, SgxTierFee: common.Big256, PseZkevmTierFee: common.Big256, diff --git a/prover/server/server.go b/prover/server/server.go index 5a543fbe1..ae07f84a4 100644 --- a/prover/server/server.go +++ b/prover/server/server.go @@ -64,7 +64,7 @@ type NewProverServerOpts struct { ProposeConcurrencyGuard chan struct{} TaikoL1Address common.Address AssignmentHookAddress common.Address - Rpc *rpc.Client + RPC *rpc.Client ProtocolConfigs *bindings.TaikoDataConfig LivenessBond *big.Int IsGuardian bool @@ -87,7 +87,7 @@ func New(opts *NewProverServerOpts) (*ProverServer, error) { proposeConcurrencyGuard: opts.ProposeConcurrencyGuard, taikoL1Address: opts.TaikoL1Address, assignmentHookAddress: opts.AssignmentHookAddress, - rpc: opts.Rpc, + rpc: opts.RPC, protocolConfigs: opts.ProtocolConfigs, livenessBond: opts.LivenessBond, isGuardian: opts.IsGuardian, diff --git a/prover/server/server_test.go b/prover/server/server_test.go index 0d8a534ca..fd2f94ce2 100644 --- a/prover/server/server_test.go +++ b/prover/server/server_test.go @@ -58,7 +58,7 @@ func (s *ProverServerTestSuite) SetupTest() { ProposeConcurrencyGuard: make(chan struct{}, 1024), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), - Rpc: rpcClient, + RPC: rpcClient, ProtocolConfigs: &configs, LivenessBond: common.Big0, IsGuardian: false, @@ -74,11 +74,15 @@ func (s *ProverServerTestSuite) SetupTest() { } func (s *ProverServerTestSuite) TestHealth() { - s.Equal(http.StatusOK, s.sendReq("/healthz").StatusCode) + resp := s.sendReq("/healthz") + defer resp.Body.Close() + s.Equal(http.StatusOK, resp.StatusCode) } func (s *ProverServerTestSuite) TestRoot() { - s.Equal(http.StatusOK, s.sendReq("/").StatusCode) + resp := s.sendReq("/") + defer resp.Body.Close() + s.Equal(http.StatusOK, resp.StatusCode) } func (s *ProverServerTestSuite) TestStartShutdown() { diff --git a/testutils/helper.go b/testutils/helper.go index 6f2cde7f0..4a45565c1 100644 --- a/testutils/helper.go +++ b/testutils/helper.go @@ -37,12 +37,12 @@ func ProposeAndInsertEmptyBlocks( ) []*bindings.TaikoL1ClientBlockProposed { var events []*bindings.TaikoL1ClientBlockProposed - l1Head, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + l1Head, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) sink := make(chan *bindings.TaikoL1ClientBlockProposed) - sub, err := s.RpcClient.TaikoL1.WatchBlockProposed(nil, sink, nil, nil) + sub, err := s.RPCClient.TaikoL1.WatchBlockProposed(nil, sink, nil, nil) s.Nil(err) defer func() { sub.Unsubscribe() @@ -63,15 +63,15 @@ func ProposeAndInsertEmptyBlocks( events = append(events, []*bindings.TaikoL1ClientBlockProposed{<-sink, <-sink, <-sink}...) - _, isPending, err := s.RpcClient.L1.TransactionByHash(context.Background(), events[len(events)-1].Raw.TxHash) + _, isPending, err := s.RPCClient.L1.TransactionByHash(context.Background(), events[len(events)-1].Raw.TxHash) s.Nil(err) s.False(isPending) - newL1Head, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + newL1Head, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) s.Greater(newL1Head.Number.Uint64(), l1Head.Number.Uint64()) - syncProgress, err := s.RpcClient.L2.SyncProgress(context.Background()) + syncProgress, err := s.RPCClient.L2.SyncProgress(context.Background()) s.Nil(err) s.Nil(syncProgress) @@ -90,26 +90,26 @@ func ProposeAndInsertValidBlock( proposer Proposer, calldataSyncer CalldataSyncer, ) *bindings.TaikoL1ClientBlockProposed { - l1Head, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + l1Head, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) - l2Head, err := s.RpcClient.L2.HeaderByNumber(context.Background(), nil) + l2Head, err := s.RPCClient.L2.HeaderByNumber(context.Background(), nil) s.Nil(err) // Propose txs in L2 execution engine's mempool sink := make(chan *bindings.TaikoL1ClientBlockProposed) - sub, err := s.RpcClient.TaikoL1.WatchBlockProposed(nil, sink, nil, nil) + sub, err := s.RPCClient.TaikoL1.WatchBlockProposed(nil, sink, nil, nil) s.Nil(err) defer func() { sub.Unsubscribe() close(sink) }() - baseFee, err := s.RpcClient.TaikoL2.GetBasefee(nil, 0, uint32(l2Head.GasUsed)) + baseFee, err := s.RPCClient.TaikoL2.GetBasefee(nil, 0, uint32(l2Head.GasUsed)) s.Nil(err) - nonce, err := s.RpcClient.L2.PendingNonceAt(context.Background(), s.TestAddr) + nonce, err := s.RPCClient.L2.PendingNonceAt(context.Background(), s.TestAddr) s.Nil(err) tx := types.NewTransaction( @@ -120,27 +120,27 @@ func ProposeAndInsertValidBlock( baseFee, []byte{}, ) - signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(s.RpcClient.L2ChainID), s.TestAddrPrivKey) + signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(s.RPCClient.L2ChainID), s.TestAddrPrivKey) s.Nil(err) - s.Nil(s.RpcClient.L2.SendTransaction(context.Background(), signedTx)) + s.Nil(s.RPCClient.L2.SendTransaction(context.Background(), signedTx)) s.Nil(proposer.ProposeOp(context.Background())) event := <-sink - _, isPending, err := s.RpcClient.L1.TransactionByHash(context.Background(), event.Raw.TxHash) + _, isPending, err := s.RPCClient.L1.TransactionByHash(context.Background(), event.Raw.TxHash) s.Nil(err) s.False(isPending) - receipt, err := s.RpcClient.L1.TransactionReceipt(context.Background(), event.Raw.TxHash) + receipt, err := s.RPCClient.L1.TransactionReceipt(context.Background(), event.Raw.TxHash) s.Nil(err) s.Equal(types.ReceiptStatusSuccessful, receipt.Status) - newL1Head, err := s.RpcClient.L1.HeaderByNumber(context.Background(), nil) + newL1Head, err := s.RPCClient.L1.HeaderByNumber(context.Background(), nil) s.Nil(err) s.Greater(newL1Head.Number.Uint64(), l1Head.Number.Uint64()) - syncProgress, err := s.RpcClient.L2.SyncProgress(context.Background()) + syncProgress, err := s.RPCClient.L2.SyncProgress(context.Background()) s.Nil(err) s.Nil(syncProgress) @@ -149,22 +149,22 @@ func ProposeAndInsertValidBlock( s.Nil(calldataSyncer.ProcessL1Blocks(ctx, newL1Head)) - _, err = s.RpcClient.L2.HeaderByNumber(context.Background(), nil) + _, err = s.RPCClient.L2.HeaderByNumber(context.Background(), nil) s.Nil(err) return event } func DepositEtherToL2(s *ClientTestSuite, depositerPrivKey *ecdsa.PrivateKey, recipient common.Address) { - config, err := s.RpcClient.TaikoL1.GetConfig(nil) + config, err := s.RPCClient.TaikoL1.GetConfig(nil) s.Nil(err) - opts, err := bind.NewKeyedTransactorWithChainID(depositerPrivKey, s.RpcClient.L1ChainID) + opts, err := bind.NewKeyedTransactorWithChainID(depositerPrivKey, s.RPCClient.L1ChainID) s.Nil(err) opts.Value = config.EthDepositMinAmount for i := 0; i < int(config.EthDepositMinCountPerBlock); i++ { - _, err = s.RpcClient.TaikoL1.DepositEtherToL2(opts, recipient) + _, err = s.RPCClient.TaikoL1.DepositEtherToL2(opts, recipient) s.Nil(err) } } @@ -176,7 +176,7 @@ func NewTestProverServer( proverPrivKey *ecdsa.PrivateKey, url *url.URL, ) *server.ProverServer { - protocolConfig, err := s.RpcClient.TaikoL1.GetConfig(nil) + protocolConfig, err := s.RPCClient.TaikoL1.GetConfig(nil) s.Nil(err) srv, err := server.New(&server.NewProverServerOpts{ @@ -189,7 +189,7 @@ func NewTestProverServer( TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), ProposeConcurrencyGuard: make(chan struct{}, 1024), - Rpc: s.RpcClient, + RPC: s.RPCClient, ProtocolConfigs: &protocolConfig, LivenessBond: protocolConfig.LivenessBond, IsGuardian: true, diff --git a/testutils/suite.go b/testutils/suite.go index 482fbb182..361ebff61 100644 --- a/testutils/suite.go +++ b/testutils/suite.go @@ -22,7 +22,7 @@ import ( type ClientTestSuite struct { suite.Suite testnetL1SnapshotID string - RpcClient *rpc.Client + RPCClient *rpc.Client TestAddrPrivKey *ecdsa.PrivateKey TestAddr common.Address ProverEndpoints []*url.URL @@ -59,7 +59,7 @@ func (s *ClientTestSuite) SetupTest() { RetryInterval: backoff.DefaultMaxInterval, }) s.Nil(err) - s.RpcClient = rpcCli + s.RPCClient = rpcCli l1ProverPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROVER_PRIVATE_KEY"))) s.Nil(err) @@ -131,17 +131,17 @@ func (s *ClientTestSuite) setAddress(ownerPrivKey *ecdsa.PrivateKey, name [32]by controller, err := bindings.NewTaikoTimelockController( common.HexToAddress(os.Getenv("TIMELOCK_CONTROLLER")), - s.RpcClient.L1, + s.RPCClient.L1, ) s.Nil(err) - opts, err := bind.NewKeyedTransactorWithChainID(ownerPrivKey, s.RpcClient.L1ChainID) + opts, err := bind.NewKeyedTransactorWithChainID(ownerPrivKey, s.RPCClient.L1ChainID) s.Nil(err) addressManagerABI, err := bindings.AddressManagerMetaData.GetAbi() s.Nil(err) - data, err := addressManagerABI.Pack("setAddress", s.RpcClient.L1ChainID.Uint64(), name, address) + data, err := addressManagerABI.Pack("setAddress", s.RPCClient.L1ChainID.Uint64(), name, address) s.Nil(err) tx, err := controller.Schedule( @@ -155,7 +155,7 @@ func (s *ClientTestSuite) setAddress(ownerPrivKey *ecdsa.PrivateKey, name [32]by ) s.Nil(err) - _, err = rpc.WaitReceipt(context.Background(), s.RpcClient.L1, tx) + _, err = rpc.WaitReceipt(context.Background(), s.RPCClient.L1, tx) s.Nil(err) tx, err = controller.Execute( @@ -168,25 +168,25 @@ func (s *ClientTestSuite) setAddress(ownerPrivKey *ecdsa.PrivateKey, name [32]by ) s.Nil(err) - _, err = rpc.WaitReceipt(context.Background(), s.RpcClient.L1, tx) + _, err = rpc.WaitReceipt(context.Background(), s.RPCClient.L1, tx) s.Nil(err) } func (s *ClientTestSuite) TearDownTest() { var revertRes bool - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", s.testnetL1SnapshotID)) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &revertRes, "evm_revert", s.testnetL1SnapshotID)) s.True(revertRes) - s.Nil(rpc.SetHead(context.Background(), s.RpcClient.L2RawRPC, common.Big0)) + s.Nil(rpc.SetHead(context.Background(), s.RPCClient.L2RawRPC, common.Big0)) s.Nil(s.proverServer.Shutdown(context.Background())) } func (s *ClientTestSuite) SetL1Automine(automine bool) { - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), nil, "evm_setAutomine", automine)) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), nil, "evm_setAutomine", automine)) } func (s *ClientTestSuite) IncreaseTime(time uint64) { var result uint64 - s.Nil(s.RpcClient.L1RawRPC.CallContext(context.Background(), &result, "evm_increaseTime", time)) + s.Nil(s.RPCClient.L1RawRPC.CallContext(context.Background(), &result, "evm_increaseTime", time)) s.NotNil(result) } diff --git a/version/version.go b/version/version.go index 78ff5c025..cc0463bea 100644 --- a/version/version.go +++ b/version/version.go @@ -3,7 +3,7 @@ package version // Version info. const Version = "0.18.0" // x-release-please-version -var Meta = "dev" +var meta = "dev" // Git commit/date info, set via linker flags. var ( @@ -11,14 +11,13 @@ var ( GitDate = "" ) -// VersionWithCommit returns a textual version string including Git commit/date -// information. -func VersionWithCommit() string { - vsn := Version + "-" + Meta +// CommitVersion returns a textual version string including Git commit/date information. +func CommitVersion() string { + vsn := Version + "-" + meta if len(GitCommit) >= 8 { vsn += "-" + GitCommit[:8] } - if (Meta != "stable") && (GitDate != "") { + if (meta != "stable") && (GitDate != "") { vsn += "-" + GitDate } return vsn