From 7833cb11ded045b148e5f0cb2366fb72f0199d17 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 4 Mar 2021 18:26:00 -0300 Subject: [PATCH] fix some code and comment typos --- api/account.go | 2 +- api/accountcreationauths.go | 2 +- api/api_test.go | 8 ++++---- api/batch.go | 2 +- api/bids.go | 2 +- api/coordinator.go | 2 +- api/exits.go | 4 ++-- api/handlers.go | 6 +++--- api/parsers.go | 10 +++++----- api/slots.go | 4 ++-- api/token.go | 2 +- api/txshistory.go | 4 ++-- api/txshistory_test.go | 2 +- api/txspool.go | 2 +- api/txspool_test.go | 2 +- apitypes/apitypes.go | 10 +++++----- common/accountcreationauths.go | 6 +++--- common/bid.go | 2 +- common/l2tx.go | 2 +- common/tx.go | 2 +- common/zk.go | 2 +- config/config.go | 10 +++++----- coordinator/coordinator.go | 4 ++-- coordinator/pipeline.go | 2 +- coordinator/purger.go | 4 ++-- coordinator/txmanager.go | 4 ++-- db/historydb/historydb_test.go | 2 +- db/kvdb/kvdb.go | 2 +- db/l2db/l2db.go | 2 +- db/l2db/l2db_test.go | 2 +- db/statedb/statedb.go | 2 +- db/utils.go | 4 ++-- node/node.go | 6 +++--- prover/prover.go | 4 ++-- synchronizer/synchronizer.go | 16 ++++++++-------- synchronizer/synchronizer_test.go | 2 +- test/debugapi/debugapi.go | 4 ++-- test/debugapi/debugapi_test.go | 2 +- 38 files changed, 75 insertions(+), 75 deletions(-) diff --git a/api/account.go b/api/account.go index 677af5a..5f76c76 100644 --- a/api/account.go +++ b/api/account.go @@ -44,7 +44,7 @@ func (a *API) getAccounts(c *gin.Context) { return } - // Build succesfull response + // Build successful response type accountResponse struct { Accounts []historydb.AccountAPI `json:"accounts"` PendingItems uint64 `json:"pendingItems"` diff --git a/api/accountcreationauths.go b/api/accountcreationauths.go index ed7e3d8..0fa7c85 100644 --- a/api/accountcreationauths.go +++ b/api/accountcreationauths.go @@ -47,7 +47,7 @@ func (a *API) getAccountCreationAuth(c *gin.Context) { retSQLErr(err, c) return } - // Build succesfull response + // Build successful response c.JSON(http.StatusOK, auth) } diff --git a/api/api_test.go b/api/api_test.go index b321fb1..afe8d94 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -201,7 +201,7 @@ func TestMain(m *testing.M) { if err != nil { panic(err) } - apiConnCon := db.NewAPICnnectionController(1, time.Second) + apiConnCon := db.NewAPIConnectionController(1, time.Second) hdb := historydb.NewHistoryDB(database, database, apiConnCon) if err != nil { panic(err) @@ -260,7 +260,7 @@ func TestMain(m *testing.M) { // Reset DB test.WipeDB(api.h.DB()) - // Genratre blockchain data with til + // Generate blockchain data with til tcc := til.NewContext(chainID, common.RollupConstMaxL1UserTx) tilCfgExtra := til.ConfigExtra{ BootCoordAddr: ethCommon.HexToAddress("0xE39fEc6224708f0772D2A74fd3f9055A90E0A9f2"), @@ -512,7 +512,7 @@ func TestMain(m *testing.M) { WithdrawalDelay: uint64(3000), } - // Generate test data, as expected to be received/sended from/to the API + // Generate test data, as expected to be received/sent from/to the API testCoords := genTestCoordinators(commonCoords) testBids := genTestBids(commonBlocks, testCoords, bids) testExits := genTestExits(commonExitTree, testTokens, commonAccounts) @@ -599,7 +599,7 @@ func TestTimeout(t *testing.T) { pass := os.Getenv("POSTGRES_PASS") databaseTO, err := db.InitSQLDB(5432, "localhost", "hermez", pass, "hermez") require.NoError(t, err) - apiConnConTO := db.NewAPICnnectionController(1, 100*time.Millisecond) + apiConnConTO := db.NewAPIConnectionController(1, 100*time.Millisecond) hdbTO := historydb.NewHistoryDB(databaseTO, databaseTO, apiConnConTO) require.NoError(t, err) // L2DB diff --git a/api/batch.go b/api/batch.go index 48be3dd..8d90ce0 100644 --- a/api/batch.go +++ b/api/batch.go @@ -52,7 +52,7 @@ func (a *API) getBatches(c *gin.Context) { return } - // Build succesfull response + // Build successful response type batchesResponse struct { Batches []historydb.BatchAPI `json:"batches"` PendingItems uint64 `json:"pendingItems"` diff --git a/api/bids.go b/api/bids.go index cdfa89c..55e4dbc 100644 --- a/api/bids.go +++ b/api/bids.go @@ -34,7 +34,7 @@ func (a *API) getBids(c *gin.Context) { return } - // Build succesfull response + // Build successful response type bidsResponse struct { Bids []historydb.BidAPI `json:"bids"` PendingItems uint64 `json:"pendingItems"` diff --git a/api/coordinator.go b/api/coordinator.go index b1d507f..3b34de0 100644 --- a/api/coordinator.go +++ b/api/coordinator.go @@ -32,7 +32,7 @@ func (a *API) getCoordinators(c *gin.Context) { return } - // Build succesfull response + // Build successful response type coordinatorsResponse struct { Coordinators []historydb.CoordinatorAPI `json:"coordinators"` PendingItems uint64 `json:"pendingItems"` diff --git a/api/exits.go b/api/exits.go index d86c70d..7f9f730 100644 --- a/api/exits.go +++ b/api/exits.go @@ -43,7 +43,7 @@ func (a *API) getExits(c *gin.Context) { return } - // Build succesfull response + // Build successful response type exitsResponse struct { Exits []historydb.ExitAPI `json:"exits"` PendingItems uint64 `json:"pendingItems"` @@ -72,6 +72,6 @@ func (a *API) getExit(c *gin.Context) { retSQLErr(err, c) return } - // Build succesfull response + // Build successful response c.JSON(http.StatusOK, exit) } diff --git a/api/handlers.go b/api/handlers.go index 0db395c..6e9a2e9 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -14,7 +14,7 @@ import ( ) const ( - // maxLimit is the max permited items to be returned in paginated responses + // maxLimit is the max permitted items to be returned in paginated responses maxLimit uint = 2049 // dfltOrder indicates how paginated endpoints are ordered if not specified @@ -40,8 +40,8 @@ const ( ) var ( - // ErrNillBidderAddr is used when a nil bidderAddr is received in the getCoordinator method - ErrNillBidderAddr = errors.New("biderAddr can not be nil") + // ErrNilBidderAddr is used when a nil bidderAddr is received in the getCoordinator method + ErrNilBidderAddr = errors.New("biderAddr can not be nil") ) func retSQLErr(err error, c *gin.Context) { diff --git a/api/parsers.go b/api/parsers.go index 4519c1f..259adc3 100644 --- a/api/parsers.go +++ b/api/parsers.go @@ -50,19 +50,19 @@ func parsePagination(c querier) (fromItem *uint, order string, limit *uint, err return fromItem, order, limit, nil } -// nolint reason: res may be not overwriten +// nolint reason: res may be not overwritten func parseQueryUint(name string, dflt *uint, min, max uint, c querier) (*uint, error) { //nolint:SA4009 str := c.Query(name) return stringToUint(str, name, dflt, min, max) } -// nolint reason: res may be not overwriten +// nolint reason: res may be not overwritten func parseQueryInt64(name string, dflt *int64, min, max int64, c querier) (*int64, error) { //nolint:SA4009 str := c.Query(name) return stringToInt64(str, name, dflt, min, max) } -// nolint reason: res may be not overwriten +// nolint reason: res may be not overwritten func parseQueryBool(name string, dflt *bool, c querier) (*bool, error) { //nolint:SA4009 str := c.Query(name) if str == "" { @@ -295,13 +295,13 @@ func parseParamIdx(c paramer) (*common.Idx, error) { return stringToIdx(idxStr, name) } -// nolint reason: res may be not overwriten +// nolint reason: res may be not overwritten func parseParamUint(name string, dflt *uint, min, max uint, c paramer) (*uint, error) { //nolint:SA4009 str := c.Param(name) return stringToUint(str, name, dflt, min, max) } -// nolint reason: res may be not overwriten +// nolint reason: res may be not overwritten func parseParamInt64(name string, dflt *int64, min, max int64, c paramer) (*int64, error) { //nolint:SA4009 str := c.Param(name) return stringToInt64(str, name, dflt, min, max) diff --git a/api/slots.go b/api/slots.go index 877a985..c2d8afd 100644 --- a/api/slots.go +++ b/api/slots.go @@ -11,7 +11,7 @@ import ( "github.com/hermeznetwork/tracerr" ) -// SlotAPI is a repesentation of a slot information +// SlotAPI is a representation of a slot information type SlotAPI struct { ItemID uint64 `json:"itemId"` SlotNum int64 `json:"slotNum"` @@ -316,7 +316,7 @@ func (a *API) getSlots(c *gin.Context) { return } - // Build succesfull response + // Build successful response type slotsResponse struct { Slots []SlotAPI `json:"slots"` PendingItems uint64 `json:"pendingItems"` diff --git a/api/token.go b/api/token.go index dc061ce..5994fb6 100644 --- a/api/token.go +++ b/api/token.go @@ -53,7 +53,7 @@ func (a *API) getTokens(c *gin.Context) { return } - // Build succesfull response + // Build successful response type tokensResponse struct { Tokens []historydb.TokenWithUSD `json:"tokens"` PendingItems uint64 `json:"pendingItems"` diff --git a/api/txshistory.go b/api/txshistory.go index 7218948..d42dca6 100644 --- a/api/txshistory.go +++ b/api/txshistory.go @@ -42,7 +42,7 @@ func (a *API) getHistoryTxs(c *gin.Context) { return } - // Build succesfull response + // Build successful response type txsResponse struct { Txs []historydb.TxAPI `json:"transactions"` PendingItems uint64 `json:"pendingItems"` @@ -66,6 +66,6 @@ func (a *API) getHistoryTx(c *gin.Context) { retSQLErr(err, c) return } - // Build succesfull response + // Build successful response c.JSON(http.StatusOK, tx) } diff --git a/api/txshistory_test.go b/api/txshistory_test.go index cbef007..a3e5aef 100644 --- a/api/txshistory_test.go +++ b/api/txshistory_test.go @@ -455,7 +455,7 @@ func TestGetHistoryTx(t *testing.T) { // 400, due invalid TxID err := doBadReq("GET", endpoint+"0x001", nil, 400) assert.NoError(t, err) - // 404, due inexistent TxID in DB + // 404, due nonexistent TxID in DB err = doBadReq("GET", endpoint+"0x00eb5e95e1ce5e9f6c4ed402d415e8d0bdd7664769cfd2064d28da04a2c76be432", nil, 404) assert.NoError(t, err) } diff --git a/api/txspool.go b/api/txspool.go index 7e28529..d103e44 100644 --- a/api/txspool.go +++ b/api/txspool.go @@ -51,7 +51,7 @@ func (a *API) getPoolTx(c *gin.Context) { retSQLErr(err, c) return } - // Build succesfull response + // Build successful response c.JSON(http.StatusOK, tx) } diff --git a/api/txspool_test.go b/api/txspool_test.go index 379b4d3..c256700 100644 --- a/api/txspool_test.go +++ b/api/txspool_test.go @@ -235,7 +235,7 @@ func TestPoolTxs(t *testing.T) { // 400, due invalid TxID err = doBadReq("GET", endpoint+"0xG2241b6f2b1dd772dba391f4a1a3407c7c21f598d86e2585a14e616fb4a255f823", nil, 400) require.NoError(t, err) - // 404, due inexistent TxID in DB + // 404, due nonexistent TxID in DB err = doBadReq("GET", endpoint+"0x02241b6f2b1dd772dba391f4a1a3407c7c21f598d86e2585a14e616fb4a255f823", nil, 404) require.NoError(t, err) } diff --git a/apitypes/apitypes.go b/apitypes/apitypes.go index 28012a2..7bf04ae 100644 --- a/apitypes/apitypes.go +++ b/apitypes/apitypes.go @@ -91,7 +91,7 @@ func (c *CollectedFees) UnmarshalJSON(text []byte) error { return nil } -// HezEthAddr is used to scan/value Ethereum Address directly into strings that follow the Ethereum address hez fotmat (^hez:0x[a-fA-F0-9]{40}$) from/to sql DBs. +// HezEthAddr is used to scan/value Ethereum Address directly into strings that follow the Ethereum address hez format (^hez:0x[a-fA-F0-9]{40}$) from/to sql DBs. // It assumes that Ethereum Address are inserted/fetched to/from the DB using the default Scan/Value interface type HezEthAddr string @@ -143,7 +143,7 @@ func (s *StrHezEthAddr) UnmarshalText(text []byte) error { return nil } -// HezBJJ is used to scan/value *babyjub.PublicKeyComp directly into strings that follow the BJJ public key hez fotmat (^hez:[A-Za-z0-9_-]{44}$) from/to sql DBs. +// HezBJJ is used to scan/value *babyjub.PublicKeyComp directly into strings that follow the BJJ public key hez format (^hez:[A-Za-z0-9_-]{44}$) from/to sql DBs. // It assumes that *babyjub.PublicKeyComp are inserted/fetched to/from the DB using the default Scan/Value interface type HezBJJ string @@ -216,7 +216,7 @@ func (b HezBJJ) Value() (driver.Value, error) { // StrHezBJJ is used to unmarshal HezBJJ directly into an alias of babyjub.PublicKeyComp type StrHezBJJ babyjub.PublicKeyComp -// UnmarshalText unmarshals a StrHezBJJ +// UnmarshalText unmarshalls a StrHezBJJ func (s *StrHezBJJ) UnmarshalText(text []byte) error { bjj, err := hezStrToBJJ(string(text)) if err != nil { @@ -226,8 +226,8 @@ func (s *StrHezBJJ) UnmarshalText(text []byte) error { return nil } -// HezIdx is used to value common.Idx directly into strings that follow the Idx key hez fotmat (hez:tokenSymbol:idx) to sql DBs. -// Note that this can only be used to insert to DB since there is no way to automaticaly read from the DB since it needs the tokenSymbol +// HezIdx is used to value common.Idx directly into strings that follow the Idx key hez format (hez:tokenSymbol:idx) to sql DBs. +// Note that this can only be used to insert to DB since there is no way to automatically read from the DB since it needs the tokenSymbol type HezIdx string // StrHezIdx is used to unmarshal HezIdx directly into an alias of common.Idx diff --git a/common/accountcreationauths.go b/common/accountcreationauths.go index 5d669a2..522269a 100644 --- a/common/accountcreationauths.go +++ b/common/accountcreationauths.go @@ -84,7 +84,7 @@ func (a *AccountCreationAuth) toHash(chainID uint16, return rawData, nil } -// HashToSign returns the hash to be signed by the Etherum address to authorize +// HashToSign returns the hash to be signed by the Ethereum address to authorize // the account creation, which follows the EIP-712 encoding func (a *AccountCreationAuth) HashToSign(chainID uint16, hermezContractAddr ethCommon.Address) ([]byte, error) { @@ -96,9 +96,9 @@ func (a *AccountCreationAuth) HashToSign(chainID uint16, } // Sign signs the account creation authorization message using the provided -// `signHash` function, and stores the signaure in `a.Signature`. `signHash` +// `signHash` function, and stores the signature in `a.Signature`. `signHash` // should do an ethereum signature using the account corresponding to -// `a.EthAddr`. The `signHash` function is used to make signig flexible: in +// `a.EthAddr`. The `signHash` function is used to make signing flexible: in // tests we sign directly using the private key, outside tests we sign using // the keystore (which never exposes the private key). Sign follows the EIP-712 // encoding. diff --git a/common/bid.go b/common/bid.go index e756d91..e34f0df 100644 --- a/common/bid.go +++ b/common/bid.go @@ -34,7 +34,7 @@ type Slot struct { // BatchesLen int BidValue *big.Int BootCoord bool - // Bidder, Forer and URL correspond to the winner of the slot (which is + // Bidder, Forger and URL correspond to the winner of the slot (which is // not always the highest bidder). These are the values of the // coordinator that is able to forge exclusively before the deadline. Bidder ethCommon.Address diff --git a/common/l2tx.go b/common/l2tx.go index b00028f..966b37d 100644 --- a/common/l2tx.go +++ b/common/l2tx.go @@ -10,7 +10,7 @@ import ( // L2Tx is a struct that represents an already forged L2 tx type L2Tx struct { - // Stored in DB: mandatory fileds + // Stored in DB: mandatory fields TxID TxID `meddler:"id"` BatchNum BatchNum `meddler:"batch_num"` // batchNum in which this tx was forged. Position int `meddler:"position"` diff --git a/common/tx.go b/common/tx.go index e889572..6452c89 100644 --- a/common/tx.go +++ b/common/tx.go @@ -88,7 +88,7 @@ func (txid TxID) MarshalText() ([]byte, error) { return []byte(txid.String()), nil } -// UnmarshalText unmarshals a TxID +// UnmarshalText unmarshalls a TxID func (txid *TxID) UnmarshalText(data []byte) error { idStr := string(data) id, err := NewTxIDFromString(idStr) diff --git a/common/zk.go b/common/zk.go index 85a270c..1447a38 100644 --- a/common/zk.go +++ b/common/zk.go @@ -67,7 +67,7 @@ type ZKInputs struct { // accumulate fees // FeePlanTokens contains all the tokenIDs for which the fees are being - // accumulated and those fees accoumulated will be paid to the FeeIdxs + // accumulated and those fees accumulated will be paid to the FeeIdxs // array. The order of FeeIdxs & FeePlanTokens & State3 must match. // Coordinator fees are processed correlated such as: // [FeePlanTokens[i], FeeIdxs[i]] diff --git a/config/config.go b/config/config.go index a9f495f..f4f108e 100644 --- a/config/config.go +++ b/config/config.go @@ -73,7 +73,7 @@ type Coordinator struct { // checking the next block), used to decide when to stop scheduling new // batches (by stopping the pipeline). // For example, if we are at block 10 and ScheduleBatchBlocksAheadCheck - // is 5, eventhough at block 11 we canForge, the pipeline will be + // is 5, even though at block 11 we canForge, the pipeline will be // stopped if we can't forge at block 15. // This value should be the expected number of blocks it takes between // scheduling a batch and having it mined. @@ -83,7 +83,7 @@ type Coordinator struct { // from the next block; used to decide when to stop sending batches to // the smart contract. // For example, if we are at block 10 and SendBatchBlocksMarginCheck is - // 5, eventhough at block 11 we canForge, the batch will be discarded + // 5, even though at block 11 we canForge, the batch will be discarded // if we can't forge at block 15. SendBatchBlocksMarginCheck int64 // ProofServerPollInterval is the waiting interval between polling the @@ -126,7 +126,7 @@ type Coordinator struct { // L2Txs is reached, L2Txs older than TTL will be deleted. TTL Duration `validate:"required"` // PurgeBatchDelay is the delay between batches to purge - // outdated transactions. Oudated L2Txs are those that have + // outdated transactions. Outdated L2Txs are those that have // been forged or marked as invalid for longer than the // SafetyPeriod and pending L2Txs that have been in the pool // for longer than TTL once there are MaxTxs. @@ -136,7 +136,7 @@ type Coordinator struct { // nonce. InvalidateBatchDelay int64 `validate:"required"` // PurgeBlockDelay is the delay between blocks to purge - // outdated transactions. Oudated L2Txs are those that have + // outdated transactions. Outdated L2Txs are those that have // been forged or marked as invalid for longer than the // SafetyPeriod and pending L2Txs that have been in the pool // for longer than TTL once there are MaxTxs. @@ -168,7 +168,7 @@ type Coordinator struct { MaxGasPrice *big.Int `validate:"required"` // GasPriceIncPerc is the percentage increase of gas price set // in an ethereum transaction from the suggested gas price by - // the ehtereum node + // the ethereum node GasPriceIncPerc int64 // CheckLoopInterval is the waiting interval between receipt // checks of ethereum transactions in the TxManager diff --git a/coordinator/coordinator.go b/coordinator/coordinator.go index 66f4126..deb243a 100644 --- a/coordinator/coordinator.go +++ b/coordinator/coordinator.go @@ -54,7 +54,7 @@ type Config struct { // checking the next block), used to decide when to stop scheduling new // batches (by stopping the pipeline). // For example, if we are at block 10 and ScheduleBatchBlocksAheadCheck - // is 5, eventhough at block 11 we canForge, the pipeline will be + // is 5, even though at block 11 we canForge, the pipeline will be // stopped if we can't forge at block 15. // This value should be the expected number of blocks it takes between // scheduling a batch and having it mined. @@ -64,7 +64,7 @@ type Config struct { // from the next block; used to decide when to stop sending batches to // the smart contract. // For example, if we are at block 10 and SendBatchBlocksMarginCheck is - // 5, eventhough at block 11 we canForge, the batch will be discarded + // 5, even though at block 11 we canForge, the batch will be discarded // if we can't forge at block 15. // This value should be the expected number of blocks it takes between // sending a batch and having it mined. diff --git a/coordinator/pipeline.go b/coordinator/pipeline.go index d272587..2be1a6b 100644 --- a/coordinator/pipeline.go +++ b/coordinator/pipeline.go @@ -504,7 +504,7 @@ func (p *Pipeline) forgeBatch(batchNum common.BatchNum) (batchInfo *BatchInfo, e return nil, tracerr.Wrap(err) } - // Invalidate transactions that become invalid beause of + // Invalidate transactions that become invalid because of // the poolL2Txs selected. Will mark as invalid the txs that have a // (fromIdx, nonce) which already appears in the selected txs (includes // all the nonces smaller than the current one) diff --git a/coordinator/purger.go b/coordinator/purger.go index 8e11b1d..bf748a1 100644 --- a/coordinator/purger.go +++ b/coordinator/purger.go @@ -14,7 +14,7 @@ import ( // PurgerCfg is the purger configuration type PurgerCfg struct { // PurgeBatchDelay is the delay between batches to purge outdated - // transactions. Oudated L2Txs are those that have been forged or + // transactions. Outdated L2Txs are those that have been forged or // marked as invalid for longer than the SafetyPeriod and pending L2Txs // that have been in the pool for longer than TTL once there are // MaxTxs. @@ -23,7 +23,7 @@ type PurgerCfg struct { // transactions due to nonce lower than the account nonce. InvalidateBatchDelay int64 // PurgeBlockDelay is the delay between blocks to purge outdated - // transactions. Oudated L2Txs are those that have been forged or + // transactions. Outdated L2Txs are those that have been forged or // marked as invalid for longer than the SafetyPeriod and pending L2Txs // that have been in the pool for longer than TTL once there are // MaxTxs. diff --git a/coordinator/txmanager.go b/coordinator/txmanager.go index bb97a4b..9ca29f8 100644 --- a/coordinator/txmanager.go +++ b/coordinator/txmanager.go @@ -503,7 +503,7 @@ func (t *TxManager) Run(ctx context.Context) { // Our ethNode is giving an error different // than "not found" when getting the receipt // for the transaction, so we can't figure out - // if it was not mined, mined and succesfull or + // if it was not mined, mined and successful or // mined and failed. This could be due to the // ethNode failure. t.coord.SendMsg(ctx, MsgStopPipeline{ @@ -568,7 +568,7 @@ func (t *TxManager) removeBadBatchInfos(ctx context.Context) error { // Our ethNode is giving an error different // than "not found" when getting the receipt // for the transaction, so we can't figure out - // if it was not mined, mined and succesfull or + // if it was not mined, mined and successful or // mined and failed. This could be due to the // ethNode failure. next++ diff --git a/db/historydb/historydb_test.go b/db/historydb/historydb_test.go index 5b5800e..f860016 100644 --- a/db/historydb/historydb_test.go +++ b/db/historydb/historydb_test.go @@ -43,7 +43,7 @@ func TestMain(m *testing.M) { if err != nil { panic(err) } - apiConnCon := dbUtils.NewAPICnnectionController(1, time.Second) + apiConnCon := dbUtils.NewAPIConnectionController(1, time.Second) historyDBWithACC = NewHistoryDB(db, db, apiConnCon) // Run tests result := m.Run() diff --git a/db/kvdb/kvdb.go b/db/kvdb/kvdb.go index 3953876..a470ccb 100644 --- a/db/kvdb/kvdb.go +++ b/db/kvdb/kvdb.go @@ -316,7 +316,7 @@ func (k *KVDB) ResetFromSynchronizer(batchNum common.BatchNum, synchronizerKVDB checkpointPath := path.Join(k.cfg.Path, fmt.Sprintf("%s%d", PathBatchNum, batchNum)) - // copy synchronizer'BatchNumX' to 'BatchNumX' + // copy synchronizer 'BatchNumX' to 'BatchNumX' if err := synchronizerKVDB.MakeCheckpointFromTo(batchNum, checkpointPath); err != nil { return tracerr.Wrap(err) } diff --git a/db/l2db/l2db.go b/db/l2db/l2db.go index aeeaffa..e4d5846 100644 --- a/db/l2db/l2db.go +++ b/db/l2db/l2db.go @@ -310,7 +310,7 @@ func (l2db *L2DB) InvalidateOldNonces(updatedAccounts []common.IdxNonce, batchNu return nil } // Fill the batch_num in the query with Sprintf because we are using a - // named query which works with slices, and doens't handle an extra + // named query which works with slices, and doesn't handle an extra // individual argument. query := fmt.Sprintf(invalidateOldNoncesQuery, batchNum) if _, err := sqlx.NamedExec(l2db.dbWrite, query, updatedAccounts); err != nil { diff --git a/db/l2db/l2db_test.go b/db/l2db/l2db_test.go index 45db439..76a38a5 100644 --- a/db/l2db/l2db_test.go +++ b/db/l2db/l2db_test.go @@ -38,7 +38,7 @@ func TestMain(m *testing.M) { panic(err) } l2DB = NewL2DB(db, db, 10, 1000, 0.0, 24*time.Hour, nil) - apiConnCon := dbUtils.NewAPICnnectionController(1, time.Second) + apiConnCon := dbUtils.NewAPIConnectionController(1, time.Second) l2DBWithACC = NewL2DB(db, db, 10, 1000, 0.0, 24*time.Hour, apiConnCon) test.WipeDB(l2DB.DB()) historyDB = historydb.NewHistoryDB(db, db, nil) diff --git a/db/statedb/statedb.go b/db/statedb/statedb.go index d82e85a..53370a1 100644 --- a/db/statedb/statedb.go +++ b/db/statedb/statedb.go @@ -510,7 +510,7 @@ func (l *LocalStateDB) CheckpointExists(batchNum common.BatchNum) (bool, error) return l.db.CheckpointExists(batchNum) } -// Reset performs a reset in the LocaStateDB. If fromSynchronizer is true, it +// Reset performs a reset in the LocalStateDB. If fromSynchronizer is true, it // gets the state from LocalStateDB.synchronizerStateDB for the given batchNum. // If fromSynchronizer is false, get the state from LocalStateDB checkpoints. func (l *LocalStateDB) Reset(batchNum common.BatchNum, fromSynchronizer bool) error { diff --git a/db/utils.go b/db/utils.go index 901d8d4..bf7d304 100644 --- a/db/utils.go +++ b/db/utils.go @@ -93,8 +93,8 @@ type APIConnectionController struct { timeout time.Duration } -// NewAPICnnectionController initialize APIConnectionController -func NewAPICnnectionController(maxConnections int, timeout time.Duration) *APIConnectionController { +// NewAPIConnectionController initialize APIConnectionController +func NewAPIConnectionController(maxConnections int, timeout time.Duration) *APIConnectionController { return &APIConnectionController{ smphr: semaphore.NewWeighted(int64(maxConnections)), timeout: timeout, diff --git a/node/node.go b/node/node.go index 681a32c..8ab9f98 100644 --- a/node/node.go +++ b/node/node.go @@ -107,7 +107,7 @@ func NewNode(mode Mode, cfg *config.Node) (*Node, error) { } var apiConnCon *dbUtils.APIConnectionController if cfg.API.Explorer || mode == ModeCoordinator { - apiConnCon = dbUtils.NewAPICnnectionController( + apiConnCon = dbUtils.NewAPIConnectionController( cfg.API.MaxSQLConnections, cfg.API.SQLConnectionTimeout.Duration, ) @@ -491,8 +491,8 @@ func NewNodeAPI( }, nil } -// Run starts the http server of the NodeAPI. To stop it, pass a context with -// cancelation. +// Run starts the http server of the NodeAPI. To stop it, pass a context +// with cancellation. func (a *NodeAPI) Run(ctx context.Context) error { server := &http.Server{ Handler: a.engine, diff --git a/prover/prover.go b/prover/prover.go index 4989086..4859dc3 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -235,7 +235,7 @@ func (p *ProofServerClient) CalculateProof(ctx context.Context, zkInputs *common return tracerr.Wrap(p.apiInput(ctx, zkInputs)) } -// GetProof retreives the Proof and Public Data (public inputs) from the +// GetProof retrieves the Proof and Public Data (public inputs) from the // ServerProof, blocking until the proof is ready. func (p *ProofServerClient) GetProof(ctx context.Context) (*Proof, []*big.Int, error) { if err := p.WaitReady(ctx); err != nil { @@ -298,7 +298,7 @@ func (p *MockClient) CalculateProof(ctx context.Context, zkInputs *common.ZKInpu return nil } -// GetProof retreives the Proof from the ServerProof +// GetProof retrieves the Proof from the ServerProof func (p *MockClient) GetProof(ctx context.Context) (*Proof, []*big.Int, error) { // Simulate a delay select { diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index f41adac..6b573c7 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -31,7 +31,7 @@ var ( ErrUnknownBlock = fmt.Errorf("unknown block") ) -// Stats of the syncrhonizer +// Stats of the synchronizer type Stats struct { Eth struct { RefreshPeriod time.Duration @@ -347,7 +347,7 @@ func (s *Synchronizer) setSlotCoordinator(slot *common.Slot) error { } // updateCurrentSlot updates the slot with information of the current slot. -// The information abouth which coordinator is allowed to forge is only updated +// The information about which coordinator is allowed to forge is only updated // when we are Synced. // hasBatch is true when the last synced block contained at least one batch. func (s *Synchronizer) updateCurrentSlot(slot *common.Slot, reset bool, hasBatch bool) error { @@ -400,7 +400,7 @@ func (s *Synchronizer) updateCurrentSlot(slot *common.Slot, reset bool, hasBatch } // updateNextSlot updates the slot with information of the next slot. -// The information abouth which coordinator is allowed to forge is only updated +// The information about which coordinator is allowed to forge is only updated // when we are Synced. func (s *Synchronizer) updateNextSlot(slot *common.Slot) error { // We want the next block because the current one is already mined @@ -503,9 +503,9 @@ func (s *Synchronizer) resetIntermediateState() error { return nil } -// Sync attems to synchronize an ethereum block starting from lastSavedBlock. +// Sync attempts to synchronize an ethereum block starting from lastSavedBlock. // If lastSavedBlock is nil, the lastSavedBlock value is obtained from de DB. -// If a block is synched, it will be returned and also stored in the DB. If a +// If a block is synced, it will be returned and also stored in the DB. If a // reorg is detected, the number of discarded blocks will be returned and no // synchronization will be made. // TODO: Be smart about locking: only lock during the read/write operations @@ -558,7 +558,7 @@ func (s *Synchronizer) Sync(ctx context.Context, "ethLastBlock", s.stats.Eth.LastBlock, ) - // Check that the obtianed ethBlock.ParentHash == prevEthBlock.Hash; if not, reorg! + // Check that the obtained ethBlock.ParentHash == prevEthBlock.Hash; if not, reorg! if lastSavedBlock != nil { if lastSavedBlock.Hash != ethBlock.ParentHash { // Reorg detected @@ -578,7 +578,7 @@ func (s *Synchronizer) Sync(ctx context.Context, // If there was an error during sync, reset to the last block // in the historyDB because the historyDB is written last in // the Sync method and is the source of consistency. This - // allows reseting the stateDB in the case a batch was + // allows resetting the stateDB in the case a batch was // processed but the historyDB block was not committed due to an // error. if err != nil { @@ -818,7 +818,7 @@ func (s *Synchronizer) resetState(block *common.Block) error { return nil } -// rollupSync retreives all the Rollup Smart Contract Data that happened at +// rollupSync retrieves all the Rollup Smart Contract Data that happened at // ethBlock.blockNum with ethBlock.Hash. func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, error) { blockNum := ethBlock.Num diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 6cd2300..6f6252c 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -823,7 +823,7 @@ func TestSyncForgerCommitment(t *testing.T) { // Store ForgerComitmnent observed at every block by the live synchronizer syncCommitment := map[int64]bool{} - // Store ForgerComitmnent observed at every block by a syncrhonizer that is restarted + // Store ForgerComitmnent observed at every block by a synchronizer that is restarted syncRestartedCommitment := map[int64]bool{} for _, block := range blocks { // Add block data to the smart contracts diff --git a/test/debugapi/debugapi.go b/test/debugapi/debugapi.go index 250f71a..71d3278 100644 --- a/test/debugapi/debugapi.go +++ b/test/debugapi/debugapi.go @@ -101,8 +101,8 @@ func (a *DebugAPI) handleSyncStats(c *gin.Context) { c.JSON(http.StatusOK, stats) } -// Run starts the http server of the DebugAPI. To stop it, pass a context with -// cancelation (see `debugapi_test.go` for an example). +// Run starts the http server of the DebugAPI. To stop it, pass a context +// with cancellation (see `debugapi_test.go` for an example). func (a *DebugAPI) Run(ctx context.Context) error { api := gin.Default() api.NoRoute(handleNoRoute) diff --git a/test/debugapi/debugapi_test.go b/test/debugapi/debugapi_test.go index d1cba60..e90229d 100644 --- a/test/debugapi/debugapi_test.go +++ b/test/debugapi/debugapi_test.go @@ -51,7 +51,7 @@ func TestDebugAPI(t *testing.T) { require.Nil(t, err) addr := "localhost:12345" - // We won't test the sync/stats endpoint, so we can se the Syncrhonizer to nil + // We won't test the sync/stats endpoint, so we can se the synchronizer to nil debugAPI := NewDebugAPI(addr, sdb, nil) ctx, cancel := context.WithCancel(context.Background())