From 40537f953161b80f12b57cebb79a8bc812ef8e4d Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Fri, 23 Apr 2021 19:42:32 -0500 Subject: [PATCH] chore(linter): change locale to UK from US (#1533) * chore(linter): change locale to UK from US --- .github/CODE_OF_CONDUCT.md | 10 +- .github/CONTRIBUTING.md | 4 +- .github/ISSUE_TEMPLATE/bug_report.md | 6 +- .golangci.yml | 4 +- Makefile | 2 +- README.md | 6 +- cmd/gossamer/config.go | 8 +- cmd/gossamer/flags.go | 2 +- cmd/gossamer/main.go | 30 ++--- cmd/gossamer/main_test.go | 2 +- docs/docs/contributing.md | 4 +- docs/docs/getting-started/installation.md | 4 +- .../overview/host-architecture.md | 2 +- .../overview/package-library.md | 4 +- .../resources/general-resources.md | 2 +- docs/docs/usage/command-line.md | 10 +- docs/docs/usage/import-runtime.md | 4 +- docs/docs/usage/running-nodes.md | 4 +- dot/build_spec.go | 2 +- dot/build_spec_test.go | 2 +- dot/core/digest.go | 22 ++-- dot/core/digest_test.go | 2 +- dot/core/errors.go | 2 +- dot/core/service_test.go | 2 +- dot/core/test_helpers.go | 2 +- dot/network/service_test.go | 2 +- dot/network/sync.go | 18 +-- dot/node.go | 22 ++-- dot/node_test.go | 2 +- dot/rpc/dot_up_codec.go | 2 +- dot/rpc/http.go | 2 +- dot/rpc/modules/author.go | 4 +- dot/rpc/modules/chain.go | 4 +- dot/rpc/modules/chain_test.go | 2 +- dot/rpc/modules/grandpa.go | 2 +- dot/rpc/subscription/listeners.go | 12 +- dot/rpc/subscription/listeners_test.go | 6 +- dot/rpc/subscription/websocket.go | 6 +- dot/services.go | 6 +- dot/state/block.go | 32 ++--- dot/state/block_notify.go | 37 +++--- dot/state/block_notify_test.go | 4 +- dot/state/block_test.go | 12 +- dot/state/service.go | 26 ++--- dot/state/service_test.go | 24 ++-- dot/sync/syncer.go | 6 +- dot/sync/syncer_test.go | 2 +- dot/telemetry/telemetry.go | 4 +- dot/types/block.go | 2 +- dot/types/roles.go | 2 +- lib/babe/babe_test.go | 2 +- lib/babe/build.go | 10 +- lib/babe/build_test.go | 4 +- lib/babe/verify_test.go | 2 +- lib/blocktree/blocktree.go | 12 +- lib/blocktree/blocktree_test.go | 14 +-- lib/blocktree/node.go | 18 +-- lib/blocktree/node_test.go | 14 +-- lib/common/db_keys.go | 10 +- lib/grandpa/errors.go | 8 +- lib/grandpa/grandpa.go | 60 +++++----- lib/grandpa/grandpa_test.go | 14 +-- lib/grandpa/message.go | 4 +- lib/grandpa/message_handler.go | 18 +-- lib/grandpa/message_handler_test.go | 4 +- lib/grandpa/round_test.go | 110 +++++++++--------- lib/grandpa/types.go | 2 +- lib/grandpa/vote_message.go | 4 +- lib/keystore/keyring.go | 4 +- lib/runtime/constants.go | 3 +- .../extrinsic/unchecked_extrinsic_test.go | 2 +- lib/runtime/life/exports.go | 3 +- lib/runtime/sig_verifier.go | 2 +- lib/runtime/storage/trie_test.go | 2 +- lib/runtime/wasmer/exports.go | 3 +- lib/runtime/wasmer/exports_test.go | 2 +- lib/runtime/wasmtime/exports.go | 2 + lib/scale/decode.go | 2 +- lib/trie/database_test.go | 2 +- lib/trie/trie_test.go | 4 +- scripts/install-lint.sh | 2 +- tests/stress/errors.go | 4 +- tests/stress/grandpa_test.go | 10 +- tests/stress/helpers.go | 10 +- tests/stress/stress_test.go | 4 +- tests/sync/sync_test.go | 2 +- tests/utils/chain.go | 4 +- tests/utils/gossamer_utils.go | 14 +-- 88 files changed, 392 insertions(+), 382 deletions(-) diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 2e3c5f0ec9..30f45bee28 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -11,7 +11,7 @@ appearance, race, religion, or sexual identity and orientation. ## Our Standards -Examples of behavior that contributes to creating a positive environment +Examples of behaviour that contributes to creating a positive environment include: * Using welcoming and inclusive language @@ -20,7 +20,7 @@ include: * Focusing on what is best for the community * Showing empathy towards other community members -Examples of unacceptable behavior by participants include: +Examples of unacceptable behaviour by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances @@ -34,13 +34,13 @@ Examples of unacceptable behavior by participants include: ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. +behaviour and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behaviour. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, +permanently any contributor for other behaviours that they deem inappropriate, threatening, offensive, or harmful. ## Scope diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e34ef3b777..0f54b02bea 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -44,7 +44,7 @@ $ git remote -v (you should see myrepo and gossamer in the list of remotes) To start, check out our open issues. We recommend starting with an [issue labeled `Good First Issue`](https://github.com/ChainSafe/gossamer/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+First+Issue%22). Leave a comment to let us know that you would like to work on it. -Another option is to improve gossamer where you see fit based on your evaluation of our code. In order to best faciliate collaboration, please create an issue before you start working on it. +Another option is to improve gossamer where you see fit based on your evaluation of our code. In order to best facilitate collaboration, please create an issue before you start working on it. **6. Make improvements to the code.** @@ -76,7 +76,7 @@ Navigate your browser to [https://github.com/ChainSafe/gossamer](https://github. ## Note on memory intensive tests Unfortunately, the free tier for CI's have a memory cap and some tests will cause the CI to experience an out of memory error. -In order to mitigate this we have introduced the concept of **short tests**. If your PR causes an out of memory error please seperate the tests into two groups +In order to mitigate this we have introduced the concept of **short tests**. If your PR causes an out of memory error please separate the tests into two groups like below and make sure to label it `large`: ``` diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8f2ba47ecb..8bbc88a043 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,10 +30,10 @@ If you're suggesting a change/improvement, tell us how it should work. @@ -55,7 +55,7 @@ submit a PR and you'll get credit for the whole thing. ## To Reproduce -Steps to reproduce the behavior: +Steps to reproduce the behaviour: 1. 2. diff --git a/.golangci.yml b/.golangci.yml index dcb195c988..ee156bb62a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -41,7 +41,7 @@ run: # which files to skip: they will be analyzed, but issues from them # won't be reported. Default value is empty list, but there is - # no need to include all autogenerated files, we confidently recognize + # no need to include all autogenerated files, we confidently recognise # autogenerated files. If it's not please let us know. #skip-files: @@ -132,7 +132,7 @@ linters-settings: # Correct spellings using locale preferences for US or UK. # Default is to use a neutral variety of English. # Setting locale to US will correct the British spelling of 'colour' to 'color'. - locale: US + locale: UK ignore-words: - gossamer lll: diff --git a/Makefile b/Makefile index 8dceb3540b..73ca566dc0 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ build-debug: @echo " > \033[32mBuilding binary...\033[0m " GOBIN=$(PWD)/bin go run scripts/ci.go install-debug -## init: Initialize gossamer using the default genesis and toml configuration files +## init: Initialise gossamer using the default genesis and toml configuration files init: ./bin/gossamer --key alice init --genesis chain/gssmr/genesis.json --force diff --git a/README.md b/README.md index 362ecf9916..0e034e5ce8 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ make gossamer ### Run Default Node -initialize default node: +initialise default node: ``` ./bin/gossamer --chain gssmr init ``` @@ -87,7 +87,7 @@ Then, re-run the above steps. NOTE: this feature is for testing only; if you wis ### Run Kusama Node -initialize kusama node: +initialise kusama node: ``` ./bin/gossamer --chain kusama init ``` @@ -108,7 +108,7 @@ After it's finished bootstrapping, the node should begin to sync. ### Run Polkadot Node -initialize polkadot node: +initialise polkadot node: ``` ./bin/gossamer --chain polkadot init ``` diff --git a/cmd/gossamer/config.go b/cmd/gossamer/config.go index 0b47ff5721..bc65137174 100644 --- a/cmd/gossamer/config.go +++ b/cmd/gossamer/config.go @@ -151,7 +151,7 @@ func createDotConfig(ctx *cli.Context) (*dot.Config, error) { return cfg, nil } -// createInitConfig creates the configuration required to initialize a dot node +// createInitConfig creates the configuration required to initialise a dot node func createInitConfig(ctx *cli.Context) (*dot.Config, error) { tomlCfg, cfg, err := setupConfigFromChain(ctx) if err != nil { @@ -736,9 +736,9 @@ func updateDotConfigFromGenesisJSONRaw(tomlCfg ctoml.Config, cfg *dot.Config) { ) } -// updateDotConfigFromGenesisData updates the configuration from genesis data of an initialized node +// updateDotConfigFromGenesisData updates the configuration from genesis data of an initialised node func updateDotConfigFromGenesisData(ctx *cli.Context, cfg *dot.Config) error { - // initialize database using data directory + // initialise database using data directory db, err := chaindb.NewBadgerDB(&chaindb.Config{ DataDir: cfg.Global.BasePath, }) @@ -746,7 +746,7 @@ func updateDotConfigFromGenesisData(ctx *cli.Context, cfg *dot.Config) error { return fmt.Errorf("failed to create database: %s", err) } - // load genesis data from initialized node database + // load genesis data from initialised node database gen, err := state.LoadGenesisData(db) if err != nil { return fmt.Errorf("failed to load genesis data: %s", err) diff --git a/cmd/gossamer/flags.go b/cmd/gossamer/flags.go index fcc620fe1b..41f36b99de 100644 --- a/cmd/gossamer/flags.go +++ b/cmd/gossamer/flags.go @@ -359,7 +359,7 @@ var ( // FixFlagOrder allow us to use various flag order formats (ie, `gossamer init // --config config.toml` and `gossamer --config config.toml init`). FixFlagOrder // only fixes global flags, all local flags must come after the subcommand (ie, -// `gossamer --force --config config.toml init` will not recognize `--force` but +// `gossamer --force --config config.toml init` will not recognise `--force` but // `gossamer init --force --config config.toml` will work as expected). func FixFlagOrder(f func(ctx *cli.Context) error) func(*cli.Context) error { return func(ctx *cli.Context) error { diff --git a/cmd/gossamer/main.go b/cmd/gossamer/main.go index 84dbe34650..5c0d3d0ea3 100644 --- a/cmd/gossamer/main.go +++ b/cmd/gossamer/main.go @@ -48,11 +48,11 @@ var ( initCommand = cli.Command{ Action: FixFlagOrder(initAction), Name: "init", - Usage: "Initialize node databases and load genesis data to state", + Usage: "Initialise node databases and load genesis data to state", ArgsUsage: "", Flags: InitFlags, Category: "INIT", - Description: "The init command initializes the node databases and loads the genesis data from the genesis file to state.\n" + + Description: "The init command initialises the node databases and loads the genesis data from the genesis file to state.\n" + "\tUsage: gossamer init --genesis genesis.json", } // accountCommand defines the "account" subcommand (ie, `gossamer account`) @@ -108,7 +108,7 @@ var ( } ) -// init initializes the cli application +// init initialises the cli application func init() { app.Action = gossamerAction app.Copyright = "Copyright 2019 ChainSafe Systems Authors" @@ -181,7 +181,7 @@ func importRuntimeAction(ctx *cli.Context) error { } // gossamerAction is the root action for the gossamer command, creates a node -// configuration, loads the keystore, initializes the node if not initialized, +// configuration, loads the keystore, initialises the node if not initialised, // then creates and starts the node and node services func gossamerAction(ctx *cli.Context) error { // check for unknown command arguments @@ -216,13 +216,13 @@ func gossamerAction(ctx *cli.Context) error { // from createDotConfig because dot config should not include expanded path) cfg.Global.BasePath = utils.ExpandDir(cfg.Global.BasePath) - // check if node has not been initialized (expected true - add warning log) + // check if node has not been initialised (expected true - add warning log) if !dot.NodeInitialized(cfg.Global.BasePath, true) { - // initialize node (initialize state database and load genesis data) + // initialise node (initialise state database and load genesis data) err = dot.InitNode(cfg) if err != nil { - logger.Error("failed to initialize node", "error", err) + logger.Error("failed to initialise node", "error", err) return err } } @@ -289,7 +289,7 @@ func gossamerAction(ctx *cli.Context) error { return nil } -// initAction is the action for the "init" subcommand, initializes the trie and +// initAction is the action for the "init" subcommand, initialises the trie and // state databases and loads initial state from the configured genesis file func initAction(ctx *cli.Context) error { lvl, err := setupLogger(ctx) @@ -310,31 +310,31 @@ func initAction(ctx *cli.Context) error { // from createDotConfig because dot config should not include expanded path) cfg.Global.BasePath = utils.ExpandDir(cfg.Global.BasePath) - // check if node has been initialized (expected false - no warning log) + // check if node has been initialised (expected false - no warning log) if dot.NodeInitialized(cfg.Global.BasePath, false) { - // use --force value to force initialize the node + // use --force value to force initialise the node force := ctx.Bool(ForceFlag.Name) // prompt user to confirm reinitialization - if force || confirmMessage("Are you sure you want to reinitialize the node? [Y/n]") { + if force || confirmMessage("Are you sure you want to reinitialise the node? [Y/n]") { logger.Info( - "reinitializing node...", + "reinitialising node...", "basepath", cfg.Global.BasePath, ) } else { logger.Warn( - "exiting without reinitializing the node", + "exiting without reinitialising the node", "basepath", cfg.Global.BasePath, ) return nil // exit if reinitialization is not confirmed } } - // initialize node (initialize state database and load genesis data) + // initialise node (initialise state database and load genesis data) err = dot.InitNode(cfg) if err != nil { - logger.Error("failed to initialize node", "error", err) + logger.Error("failed to initialise node", "error", err) return err } diff --git a/cmd/gossamer/main_test.go b/cmd/gossamer/main_test.go index a05ebc6eac..a1ab39225f 100644 --- a/cmd/gossamer/main_test.go +++ b/cmd/gossamer/main_test.go @@ -250,7 +250,7 @@ func TestGossamerCommand(t *testing.T) { t.Log("init gossamer output, ", "stdout", string(stdout), "stderr", string(stderr)) expectedMessages := []string{ - "node initialized", + "node initialised", } for _, m := range expectedMessages { diff --git a/docs/docs/contributing.md b/docs/docs/contributing.md index 6e808861c6..d153a32b00 100644 --- a/docs/docs/contributing.md +++ b/docs/docs/contributing.md @@ -44,7 +44,7 @@ $ git remote -v (you should see myrepo and gossamer in the list of remotes) To start, check out our open issues. We recommend starting with an [issue labeled `Good First Issue`](https://github.com/ChainSafe/gossamer/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+First+Issue%22). Leave a comment to let us know that you would like to work on it. -Another option is to improve gossamer where you see fit based on your evaluation of our code. In order to best faciliate collaboration, please create an issue before you start working on it. +Another option is to improve gossamer where you see fit based on your evaluation of our code. In order to best facilitate collaboration, please create an issue before you start working on it. **6. Make improvements to the code.** @@ -76,7 +76,7 @@ Navigate your browser to [https://github.com/ChainSafe/gossamer](https://github. ## Note on memory intensive tests Unfortunately, the free tier for CI's have a memory cap and some tests will cause the CI to experience an out of memory error. -In order to mitigate this we have introduced the concept of **short tests**. If your PR causes an out of memory error please seperate the tests into two groups +In order to mitigate this we have introduced the concept of **short tests**. If your PR causes an out of memory error please separate the tests into two groups like below and make sure to label it `large`: ``` diff --git a/docs/docs/getting-started/installation.md b/docs/docs/getting-started/installation.md index b25d04197a..358775e051 100644 --- a/docs/docs/getting-started/installation.md +++ b/docs/docs/getting-started/installation.md @@ -25,7 +25,7 @@ make gossamer ## Run a Gossamer Node -To run default Gossamer node, first initialize the node. This writes the genesis state to the database. +To run default Gossamer node, first initialise the node. This writes the genesis state to the database. ``` ./bin/gossamer --chain gssmr init ``` @@ -77,7 +77,7 @@ After it's finished bootstrapping, the node should begin to sync. ## Run Polkadot Node -Initialize polkadot node: +Initialise polkadot node: ``` ./bin/gossamer --chain polkadot init ``` diff --git a/docs/docs/getting-started/overview/host-architecture.md b/docs/docs/getting-started/overview/host-architecture.md index ab147dcc51..aeb4f4d4ce 100644 --- a/docs/docs/getting-started/overview/host-architecture.md +++ b/docs/docs/getting-started/overview/host-architecture.md @@ -48,7 +48,7 @@ type Service interface { ### Core Service -The **core service** is responsible for block production and finalization (consensus) and processing messages received from the **network service**; it initializes BABE sessions and GRANDPA rounds and validates blocks and transactions before committing them to the **state service**. +The **core service** is responsible for block production and finalisation (consensus) and processing messages received from the **network service**; it initialises BABE sessions and GRANDPA rounds and validates blocks and transactions before committing them to the **state service**. - only the **core service** writes to block state - only the **core service** writes to storage state diff --git a/docs/docs/getting-started/overview/package-library.md b/docs/docs/getting-started/overview/package-library.md index 347a3caaf3..d0d8b30e8e 100644 --- a/docs/docs/getting-started/overview/package-library.md +++ b/docs/docs/getting-started/overview/package-library.md @@ -42,7 +42,7 @@ Gossamer packages can be categorized into **four package types**: #### `dot/core` -- The **core package** implements the [Core Service](/getting-started/overview/host-architecture#core-service) - responsible for block production and block finalization (consensus) and processing messages received from the [Network Service](/getting-started/overview/host-architecture/#network-service). +- The **core package** implements the [Core Service](/getting-started/overview/host-architecture#core-service) - responsible for block production and block finalisation (consensus) and processing messages received from the [Network Service](/getting-started/overview/host-architecture/#network-service). #### `dot/network` @@ -72,7 +72,7 @@ Gossamer packages can be categorized into **four package types**: #### `lib/blocktree` -- the **blocktree package** implements the blocktree, a data structure which tracks the chain and all its non-finalized forks. +- the **blocktree package** implements the blocktree, a data structure which tracks the chain and all its non-finalised forks. #### `lib/common` diff --git a/docs/docs/getting-started/resources/general-resources.md b/docs/docs/getting-started/resources/general-resources.md index 56854b0644..b9198bcaea 100644 --- a/docs/docs/getting-started/resources/general-resources.md +++ b/docs/docs/getting-started/resources/general-resources.md @@ -34,7 +34,7 @@ To start, it would be extremely beneficial to have an understanding of the Polka ## Polkadot Host -[_Please Note: The "Polkadot Host" was formerly known as the "Polkadot Runtime Enviornment"_] +[_Please Note: The "Polkadot Host" was formerly known as the "Polkadot Runtime Environment"_] The Polkadot Host plays two important roles within the Polkadot ecosystem. diff --git a/docs/docs/usage/command-line.md b/docs/docs/usage/command-line.md index 1d3918c519..89d6934b3e 100644 --- a/docs/docs/usage/command-line.md +++ b/docs/docs/usage/command-line.md @@ -6,7 +6,7 @@ permalink: /usage/command-line/ ## Gossamer Command -The `gossamer` command is the root command for the `gossamer` package (`cmd/gossamer`). The root command starts the node (and initializes the node if the node has not already been initialized). +The `gossamer` command is the root command for the `gossamer` package (`cmd/gossamer`). The root command starts the node (and initialises the node if the node has not already been initialised). ### Accepted Formats @@ -69,7 +69,7 @@ SUBCOMMANDS: help, h Shows a list of commands or help for one command account Create and manage node keystore accounts export Export configuration values to TOML configuration file - init Initialize node databases and load genesis data to state + init Initialise node databases and load genesis data to state ``` List of ***local flags*** for `init` subcommand: @@ -188,15 +188,15 @@ Available built-in keys: ./bin/gossmer --key heather ``` -## Initializing Nodes +## initialising Nodes -To initialize or re-initialize a node, use the init subcommand `init`: +To initialise or re-initialise a node, use the init subcommand `init`: ``` ./bin/gossamer init ./bin/gossamer --key alice --roles 4 ``` -`init` can be used with the `--base-path` or `--config` flag to re-initialize a custom node (ie, `bob` from the example above): +`init` can be used with the `--base-path` or `--config` flag to re-initialise a custom node (ie, `bob` from the example above): ``` ./bin/gossamer --config node/gssmr/bob.toml init ``` diff --git a/docs/docs/usage/import-runtime.md b/docs/docs/usage/import-runtime.md index 7bed1f04cd..df39cd91d4 100644 --- a/docs/docs/usage/import-runtime.md +++ b/docs/docs/usage/import-runtime.md @@ -35,9 +35,9 @@ To create the raw genesis file used by the node, you can use the `gossamer build This creates a genesis file `genesis.json` that is usable by the node. -### 3. Initialize the node with the genesis file +### 3. Initialise the node with the genesis file -Next, you will need to write the state in `genesis.json` to the database by initializing the node. +Next, you will need to write the state in `genesis.json` to the database by initialising the node. ``` ./bin/gossamer init --genesis genesis.json diff --git a/docs/docs/usage/running-nodes.md b/docs/docs/usage/running-nodes.md index 3d44568e49..d32ab6907d 100644 --- a/docs/docs/usage/running-nodes.md +++ b/docs/docs/usage/running-nodes.md @@ -6,7 +6,7 @@ permalink: /usage/running-nodes/ ## Run a Gossamer Node -To run default Gossamer node, first initialize the node. This writes the genesis state to the database. +To run default Gossamer node, first initialise the node. This writes the genesis state to the database. ``` ./bin/gossamer --chain gssmr init ``` @@ -58,7 +58,7 @@ After it's finished bootstrapping, the node should begin to sync. ## Run Polkadot Node -Initialize polkadot node: +Initialise polkadot node: ``` ./bin/gossamer --chain polkadot init ``` diff --git a/dot/build_spec.go b/dot/build_spec.go index 70558f6825..53e150f1e6 100644 --- a/dot/build_spec.go +++ b/dot/build_spec.go @@ -109,7 +109,7 @@ func BuildFromDB(path string) (*BuildSpec, error) { stateSrvc := state.NewService(path, log.LvlCrit) - // start state service (initialize state database) + // start state service (initialise state database) err := stateSrvc.Start() if err != nil { return nil, err diff --git a/dot/build_spec_test.go b/dot/build_spec_test.go index 10320e6327..53dc276742 100644 --- a/dot/build_spec_test.go +++ b/dot/build_spec_test.go @@ -135,7 +135,7 @@ func TestBuildFromDB(t *testing.T) { cfg.Init.Genesis = "../chain/gssmr/genesis.json" expected, err := genesis.NewGenesisFromJSONRaw(cfg.Init.Genesis) require.NoError(t, err) - // initialize node (initialize state database and load genesis data) + // initialise node (initialise state database and load genesis data) err = InitNode(cfg) require.NoError(t, err) diff --git a/dot/core/digest.go b/dot/core/digest.go index dc00e09b2d..a52d124a26 100644 --- a/dot/core/digest.go +++ b/dot/core/digest.go @@ -44,8 +44,8 @@ type DigestHandler struct { // block notification channels imported chan *types.Block importedID byte - finalized chan *types.Header - finalizedID byte + finalised chan *types.Header + finalisedID byte // GRANDPA changes grandpaScheduledChange *grandpaChange @@ -71,13 +71,13 @@ type resume struct { // NewDigestHandler returns a new DigestHandler func NewDigestHandler(blockState BlockState, epochState EpochState, babe BlockProducer, grandpa FinalityGadget, verifier Verifier) (*DigestHandler, error) { imported := make(chan *types.Block, 16) - finalized := make(chan *types.Header, 16) + finalised := make(chan *types.Header, 16) iid, err := blockState.RegisterImportedChannel(imported) if err != nil { return nil, err } - fid, err := blockState.RegisterFinalizedChannel(finalized) + fid, err := blockState.RegisterFinalizedChannel(finalised) if err != nil { return nil, err } @@ -99,8 +99,8 @@ func NewDigestHandler(blockState BlockState, epochState EpochState, babe BlockPr isBlockProducer: isBlockProducer, imported: imported, importedID: iid, - finalized: finalized, - finalizedID: fid, + finalised: finalised, + finalisedID: fid, }, nil } @@ -114,9 +114,9 @@ func (h *DigestHandler) Start() { func (h *DigestHandler) Stop() { h.cancel() h.blockState.UnregisterImportedChannel(h.importedID) - h.blockState.UnregisterFinalizedChannel(h.finalizedID) + h.blockState.UnregisterFinalizedChannel(h.finalisedID) close(h.imported) - close(h.finalized) + close(h.finalised) } // SetFinalityGadget sets the digest handler's grandpa instance @@ -205,7 +205,7 @@ func (h *DigestHandler) handleBlockImport(ctx context.Context) { func (h *DigestHandler) handleBlockFinalization(ctx context.Context) { for { select { - case header := <-h.finalized: + case header := <-h.finalised: if header == nil { continue } @@ -251,7 +251,7 @@ func (h *DigestHandler) handleGrandpaChangesOnFinalization(num *big.Int) { h.grandpaScheduledChange = nil } - // if blocks get finalized before forced change takes place, disregard it + // if blocks get finalised before forced change takes place, disregard it h.grandpaForcedChange = nil } @@ -346,7 +346,7 @@ func (h *DigestHandler) handleGrandpaOnDisabled(d *types.ConsensusDigest, _ *typ // TODO: this needs to be updated not to remove the authority from the list, // but to flag them as disabled. thus, if we are disabled, we should stop voting. - // if we receive vote or finalization messages, we should ignore anything signed by the + // if we receive vote or finalisation messages, we should ignore anything signed by the // disabled authority h.grandpa.UpdateAuthorities(next) return nil diff --git a/dot/core/digest_test.go b/dot/core/digest_test.go index fd2e1075f8..396e24758e 100644 --- a/dot/core/digest_test.go +++ b/dot/core/digest_test.go @@ -38,7 +38,7 @@ func newTestDigestHandler(t *testing.T, withBABE, withGrandpa bool) *DigestHandl stateSrvc.UseMemDB() gen, genTrie, genHeader := newTestGenesisWithTrieAndHeader(t) - err = stateSrvc.Initialize(gen, genHeader, genTrie) + err = stateSrvc.Initialise(gen, genHeader, genTrie) require.NoError(t, err) err = stateSrvc.Start() diff --git a/dot/core/errors.go b/dot/core/errors.go index fd3b77705e..0e33e5fdf1 100644 --- a/dot/core/errors.go +++ b/dot/core/errors.go @@ -45,7 +45,7 @@ var ErrNilRuntime = errors.New("cannot have nil runtime") // ErrNilBlockProducer is returned when trying to instantiate a block producing Service without a block producer var ErrNilBlockProducer = errors.New("cannot have nil BlockProducer") -// ErrNilFinalityGadget is returned when trying to instantiate a finalizing Service without a finality gadget +// ErrNilFinalityGadget is returned when trying to instantiate a finalising Service without a finality gadget var ErrNilFinalityGadget = errors.New("cannot have nil FinalityGadget") // ErrNilConsensusMessageHandler is returned when trying to instantiate a Service without a FinalityMessageHandler diff --git a/dot/core/service_test.go b/dot/core/service_test.go index 6fd46f8f23..b3ee59cccc 100644 --- a/dot/core/service_test.go +++ b/dot/core/service_test.go @@ -378,7 +378,7 @@ func TestService_HandleSubmittedExtrinsic(t *testing.T) { header, err := types.NewHeader(parentHash, common.Hash{}, common.Hash{}, big.NewInt(1), types.NewEmptyDigest()) require.NoError(t, err) - //initialize block header + //initialise block header err = s.rt.InitializeBlock(header) require.NoError(t, err) diff --git a/dot/core/test_helpers.go b/dot/core/test_helpers.go index fbe1d6bdd8..548f778d74 100644 --- a/dot/core/test_helpers.go +++ b/dot/core/test_helpers.go @@ -156,7 +156,7 @@ func NewTestService(t *testing.T, cfg *Config) *Service { stateSrvc = state.NewService(testDatadirPath, log.LvlInfo) stateSrvc.UseMemDB() - err = stateSrvc.Initialize(gen, genHeader, genTrie) + err = stateSrvc.Initialise(gen, genHeader, genTrie) require.Nil(t, err) err = stateSrvc.Start() diff --git a/dot/network/service_test.go b/dot/network/service_test.go index 2d099b0334..ba86435927 100644 --- a/dot/network/service_test.go +++ b/dot/network/service_test.go @@ -390,7 +390,7 @@ func TestPersistPeerStore(t *testing.T) { require.NotEmpty(t, nodeA.host.h.Peerstore().PeerInfo(nodeB.host.id()).Addrs) - // Stop a node and reinitialize a new node with same base path. + // Stop a node and reinitialise a new node with same base path. err = nodeA.Stop() require.NoError(t, err) diff --git a/dot/network/sync.go b/dot/network/sync.go index 0f588932fe..96be08abe3 100644 --- a/dot/network/sync.go +++ b/dot/network/sync.go @@ -59,7 +59,7 @@ func (s *Service) decodeSyncMessage(in []byte, peer peer.ID) (Message, error) { return msg, err } -// handleSyncMessage handles synchronization message types (BlockRequest and BlockResponse) +// handleSyncMessage handles synchronisation message types (BlockRequest and BlockResponse) func (s *Service) handleSyncMessage(stream libp2pnetwork.Stream, msg Message) error { if msg == nil { _ = stream.Close() @@ -320,12 +320,12 @@ func (q *syncQueue) benchmark() { } if before.Number.Int64() >= q.goal { - finalized, err := q.s.blockState.GetFinalizedHeader(0, 0) //nolint + finalised, err := q.s.blockState.GetFinalizedHeader(0, 0) //nolint if err != nil { continue } - logger.Info("πŸ’€ node waiting", "head", before.Number, "finalized", finalized.Number) + logger.Info("πŸ’€ node waiting", "head", before.Number, "finalised", finalised.Number) time.Sleep(time.Second * 5) continue } @@ -573,7 +573,7 @@ func (q *syncQueue) trySync(req *syncRequest) { q.updatePeerScore(req.to, -1) } - logger.Trace("trying peers in prioritized order...") + logger.Trace("trying peers in prioritised order...") syncPeers := q.getSortedPeers() for _, peer := range syncPeers { @@ -692,14 +692,14 @@ func (q *syncQueue) handleBlockJustification(data []*types.BlockData) { } func (q *syncQueue) handleBlockData(data []*types.BlockData) { - finalized, err := q.s.blockState.GetFinalizedHeader(0, 0) + finalised, err := q.s.blockState.GetFinalizedHeader(0, 0) if err != nil { panic(err) // this should never happen } end := data[len(data)-1].Number().Int64() - if end <= finalized.Number.Int64() { - logger.Debug("ignoring block data that is below our head", "got", end, "head", finalized.Number.Int64()) + if end <= finalised.Number.Int64() { + logger.Debug("ignoring block data that is below our head", "got", end, "head", finalised.Number.Int64()) q.pushRequest(uint64(end+1), blockRequestBufferSize, "") return } @@ -740,7 +740,7 @@ func (q *syncQueue) handleBlockDataFailure(idx int, err error, data []*types.Blo logger.Warn("failed to handle block data", "failed on block", q.currStart+int64(idx), "error", err) if errors.Is(err, chaindb.ErrKeyNotFound) || errors.Is(err, blocktree.ErrParentNotFound) { - finalized, err := q.s.blockState.GetFinalizedHeader(0, 0) + finalised, err := q.s.blockState.GetFinalizedHeader(0, 0) if err != nil { panic(err) } @@ -752,7 +752,7 @@ func (q *syncQueue) handleBlockDataFailure(idx int, err error, data []*types.Blo } // don't request a chain that's been dropped - if header.Number.Int64() <= finalized.Number.Int64() { + if header.Number.Int64() <= finalised.Number.Int64() { return } diff --git a/dot/node.go b/dot/node.go index 8038119e77..8c5df36f31 100644 --- a/dot/node.go +++ b/dot/node.go @@ -52,12 +52,12 @@ type Node struct { wg sync.WaitGroup } -// InitNode initializes a new dot node from the provided dot node configuration +// InitNode initialises a new dot node from the provided dot node configuration // and JSON formatted genesis file. func InitNode(cfg *Config) error { setupLogger(cfg) logger.Info( - "πŸ•ΈοΈ initializing node...", + "πŸ•ΈοΈ initialising node...", "name", cfg.Global.Name, "id", cfg.Global.ID, "basepath", cfg.Global.BasePath, @@ -98,14 +98,14 @@ func InitNode(cfg *Config) error { stateSrvc.BabeThresholdDenominator = cfg.Core.BabeThresholdDenominator } - // initialize state service with genesis data, block, and trie - err = stateSrvc.Initialize(gen, header, t) + // initialise state service with genesis data, block, and trie + err = stateSrvc.Initialise(gen, header, t) if err != nil { - return fmt.Errorf("failed to initialize state service: %s", err) + return fmt.Errorf("failed to initialise state service: %s", err) } logger.Info( - "node initialized", + "node initialised", "name", cfg.Global.Name, "id", cfg.Global.ID, "basepath", cfg.Global.BasePath, @@ -126,7 +126,7 @@ func NodeInitialized(basepath string, expected bool) bool { if os.IsNotExist(err) { if expected { logger.Debug( - "node has not been initialized", + "node has not been initialised", "basepath", basepath, "error", "failed to locate KEYREGISTRY file in data directory", ) @@ -134,7 +134,7 @@ func NodeInitialized(basepath string, expected bool) bool { return false } - // initialize database using data directory + // initialise database using data directory db, err := chaindb.NewBadgerDB(&chaindb.Config{ DataDir: basepath, }) @@ -147,11 +147,11 @@ func NodeInitialized(basepath string, expected bool) bool { return false } - // load genesis data from initialized node database + // load genesis data from initialised node database _, err = state.LoadGenesisData(db) if err != nil { logger.Warn( - "node has not been initialized", + "node has not been initialised", "basepath", basepath, "error", err, ) @@ -186,7 +186,7 @@ func NewNode(cfg *Config, ks *keystore.GlobalKeystore, stopFunc func()) (*Node, // Node Services logger.Info( - "πŸ•ΈοΈ initializing node services...", + "πŸ•ΈοΈ initialising node services...", "name", cfg.Global.Name, "id", cfg.Global.ID, "basepath", cfg.Global.BasePath, diff --git a/dot/node_test.go b/dot/node_test.go index 6411392378..9afc3175ff 100644 --- a/dot/node_test.go +++ b/dot/node_test.go @@ -225,7 +225,7 @@ func TestInitNode_LoadGenesisData(t *testing.T) { genesisHeader, err := types.NewHeader(common.NewHash([]byte{0}), genTrie.MustHash(), trie.EmptyHash, big.NewInt(0), types.Digest{}) require.NoError(t, err) - err = stateSrvc.Initialize(gen, genesisHeader, genTrie) + err = stateSrvc.Initialise(gen, genesisHeader, genTrie) require.NoError(t, err) err = stateSrvc.Start() diff --git a/dot/rpc/dot_up_codec.go b/dot/rpc/dot_up_codec.go index 14ce815762..013698128e 100644 --- a/dot/rpc/dot_up_codec.go +++ b/dot/rpc/dot_up_codec.go @@ -53,7 +53,7 @@ func (c *DotUpCodec) NewRequest(r *http.Request) rpc.CodecRequest { // DotUpCodecRequest decodes and encodes a single request. UpCodecRequest // implements gorilla/rpc.CodecRequest interface primarily by embedding // the CodecRequest from gorilla/rpc/json. By selectively adding -// CodecRequest methods to UpCodecRequest, we can modify that behavior +// CodecRequest methods to UpCodecRequest, we can modify that behaviour // while maintaining all the other remaining CodecRequest methods from // gorilla's rpc/json implementation type DotUpCodecRequest struct { diff --git a/dot/rpc/http.go b/dot/rpc/http.go index 4934cafa1b..76038e3847 100644 --- a/dot/rpc/http.go +++ b/dot/rpc/http.go @@ -107,7 +107,7 @@ func (h *HTTPServer) RegisterModules(mods []string) { case "dev": srvc = modules.NewDevModule(h.serverConfig.BlockProducerAPI, h.serverConfig.NetworkAPI) default: - h.logger.Warn("Unrecognized module", "module", mod) + h.logger.Warn("Unrecognised module", "module", mod) continue } diff --git a/dot/rpc/modules/author.go b/dot/rpc/modules/author.go index 2066e4d40c..5b9d68c4bd 100644 --- a/dot/rpc/modules/author.go +++ b/dot/rpc/modules/author.go @@ -68,8 +68,8 @@ type KeyRotateResponse []byte type ExtrinsicStatus struct { IsFuture bool IsReady bool - IsFinalized bool - AsFinalized common.Hash + Isfinalised bool + Asfinalised common.Hash IsUsurped bool AsUsurped common.Hash IsBroadcast bool diff --git a/dot/rpc/modules/chain.go b/dot/rpc/modules/chain.go index d4fded3689..bebf96d250 100644 --- a/dot/rpc/modules/chain.go +++ b/dot/rpc/modules/chain.go @@ -133,7 +133,7 @@ func (cm *ChainModule) GetHead(r *http.Request, req *ChainBlockNumberRequest, re return cm.GetBlockHash(r, req, res) } -// GetFinalizedHead returns the most recently finalized block hash +// GetFinalizedHead returns the most recently finalised block hash func (cm *ChainModule) GetFinalizedHead(r *http.Request, req *EmptyRequest, res *ChainHashResponse) error { h, err := cm.blockAPI.GetFinalizedHash(0, 0) if err != nil { @@ -144,7 +144,7 @@ func (cm *ChainModule) GetFinalizedHead(r *http.Request, req *EmptyRequest, res return nil } -// GetFinalizedHeadByRound returns the hash of the block finalized at the given round and setID +// GetFinalizedHeadByRound returns the hash of the block finalised at the given round and setID func (cm *ChainModule) GetFinalizedHeadByRound(r *http.Request, req *ChainFinalizedHeadRequest, res *ChainHashResponse) error { h, err := cm.blockAPI.GetFinalizedHash(req.Round, req.SetID) if err != nil { diff --git a/dot/rpc/modules/chain_test.go b/dot/rpc/modules/chain_test.go index 8f9f3cd6e4..cb00fcf714 100644 --- a/dot/rpc/modules/chain_test.go +++ b/dot/rpc/modules/chain_test.go @@ -283,7 +283,7 @@ func newTestStateService(t *testing.T) *state.Service { stateSrvc := state.NewService(testDatadirPath, log.LvlInfo) stateSrvc.UseMemDB() - err = stateSrvc.Initialize(gen, genesisHeader, genTrie) + err = stateSrvc.Initialise(gen, genesisHeader, genTrie) if err != nil { t.Fatal(err) } diff --git a/dot/rpc/modules/grandpa.go b/dot/rpc/modules/grandpa.go index dd9d15ffa7..0ceafe7a24 100644 --- a/dot/rpc/modules/grandpa.go +++ b/dot/rpc/modules/grandpa.go @@ -44,7 +44,7 @@ type ProveFinalityRequest struct { // ProveFinalityResponse is an optional SCALE encoded proof array type ProveFinalityResponse [][]byte -// ProveFinality for the provided block range. Returns NULL if there are no known finalized blocks in the range. If no authorities set is provided, the current one will be attempted. +// ProveFinality for the provided block range. Returns NULL if there are no known finalised blocks in the range. If no authorities set is provided, the current one will be attempted. func (gm *GrandpaModule) ProveFinality(r *http.Request, req *ProveFinalityRequest, res *ProveFinalityResponse) error { blocksToCheck, err := gm.blockAPI.SubChain(req.blockHashStart, req.blockHashEnd) if err != nil { diff --git a/dot/rpc/subscription/listeners.go b/dot/rpc/subscription/listeners.go index 46213e4e56..7f7916545f 100644 --- a/dot/rpc/subscription/listeners.go +++ b/dot/rpc/subscription/listeners.go @@ -112,7 +112,7 @@ func (l *BlockListener) Listen() { } } -// BlockFinalizedListener to handle listening for finalized blocks +// BlockFinalizedListener to handle listening for finalised blocks type BlockFinalizedListener struct { channel chan *types.Header wsconn WSConnAPI @@ -147,8 +147,8 @@ type ExtrinsicSubmitListener struct { importedChan chan *types.Block importedChanID byte importedHash common.Hash - finalizedChan chan *types.Header - finalizedChanID byte + finalisedChan chan *types.Header + finalisedChanID byte } // AuthorExtrinsicUpdates method name @@ -178,12 +178,12 @@ func (l *ExtrinsicSubmitListener) Listen() { } }() - // listen for finalized headers + // listen for finalised headers go func() { - for header := range l.finalizedChan { + for header := range l.finalisedChan { if reflect.DeepEqual(l.importedHash, header.Hash()) { resM := make(map[string]interface{}) - resM["finalized"] = header.Hash().String() + resM["finalised"] = header.Hash().String() l.wsconn.safeSend(newSubscriptionResponse(AuthorExtrinsicUpdates, l.subID, resM)) } } diff --git a/dot/rpc/subscription/listeners_test.go b/dot/rpc/subscription/listeners_test.go index 1ebf13c798..ebbe8d8119 100644 --- a/dot/rpc/subscription/listeners_test.go +++ b/dot/rpc/subscription/listeners_test.go @@ -125,7 +125,7 @@ func TestExtrinsicSubmitListener_Listen(t *testing.T) { mockConnection := &MockWSConnAPI{} esl := ExtrinsicSubmitListener{ importedChan: notifyImportedChan, - finalizedChan: notifyFinalizedChan, + finalisedChan: notifyFinalizedChan, wsconn: mockConnection, extrinsic: types.Extrinsic{1, 2, 3}, } @@ -151,7 +151,7 @@ func TestExtrinsicSubmitListener_Listen(t *testing.T) { notifyFinalizedChan <- header time.Sleep(time.Millisecond * 10) - resFinalized := map[string]interface{}{"finalized": block.Header.Hash().String()} - expectedFinalizedRespones := newSubscriptionResponse(AuthorExtrinsicUpdates, esl.subID, resFinalized) + resFinalised := map[string]interface{}{"finalised": block.Header.Hash().String()} + expectedFinalizedRespones := newSubscriptionResponse(AuthorExtrinsicUpdates, esl.subID, resFinalised) require.Equal(t, expectedFinalizedRespones, mockConnection.lastMessage) } diff --git a/dot/rpc/subscription/websocket.go b/dot/rpc/subscription/websocket.go index 9c03f7c77a..17d6b737a7 100644 --- a/dot/rpc/subscription/websocket.go +++ b/dot/rpc/subscription/websocket.go @@ -92,7 +92,7 @@ func (c *WSConn) HandleComm() { case "chain_subscribeFinalizedHeads": bfl, err3 := c.initBlockFinalizedListener(reqid) if err3 != nil { - logger.Warn("failed to create block finalized", "error", err3) + logger.Warn("failed to create block finalised", "error", err3) continue } c.startListener(bfl) @@ -271,7 +271,7 @@ func (c *WSConn) initExtrinsicWatch(reqID float64, params interface{}) (uint, er importedChan: make(chan *types.Block), wsconn: c, extrinsic: types.Extrinsic(extBytes), - finalizedChan: make(chan *types.Header), + finalisedChan: make(chan *types.Header), } if c.BlockAPI == nil { @@ -282,7 +282,7 @@ func (c *WSConn) initExtrinsicWatch(reqID float64, params interface{}) (uint, er return 0, err } - esl.finalizedChanID, err = c.BlockAPI.RegisterFinalizedChannel(esl.finalizedChan) + esl.finalisedChanID, err = c.BlockAPI.RegisterFinalizedChannel(esl.finalisedChan) if err != nil { return 0, err } diff --git a/dot/services.go b/dot/services.go index e523b88d5d..3f7d8ecbf9 100644 --- a/dot/services.go +++ b/dot/services.go @@ -52,12 +52,12 @@ func newInMemoryDB(path string) (chaindb.Database, error) { // State Service -// createStateService creates the state service and initialize state database +// createStateService creates the state service and initialise state database func createStateService(cfg *Config) (*state.Service, error) { logger.Debug("creating state service...") stateSrvc := state.NewService(cfg.Global.BasePath, cfg.Log.StateLvl) - // start state service (initialize state database) + // start state service (initialise state database) err := stateSrvc.Start() if err != nil { return nil, fmt.Errorf("failed to start state service: %s", err) @@ -204,7 +204,7 @@ func createBABEService(cfg *Config, rt runtime.Instance, st *state.Service, ks k // create new BABE service bs, err := babe.NewService(bcfg) if err != nil { - logger.Error("failed to initialize BABE service", "error", err) + logger.Error("failed to initialise BABE service", "error", err) return nil, err } diff --git a/dot/state/block.go b/dot/state/block.go index 640906386d..2ed76e7a87 100644 --- a/dot/state/block.go +++ b/dot/state/block.go @@ -46,9 +46,9 @@ type BlockState struct { // block notifiers imported map[byte]chan<- *types.Block - finalized map[byte]chan<- *types.Header + finalised map[byte]chan<- *types.Header importedLock sync.RWMutex - finalizedLock sync.RWMutex + finalisedLock sync.RWMutex pruneKeyCh chan *types.Header } @@ -64,7 +64,7 @@ func NewBlockState(db chaindb.Database, bt *blocktree.BlockTree) (*BlockState, e baseDB: db, db: chaindb.NewTable(db, blockPrefix), imported: make(map[byte]chan<- *types.Block), - finalized: make(map[byte]chan<- *types.Header), + finalised: make(map[byte]chan<- *types.Header), pruneKeyCh: make(chan *types.Header, pruneKeyBufferSize), } @@ -77,14 +77,14 @@ func NewBlockState(db chaindb.Database, bt *blocktree.BlockTree) (*BlockState, e return bs, nil } -// NewBlockStateFromGenesis initializes a BlockState from a genesis header, saving it to the database located at basePath +// NewBlockStateFromGenesis initialises a BlockState from a genesis header, saving it to the database located at basePath func NewBlockStateFromGenesis(db chaindb.Database, header *types.Header) (*BlockState, error) { bs := &BlockState{ bt: blocktree.NewBlockTreeFromRoot(header, db), baseDB: db, db: chaindb.NewTable(db, blockPrefix), imported: make(map[byte]chan<- *types.Block), - finalized: make(map[byte]chan<- *types.Header), + finalised: make(map[byte]chan<- *types.Header), pruneKeyCh: make(chan *types.Header, pruneKeyBufferSize), } @@ -110,7 +110,7 @@ func NewBlockStateFromGenesis(db chaindb.Database, header *types.Header) (*Block bs.genesisHash = header.Hash() - // set the latest finalized head to the genesis header + // set the latest finalised head to the genesis header err = bs.SetFinalizedHash(bs.genesisHash, 0, 0) if err != nil { return nil, err @@ -366,7 +366,7 @@ func (bs *BlockState) SetBlockBody(hash common.Hash, body *types.Body) error { return bs.db.Put(blockBodyKey(hash), body.AsOptional().Value()) } -// HasFinalizedBlock returns true if there is a finalized block for a given round and setID, false otherwise +// HasFinalizedBlock returns true if there is a finalised block for a given round and setID, false otherwise func (bs *BlockState) HasFinalizedBlock(round, setID uint64) (bool, error) { // get current round r, err := bs.GetRound() @@ -374,15 +374,15 @@ func (bs *BlockState) HasFinalizedBlock(round, setID uint64) (bool, error) { return false, err } - // round that is being queried for has not yet finalized + // round that is being queried for has not yet finalised if round > r { - return false, fmt.Errorf("round not yet finalized") + return false, fmt.Errorf("round not yet finalised") } return bs.db.Has(finalizedHashKey(round, setID)) } -// GetFinalizedHeader returns the latest finalized block header +// GetFinalizedHeader returns the latest finalised block header func (bs *BlockState) GetFinalizedHeader(round, setID uint64) (*types.Header, error) { h, err := bs.GetFinalizedHash(round, setID) if err != nil { @@ -397,7 +397,7 @@ func (bs *BlockState) GetFinalizedHeader(round, setID uint64) (*types.Header, er return header, nil } -// GetFinalizedHash gets the latest finalized block header +// GetFinalizedHash gets the latest finalised block header func (bs *BlockState) GetFinalizedHash(round, setID uint64) (common.Hash, error) { // get current round r, err := bs.GetRound() @@ -405,9 +405,9 @@ func (bs *BlockState) GetFinalizedHash(round, setID uint64) (common.Hash, error) return common.Hash{}, err } - // round that is being queried for has not yet finalized + // round that is being queried for has not yet finalised if round > r { - return common.Hash{}, fmt.Errorf("round not yet finalized") + return common.Hash{}, fmt.Errorf("round not yet finalised") } h, err := bs.db.Get(finalizedHashKey(round, setID)) @@ -418,7 +418,7 @@ func (bs *BlockState) GetFinalizedHash(round, setID uint64) (common.Hash, error) return common.NewHash(h), nil } -// SetFinalizedHash sets the latest finalized block header +// SetFinalizedHash sets the latest finalised block header func (bs *BlockState) SetFinalizedHash(hash common.Hash, round, setID uint64) error { bs.Lock() defer bs.Unlock() @@ -450,7 +450,7 @@ func (bs *BlockState) SetFinalizedHash(hash common.Hash, round, setID uint64) er return bs.db.Put(finalizedHashKey(round, setID), hash[:]) } -// SetRound sets the latest finalized GRANDPA round in the db +// SetRound sets the latest finalised GRANDPA round in the db // TODO: this needs to use both setID and round func (bs *BlockState) SetRound(round uint64) error { buf := make([]byte, 8) @@ -458,7 +458,7 @@ func (bs *BlockState) SetRound(round uint64) error { return bs.db.Put(common.LatestFinalizedRoundKey, buf) } -// GetRound gets the latest finalized GRANDPA round from the db +// GetRound gets the latest finalised GRANDPA round from the db func (bs *BlockState) GetRound() (uint64, error) { r, err := bs.db.Get(common.LatestFinalizedRoundKey) if err != nil { diff --git a/dot/state/block_notify.go b/dot/state/block_notify.go index 68f415d870..1e9705d73b 100644 --- a/dot/state/block_notify.go +++ b/dot/state/block_notify.go @@ -49,28 +49,28 @@ func (bs *BlockState) RegisterImportedChannel(ch chan<- *types.Block) (byte, err return id, nil } -// RegisterFinalizedChannel registers a channel for block notification upon block finalization. +// RegisterFinalizedChannel registers a channel for block notification upon block finalisation. // It returns the channel ID (used for unregistering the channel) func (bs *BlockState) RegisterFinalizedChannel(ch chan<- *types.Header) (byte, error) { - bs.finalizedLock.RLock() + bs.finalisedLock.RLock() - if len(bs.finalized) == 256 { + if len(bs.finalised) == 256 { return 0, errors.New("channel limit reached") } var id byte for { id = generateID() - if bs.finalized[id] == nil { + if bs.finalised[id] == nil { break } } - bs.finalizedLock.RUnlock() + bs.finalisedLock.RUnlock() - bs.finalizedLock.Lock() - bs.finalized[id] = ch - bs.finalizedLock.Unlock() + bs.finalisedLock.Lock() + bs.finalised[id] = ch + bs.finalisedLock.Unlock() return id, nil } @@ -83,13 +83,13 @@ func (bs *BlockState) UnregisterImportedChannel(id byte) { delete(bs.imported, id) } -// UnregisterFinalizedChannel removes the block finalization notification channel with the given ID. +// UnregisterFinalizedChannel removes the block finalisation notification channel with the given ID. // A channel must be unregistered before closing it. func (bs *BlockState) UnregisterFinalizedChannel(id byte) { - bs.finalizedLock.Lock() - defer bs.finalizedLock.Unlock() + bs.finalisedLock.Lock() + defer bs.finalisedLock.Unlock() - delete(bs.finalized, id) + delete(bs.finalised, id) } func (bs *BlockState) notifyImported(block *types.Block) { @@ -112,22 +112,22 @@ func (bs *BlockState) notifyImported(block *types.Block) { } func (bs *BlockState) notifyFinalized(hash common.Hash) { - bs.finalizedLock.RLock() - defer bs.finalizedLock.RUnlock() + bs.finalisedLock.RLock() + defer bs.finalisedLock.RUnlock() - if len(bs.finalized) == 0 { + if len(bs.finalised) == 0 { return } header, err := bs.GetHeader(hash) if err != nil { - logger.Error("failed to get finalized header", "hash", hash, "error", err) + logger.Error("failed to get finalised header", "hash", hash, "error", err) return } - logger.Trace("notifying finalized block chans...", "chans", bs.finalized) + logger.Trace("notifying finalised block chans...", "chans", bs.finalised) - for _, ch := range bs.finalized { + for _, ch := range bs.finalised { go func(ch chan<- *types.Header) { select { case ch <- header: @@ -138,6 +138,7 @@ func (bs *BlockState) notifyFinalized(hash common.Hash) { } func generateID() byte { + // skipcq: GSC-G404 id := rand.Intn(256) //nolint return byte(id) } diff --git a/dot/state/block_notify_test.go b/dot/state/block_notify_test.go index a38790eb5a..3e8054a4fe 100644 --- a/dot/state/block_notify_test.go +++ b/dot/state/block_notify_test.go @@ -68,7 +68,7 @@ func TestFinalizedChannel(t *testing.T) { select { case <-ch: case <-time.After(testMessageTimeout): - t.Fatal("did not receive finalized block") + t.Fatal("did not receive finalised block") } } } @@ -138,7 +138,7 @@ func TestFinalizedChannel_Multi(t *testing.T) { select { case <-ch: case <-time.After(testMessageTimeout): - t.Error("did not receive finalized block: ch=", i) + t.Error("did not receive finalised block: ch=", i) } wg.Done() }(i, ch) diff --git a/dot/state/block_test.go b/dot/state/block_test.go index 693dd95a42..fc54bbceea 100644 --- a/dot/state/block_test.go +++ b/dot/state/block_test.go @@ -311,7 +311,7 @@ func TestFinalization_DeleteBlock(t *testing.T) { // require.True(t, has, n) // } - // pick block to finalize + // pick block to finalise fin := leaves[len(leaves)-1] err := bs.SetFinalizedHash(fin, 1, 1) require.NoError(t, err) @@ -328,7 +328,7 @@ func TestFinalization_DeleteBlock(t *testing.T) { return false } - // assert that every block except finalized has been deleted + // assert that every block except finalised has been deleted for _, b := range before { if b == fin { continue @@ -338,12 +338,12 @@ func TestFinalization_DeleteBlock(t *testing.T) { continue } - isFinalized, err := btBefore.IsDescendantOf(b, fin) + isFinalised, err := btBefore.IsDescendantOf(b, fin) require.NoError(t, err) has, err := bs.HasHeader(b) require.NoError(t, err) - if isFinalized { + if isFinalised { require.True(t, has) } else { require.False(t, has) @@ -351,7 +351,7 @@ func TestFinalization_DeleteBlock(t *testing.T) { has, err = bs.HasBlockBody(b) require.NoError(t, err) - if isFinalized { + if isFinalised { require.True(t, has) } else { require.False(t, has) @@ -359,7 +359,7 @@ func TestFinalization_DeleteBlock(t *testing.T) { // has, err = bs.HasArrivalTime(b) // require.NoError(t, err) - // if isFinalized && b != bs.genesisHash { + // if isFinalised && b != bs.genesisHash { // require.True(t, has, b) // } else { // require.False(t, has) diff --git a/dot/state/service.go b/dot/state/service.go index 67839c740d..3bc243e067 100644 --- a/dot/state/service.go +++ b/dot/state/service.go @@ -71,7 +71,7 @@ func NewService(path string, lvl log.Lvl) *Service { } // UseMemDB tells the service to use an in-memory key-value store instead of a persistent database. -// This should be called after NewService, and before Initialize. +// This should be called after NewService, and before Initialise. // This should only be used for testing. func (s *Service) UseMemDB() { s.isMemDB = true @@ -82,9 +82,9 @@ func (s *Service) DB() chaindb.Database { return s.db } -// Initialize initializes the genesis state of the DB using the given storage trie. The trie should be loaded with the genesis storage state. -// This only needs to be called during genesis initialization of the node; it doesn't need to be called during normal startup. -func (s *Service) Initialize(gen *genesis.Genesis, header *types.Header, t *trie.Trie) error { +// Initialise initialises the genesis state of the DB using the given storage trie. The trie should be loaded with the genesis storage state. +// This only needs to be called during genesis initialisation of the node; it doesn't need to be called during normal startup. +func (s *Service) Initialise(gen *genesis.Genesis, header *types.Header, t *trie.Trie) error { var db chaindb.Database cfg := &chaindb.Config{} @@ -101,7 +101,7 @@ func (s *Service) Initialize(gen *genesis.Genesis, header *types.Header, t *trie cfg.DataDir = basepath - // initialize database using data directory + // initialise database using data directory db, err = chaindb.NewBadgerDB(cfg) if err != nil { return fmt.Errorf("failed to create database: %s", err) @@ -224,7 +224,7 @@ func (s *Service) storeInitialValues(db chaindb.Database, data *genesis.Data, he return nil } -// Start initializes the Storage database and the Block database. +// Start initialises the Storage database and the Block database. func (s *Service) Start() error { if !s.isMemDB && (s.Storage != nil || s.Block != nil || s.Epoch != nil) { return nil @@ -241,7 +241,7 @@ func (s *Service) Start() error { DataDir: basepath, } - // initialize database + // initialise database db, err = chaindb.NewBadgerDB(cfg) if err != nil { return err @@ -271,17 +271,17 @@ func (s *Service) Start() error { } // if blocktree head isn't "best hash", then the node shutdown abnormally. - // restore state from last finalized hash. + // restore state from last finalised hash. btHead := bt.DeepestBlockHash() if !bytes.Equal(btHead[:], bestHash[:]) { - logger.Info("detected abnormal node shutdown, restoring from last finalized block") + logger.Info("detected abnormal node shutdown, restoring from last finalised block") - lastFinalized, err := s.Block.GetFinalizedHeader(0, 0) //nolint + lastFinalised, err := s.Block.GetFinalizedHeader(0, 0) //nolint if err != nil { - return fmt.Errorf("failed to get latest finalized block: %w", err) + return fmt.Errorf("failed to get latest finalised block: %w", err) } - s.Block.bt = blocktree.NewBlockTreeFromRoot(lastFinalized, db) + s.Block.bt = blocktree.NewBlockTreeFromRoot(lastFinalised, db) } // create storage state @@ -419,7 +419,7 @@ func (s *Service) Import(header *types.Header, t *trie.Trie, firstSlot uint64) e } else { var err error - // initialize database using data directory + // initialise database using data directory s.db, err = chaindb.NewBadgerDB(cfg) if err != nil { return fmt.Errorf("failed to create database: %s", err) diff --git a/dot/state/service_test.go b/dot/state/service_test.go index f603c5a065..fff41739f6 100644 --- a/dot/state/service_test.go +++ b/dot/state/service_test.go @@ -63,7 +63,7 @@ func TestService_Start(t *testing.T) { defer utils.RemoveTestDir(t) genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t) - err := state.Initialize(genData, genesisHeader, genTrie) + err := state.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) err = state.Start() @@ -73,18 +73,18 @@ func TestService_Start(t *testing.T) { require.NoError(t, err) } -func TestService_Initialize(t *testing.T) { +func TestService_Initialise(t *testing.T) { state := newTestService(t) defer utils.RemoveTestDir(t) genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t) - err := state.Initialize(genData, genesisHeader, genTrie) + err := state.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) genesisHeader, err = types.NewHeader(common.NewHash([]byte{77}), genTrie.MustHash(), trie.EmptyHash, big.NewInt(0), types.Digest{}) require.NoError(t, err) - err = state.Initialize(genData, genesisHeader, genTrie) + err = state.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) err = state.Start() @@ -99,7 +99,7 @@ func TestMemDB_Start(t *testing.T) { state := newTestMemDBService() genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t) - err := state.Initialize(genData, genesisHeader, genTrie) + err := state.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) err = state.Start() @@ -118,7 +118,7 @@ func TestService_BlockTree(t *testing.T) { stateA := NewService(testDir, log.LvlTrace) genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t) - err := stateA.Initialize(genData, genesisHeader, genTrie) + err := stateA.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) err = stateA.Start() @@ -148,7 +148,7 @@ func TestService_PruneStorage(t *testing.T) { serv.UseMemDB() genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t) - err := serv.Initialize(genData, genesisHeader, genTrie) + err := serv.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) err = serv.Start() @@ -171,13 +171,13 @@ func TestService_PruneStorage(t *testing.T) { err = serv.Storage.StoreTrie(trieState) require.NoError(t, err) - // Only finalize a block at height 3 + // Only finalise a block at height 3 if i == 2 { toFinalize = block.Header.Hash() } } - // add some blocks to prune, on a different chain from the finalized block + // add some blocks to prune, on a different chain from the finalised block prunedArr := []prunedBlock{} parentHash := serv.Block.GenesisHash() for i := 0; i < 3; i++ { @@ -202,7 +202,7 @@ func TestService_PruneStorage(t *testing.T) { parentHash = block.Header.Hash() } - // finalize a block + // finalise a block serv.Block.SetFinalizedHash(toFinalize, 0, 0) time.Sleep(1 * time.Second) @@ -223,7 +223,7 @@ func TestService_Rewind(t *testing.T) { serv.UseMemDB() genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t) - err := serv.Initialize(genData, genesisHeader, genTrie) + err := serv.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) err = serv.Start() @@ -246,7 +246,7 @@ func TestService_Import(t *testing.T) { serv.UseMemDB() genData, genTrie, genesisHeader := newTestGenesisWithTrieAndHeader(t) - err := serv.Initialize(genData, genesisHeader, genTrie) + err := serv.Initialise(genData, genesisHeader, genTrie) require.NoError(t, err) tr := trie.NewEmptyTrie() diff --git a/dot/sync/syncer.go b/dot/sync/syncer.go index e92b4e7461..380b5b9d4c 100644 --- a/dot/sync/syncer.go +++ b/dot/sync/syncer.go @@ -46,7 +46,7 @@ type Service struct { blockProducer BlockProducer finalityGadget FinalityGadget - // Synchronization variables + // Synchronisation variables synced bool highestSeenBlock *big.Int // highest block number we have seen runtime runtime.Instance @@ -383,7 +383,7 @@ func (s *Service) handleJustification(header *types.Header, justification []byte err = s.blockState.SetFinalizedHash(header.Hash(), 0, 0) if err != nil { - logger.Error("failed to set finalized hash", "error", err) + logger.Error("failed to set finalised hash", "error", err) return } @@ -393,7 +393,7 @@ func (s *Service) handleJustification(header *types.Header, justification []byte return } - logger.Info("πŸ”¨ finalized block", "number", header.Number, "hash", header.Hash()) + logger.Info("πŸ”¨ finalised block", "number", header.Number, "hash", header.Hash()) } func (s *Service) handleRuntimeChanges(newState *rtstorage.TrieState) error { diff --git a/dot/sync/syncer_test.go b/dot/sync/syncer_test.go index eeafd7f6ea..7fae639cc8 100644 --- a/dot/sync/syncer_test.go +++ b/dot/sync/syncer_test.go @@ -69,7 +69,7 @@ func newTestSyncer(t *testing.T) *Service { stateSrvc.UseMemDB() gen, genTrie, genHeader := newTestGenesisWithTrieAndHeader(t) - err := stateSrvc.Initialize(gen, genHeader, genTrie) + err := stateSrvc.Initialise(gen, genHeader, genTrie) require.NoError(t, err) err = stateSrvc.Start() diff --git a/dot/telemetry/telemetry.go b/dot/telemetry/telemetry.go index 4577a4a1f3..f57b063535 100644 --- a/dot/telemetry/telemetry.go +++ b/dot/telemetry/telemetry.go @@ -42,11 +42,11 @@ type MyJSONFormatter struct { // Format function for handling JSON formatting, this overrides default logging formatter to remove // log level, line number and timestamp func (f *MyJSONFormatter) Format(entry *log.Entry) ([]byte, error) { - serialized, err := json.Marshal(entry.Data) + serialised, err := json.Marshal(entry.Data) if err != nil { return nil, fmt.Errorf("failed to marshal fields to JSON, %w", err) } - return append(serialized, '\n'), nil + return append(serialised, '\n'), nil } var ( diff --git a/dot/types/block.go b/dot/types/block.go index 30c6759474..7f77c50438 100644 --- a/dot/types/block.go +++ b/dot/types/block.go @@ -36,7 +36,7 @@ func NewBlock(header *Header, body *Body) *Block { } } -// NewEmptyBlock returns a new Block with an initialized but empty Header and Body +// NewEmptyBlock returns a new Block with an initialised but empty Header and Body func NewEmptyBlock() *Block { return &Block{ Header: new(Header), diff --git a/dot/types/roles.go b/dot/types/roles.go index 551a35d1db..3d7275c588 100644 --- a/dot/types/roles.go +++ b/dot/types/roles.go @@ -23,6 +23,6 @@ const ( FullNodeRole = byte(1) // LightClientRole runs a light client LightClientRole = byte(2) - // AuthorityRole runs the node as a block-producing and finalizing node + // AuthorityRole runs the node as a block-producing and finalising node AuthorityRole = byte(4) ) diff --git a/lib/babe/babe_test.go b/lib/babe/babe_test.go index 295b50ff70..a1a7058f3e 100644 --- a/lib/babe/babe_test.go +++ b/lib/babe/babe_test.go @@ -116,7 +116,7 @@ func createTestService(t *testing.T, cfg *ServiceConfig) *Service { genesisBABEConfig.EpochLength = cfg.EpochLength } - err = dbSrv.Initialize(gen, genHeader, genTrie) + err = dbSrv.Initialise(gen, genHeader, genTrie) require.NoError(t, err) err = dbSrv.Start() diff --git a/lib/babe/build.go b/lib/babe/build.go index f47d416d39..6363f7da29 100644 --- a/lib/babe/build.go +++ b/lib/babe/build.go @@ -56,13 +56,13 @@ func (b *Service) buildBlock(parent *types.Header, slot Slot) (*types.Block, err return nil, err } - // initialize block header + // initialise block header err = b.rt.InitializeBlock(header) if err != nil { return nil, err } - logger.Trace("initialized block") + logger.Trace("initialised block") // add block inherents inherents, err := b.buildBlockInherents(slot) @@ -77,14 +77,14 @@ func (b *Service) buildBlock(parent *types.Header, slot Slot) (*types.Block, err logger.Trace("built block extrinsics") - // finalize block + // finalise block header, err = b.rt.FinalizeBlock() if err != nil { b.addToQueue(included) - return nil, fmt.Errorf("cannot finalize block: %s", err) + return nil, fmt.Errorf("cannot finalise block: %s", err) } - logger.Trace("finalized block") + logger.Trace("finalised block") header.ParentHash = parent.Hash() header.Number.Add(parent.Number, big.NewInt(1)) diff --git a/lib/babe/build_test.go b/lib/babe/build_test.go index 758a523ab6..839a9f432d 100644 --- a/lib/babe/build_test.go +++ b/lib/babe/build_test.go @@ -159,7 +159,7 @@ func TestApplyExtrinsic(t *testing.T) { header, err := types.NewHeader(parentHash, common.Hash{}, common.Hash{}, big.NewInt(1), types.NewEmptyDigest()) require.NoError(t, err) - //initialize block header + //initialise block header err = babeService.rt.InitializeBlock(header) require.NoError(t, err) @@ -194,7 +194,7 @@ func TestBuildAndApplyExtrinsic(t *testing.T) { header, err := types.NewHeader(parentHash, common.Hash{}, common.Hash{}, big.NewInt(1), types.NewEmptyDigest()) require.NoError(t, err) - //initialize block header + //initialise block header err = babeService.rt.InitializeBlock(header) require.NoError(t, err) diff --git a/lib/babe/verify_test.go b/lib/babe/verify_test.go index 64c772f4db..ca24319f43 100644 --- a/lib/babe/verify_test.go +++ b/lib/babe/verify_test.go @@ -44,7 +44,7 @@ func newTestVerificationManager(t *testing.T, genCfg *types.BabeConfiguration) * } gen, genTrie, genHeader := newTestGenesisWithTrieAndHeader(t) - err = dbSrv.Initialize(gen, genHeader, genTrie) + err = dbSrv.Initialise(gen, genHeader, genTrie) require.NoError(t, err) err = dbSrv.Start() diff --git a/lib/blocktree/blocktree.go b/lib/blocktree/blocktree.go index 6e9547da35..274fe58a7e 100644 --- a/lib/blocktree/blocktree.go +++ b/lib/blocktree/blocktree.go @@ -49,8 +49,8 @@ func NewEmptyBlockTree(db database.Database) *BlockTree { } } -// NewBlockTreeFromRoot initializes a blocktree with a root block. The root block is always the most recently -// finalized block (ie the genesis block if the node is just starting.) +// NewBlockTreeFromRoot initialises a blocktree with a root block. The root block is always the most recently +// finalised block (ie the genesis block if the node is just starting.) func NewBlockTreeFromRoot(root *types.Header, db database.Database) *BlockTree { head := &node{ hash: root.Hash(), @@ -172,15 +172,15 @@ func (bt *BlockTree) getNode(h Hash) *node { // Prune sets the given hash as the new blocktree root, removing all nodes that are not the new root node or its descendant // It returns an array of hashes that have been pruned -func (bt *BlockTree) Prune(finalized Hash) (pruned []Hash) { +func (bt *BlockTree) Prune(finalised Hash) (pruned []Hash) { bt.Lock() defer bt.Unlock() - if finalized == bt.head.hash { + if finalised == bt.head.hash { return pruned } - n := bt.getNode(finalized) + n := bt.getNode(finalised) if n == nil { return pruned } @@ -192,7 +192,7 @@ func (bt *BlockTree) Prune(finalized Hash) (pruned []Hash) { return pruned } -// String utilizes github.com/disiqueira/gotree to create a printable tree +// String utilises github.com/disiqueira/gotree to create a printable tree func (bt *BlockTree) String() string { bt.RLock() defer bt.RUnlock() diff --git a/lib/blocktree/blocktree_test.go b/lib/blocktree/blocktree_test.go index 6db2df87e1..8a8032d5ff 100644 --- a/lib/blocktree/blocktree_test.go +++ b/lib/blocktree/blocktree_test.go @@ -364,18 +364,18 @@ func TestBlockTree_Prune(t *testing.T) { copy := bt.DeepCopy() - // pick some block to finalize - finalized := bt.head.children[0].children[0].children[0] - pruned := bt.Prune(finalized.hash) + // pick some block to finalise + finalised := bt.head.children[0].children[0].children[0] + pruned := bt.Prune(finalised.hash) for _, prunedHash := range pruned { prunedNode := copy.getNode(prunedHash) - if prunedNode.isDescendantOf(finalized) { - t.Fatal("pruned node that's descendant of finalized node!!") + if prunedNode.isDescendantOf(finalised) { + t.Fatal("pruned node that's descendant of finalised node!!") } - if finalized.isDescendantOf(prunedNode) { - t.Fatal("pruned an ancestor of the finalized node!!") + if finalised.isDescendantOf(prunedNode) { + t.Fatal("pruned an ancestor of the finalised node!!") } } } diff --git a/lib/blocktree/node.go b/lib/blocktree/node.go index 788da60309..4ec9c89192 100644 --- a/lib/blocktree/node.go +++ b/lib/blocktree/node.go @@ -206,8 +206,8 @@ func (n *node) deepCopy(parent *node) *node { return nCopy } -func (n *node) prune(finalized *node, pruned []Hash) []Hash { - if finalized == nil { +func (n *node) prune(finalised *node, pruned []Hash) []Hash { + if finalised == nil { return pruned } @@ -215,23 +215,23 @@ func (n *node) prune(finalized *node, pruned []Hash) []Hash { pruned = []Hash{} } - // if this is a descedent of the finalized block, keep it - // all descendents of this block will also be descendents of the finalized block, + // if this is a descedent of the finalised block, keep it + // all descendents of this block will also be descendents of the finalised block, // so don't need to check any of those - if n.isDescendantOf(finalized) { + if n.isDescendantOf(finalised) { return pruned } - // if it's not an ancestor the finalized block, prune it - if !finalized.isDescendantOf(n) { + // if it's not an ancestor the finalised block, prune it + if !finalised.isDescendantOf(n) { pruned = append(pruned, n.hash) n.parent.deleteChild(n) } - // if this is an ancestor of the finalized block, keep it, + // if this is an ancestor of the finalised block, keep it, // and check its children for _, child := range n.children { - pruned = child.prune(finalized, pruned) + pruned = child.prune(finalised, pruned) } return pruned diff --git a/lib/blocktree/node_test.go b/lib/blocktree/node_test.go index f630d8df8c..b2c37c3d3f 100644 --- a/lib/blocktree/node_test.go +++ b/lib/blocktree/node_test.go @@ -59,18 +59,18 @@ func TestNode_Prune(t *testing.T) { copy := bt.DeepCopy() - // pick some block to finalize - finalized := bt.head.children[0].children[0].children[0] - pruned := bt.head.prune(finalized, nil) + // pick some block to finalise + finalised := bt.head.children[0].children[0].children[0] + pruned := bt.head.prune(finalised, nil) for _, prunedHash := range pruned { prunedNode := copy.getNode(prunedHash) - if prunedNode.isDescendantOf(finalized) { - t.Fatal("pruned node that's descendant of finalized node!!") + if prunedNode.isDescendantOf(finalised) { + t.Fatal("pruned node that's descendant of finalised node!!") } - if finalized.isDescendantOf(prunedNode) { - t.Fatal("pruned an ancestor of the finalized node!!") + if finalised.isDescendantOf(prunedNode) { + t.Fatal("pruned an ancestor of the finalised node!!") } } } diff --git a/lib/common/db_keys.go b/lib/common/db_keys.go index 05e431c09d..249665dcc9 100644 --- a/lib/common/db_keys.go +++ b/lib/common/db_keys.go @@ -17,18 +17,18 @@ package common var ( - // BestBlockHashKey is the db location the hash of the best (unfinalized) block header. + // BestBlockHashKey is the db location the hash of the best (unfinalised) block header. BestBlockHashKey = []byte("best_hash") // LatestStorageHashKey is the db location of the hash of the latest storage trie. LatestStorageHashKey = []byte("latest_storage_hash") - // FinalizedBlockHashKey is the db location of the hash of the latest finalized block header. - FinalizedBlockHashKey = []byte("finalized_head") + // FinalizedBlockHashKey is the db location of the hash of the latest finalised block header. + FinalizedBlockHashKey = []byte("finalised_head") // GenesisDataKey is the db location of the genesis data. GenesisDataKey = []byte("genesis_data") // BlockTreeKey is the db location of the encoded block tree structure. BlockTreeKey = []byte("block_tree") - // LatestFinalizedRoundKey is the key where the last finalized grandpa round is stored - LatestFinalizedRoundKey = []byte("latest_finalized_round") + // LatestFinalizedRoundKey is the key where the last finalised grandpa round is stored + LatestFinalizedRoundKey = []byte("latest_finalised_round") // WorkingStorageHashKey is the storage key that the runtime uses to store the latest working state root. WorkingStorageHashKey = []byte("working_storage_hash") ) diff --git a/lib/grandpa/errors.go b/lib/grandpa/errors.go index 73042e6b32..df529358d2 100644 --- a/lib/grandpa/errors.go +++ b/lib/grandpa/errors.go @@ -52,7 +52,7 @@ var ErrEquivocation = errors.New("vote is equivocatory") // ErrVoterNotFound is returned when trying to validate a vote for a voter that isn't in the voter set var ErrVoterNotFound = errors.New("voter is not in voter set") -// ErrDescendantNotFound is returned when trying to validate a vote for a block that isn't a descendant of the last finalized block +// ErrDescendantNotFound is returned when trying to validate a vote for a block that isn't a descendant of the last finalised block var ErrDescendantNotFound = blocktree.ErrDescendantNotFound // ErrNoPreVotedBlock is returned when there is no pre-voted block for a round. @@ -70,9 +70,9 @@ var ErrCannotDecodeSubround = errors.New("cannot decode invalid subround value") var ErrInvalidMessageType = errors.New("cannot decode invalid message type") // ErrNotCommitMessage is returned when calling GetFinalizedHash on a message that isn't a CommitMessage -var ErrNotCommitMessage = errors.New("cannot get finalized hash from VoteMessage") +var ErrNotCommitMessage = errors.New("cannot get finalised hash from VoteMessage") -// ErrNoJustification is returned when no justification can be found for a block, ie. it has not been finalized +// ErrNoJustification is returned when no justification can be found for a block, ie. it has not been finalised var ErrNoJustification = errors.New("no justification found for block") // ErrMinVotesNotMet is returned when the number of votes is less than the required minimum in a Justification @@ -84,7 +84,7 @@ var ErrInvalidCatchUpRound = errors.New("catch up request is for future round") // ErrInvalidCatchUpResponseRound is returned when a catch-up response is received with an invalid round var ErrInvalidCatchUpResponseRound = errors.New("catch up response is not for previous round") -// ErrGHOSTlessCatchUp is returned when a catch up response does not contain a valid grandpa-GHOST (ie. finalized block) +// ErrGHOSTlessCatchUp is returned when a catch up response does not contain a valid grandpa-GHOST (ie. finalised block) var ErrGHOSTlessCatchUp = errors.New("catch up response does not contain grandpa-GHOST") // ErrCatchUpResponseNotCompletable is returned when the round represented by the catch up response is not completable diff --git a/lib/grandpa/grandpa.go b/lib/grandpa/grandpa.go index 135e8494c2..3fcfbafbb8 100644 --- a/lib/grandpa/grandpa.go +++ b/lib/grandpa/grandpa.go @@ -65,7 +65,7 @@ type Service struct { pvEquivocations map[ed25519.PublicKeyBytes][]*Vote // equivocatory votes for current pre-vote stage pcEquivocations map[ed25519.PublicKeyBytes][]*Vote // equivocatory votes for current pre-commit stage tracker *tracker // tracker of vote messages we may need in the future - head *types.Header // most recently finalized block + head *types.Header // most recently finalised block nextAuthorities []*Voter // if not nil, the updated authorities for the next round // historical information @@ -118,7 +118,7 @@ func NewService(cfg *Config) (*Service, error) { logger.Debug("creating service", "authority", cfg.Authority, "key", pub, "voter set", Voters(cfg.Voters)) - // get latest finalized header + // get latest finalised header head, err := cfg.BlockState.GetFinalizedHeader(0, 0) if err != nil { return nil, err @@ -296,7 +296,7 @@ func (s *Service) initiate() error { return err } } else { - // if not a grandpa authority, wait for a block to be finalized in the current round + // if not a grandpa authority, wait for a block to be finalised in the current round err = s.waitForFinalizedBlock() if err != nil { return err @@ -375,7 +375,7 @@ func (s *Service) waitForFirstBlock() error { } // playGrandpaRound executes a round of GRANDPA -// at the end of this round, a block will be finalized. +// at the end of this round, a block will be finalised. func (s *Service) playGrandpaRound() error { logger.Debug("starting round", "round", s.state.round, "setID", s.state.setID) @@ -389,7 +389,7 @@ func (s *Service) playGrandpaRound() error { if bytes.Equal(primary.key.Encode(), s.keypair.Public().Encode()) { msg, err := s.newCommitMessage(s.head, s.state.round-1).ToConsensusMessage() if err != nil { - logger.Error("failed to encode finalization message", "error", err) + logger.Error("failed to encode finalisation message", "error", err) } else { s.network.SendMessage(msg) } @@ -403,7 +403,7 @@ func (s *Service) playGrandpaRound() error { } else { msg, err = primProposal.ToConsensusMessage() if err != nil { - logger.Error("failed to encode finalization message", "error", err) + logger.Error("failed to encode finalisation message", "error", err) } else { s.network.SendMessage(msg) } @@ -446,16 +446,16 @@ func (s *Service) playGrandpaRound() error { logger.Debug("sending pre-vote message...", "vote", pv, "prevotes", s.prevotes) s.mapLock.Unlock() - finalized := false + finalised := false // continue to send prevote messages until round is done - go func(finalized *bool) { + go func(finalised *bool) { for { if s.paused.Load().(bool) { return } - if *finalized { + if *finalised { return } @@ -467,7 +467,7 @@ func (s *Service) playGrandpaRound() error { time.Sleep(time.Second * 5) logger.Trace("sent pre-vote message...", "vote", pv, "prevotes", s.prevotes) } - }(&finalized) + }(&finalised) logger.Debug("receiving pre-commit messages...") @@ -502,13 +502,13 @@ func (s *Service) playGrandpaRound() error { s.mapLock.Unlock() // continue to send precommit messages until round is done - go func(finalized *bool) { + go func(finalised *bool) { for { if s.paused.Load().(bool) { return } - if *finalized { + if *finalised { return } @@ -520,11 +520,11 @@ func (s *Service) playGrandpaRound() error { time.Sleep(time.Second * 5) logger.Trace("sent pre-commit message...", "vote", pc, "precommits", s.precommits) } - }(&finalized) + }(&finalised) go func() { - // receive messages until current round is completable and previous round is finalizable - // and the last finalized block is greater than the best final candidate from the previous round + // receive messages until current round is completable and previous round is finalisable + // and the last finalised block is greater than the best final candidate from the previous round s.receiveMessages(func() bool { if s.paused.Load().(bool) { return true @@ -536,7 +536,7 @@ func (s *Service) playGrandpaRound() error { } round := s.state.round - finalizable, err := s.isFinalizable(round) + finalisable, err := s.isFinalisable(round) if err != nil { return false } @@ -550,7 +550,7 @@ func (s *Service) playGrandpaRound() error { return false } - if completable && finalizable && uint32(s.head.Number.Int64()) >= prevBfc.number { + if completable && finalisable && uint32(s.head.Number.Int64()) >= prevBfc.number { return true } @@ -560,15 +560,15 @@ func (s *Service) playGrandpaRound() error { err = s.attemptToFinalize() if err != nil { - log.Error("failed to finalize", "error", err) + log.Error("failed to finalise", "error", err) return err } - finalized = true + finalised = true return nil } -// attemptToFinalize loops until the round is finalizable +// attemptToFinalize loops until the round is finalisable func (s *Service) attemptToFinalize() error { if s.paused.Load().(bool) { return ErrServicePaused @@ -576,7 +576,7 @@ func (s *Service) attemptToFinalize() error { has, _ := s.blockState.HasFinalizedBlock(s.state.round, s.state.setID) if has { - return nil // a block was finalized, seems like we missed some messages + return nil // a block was finalised, seems like we missed some messages } bfc, err := s.getBestFinalCandidate() @@ -590,14 +590,14 @@ func (s *Service) attemptToFinalize() error { } if bfc.number >= uint32(s.head.Number.Int64()) && pc >= s.state.threshold() { - err = s.finalize() + err = s.finalise() if err != nil { return err } - // if we haven't received a finalization message for this block yet, broadcast a finalization message + // if we haven't received a finalisation message for this block yet, broadcast a finalisation message votes := s.getDirectVotes(precommit) - logger.Debug("finalized block!!!", "setID", s.state.setID, "round", s.state.round, "hash", s.head.Hash(), + logger.Debug("finalised block!!!", "setID", s.state.setID, "round", s.state.round, "hash", s.head.Hash(), "precommits #", pc, "votes for bfc #", votes[*bfc], "total votes for bfc", pc, "precommits", s.precommits) msg, err := s.newCommitMessage(s.head, s.state.round).ToConsensusMessage() if err != nil { @@ -672,8 +672,8 @@ func (s *Service) determinePreCommit() (*Vote, error) { return &pvb, nil } -// isFinalizable returns true is the round is finalizable, false otherwise. -func (s *Service) isFinalizable(round uint64) (bool, error) { +// isFinalisable returns true is the round is finalisable, false otherwise. +func (s *Service) isFinalisable(round uint64) (bool, error) { var pvb Vote var err error @@ -719,8 +719,8 @@ func (s *Service) isFinalizable(round uint64) (bool, error) { return false, nil } -// finalize finalizes the round by setting the best final candidate for this round -func (s *Service) finalize() error { +// finalise finalises the round by setting the best final candidate for this round +func (s *Service) finalise() error { // get best final candidate bfc, err := s.getBestFinalCandidate() if err != nil { @@ -763,13 +763,13 @@ func (s *Service) finalize() error { return err } - // set finalized head for round in db + // set finalised head for round in db err = s.blockState.SetFinalizedHash(bfc.hash, s.state.round, s.state.setID) if err != nil { return err } - // set latest finalized head in db + // set latest finalised head in db return s.blockState.SetFinalizedHash(bfc.hash, 0, 0) } diff --git a/lib/grandpa/grandpa_test.go b/lib/grandpa/grandpa_test.go index 3beab53b47..652ca0e00e 100644 --- a/lib/grandpa/grandpa_test.go +++ b/lib/grandpa/grandpa_test.go @@ -945,7 +945,7 @@ func TestDeterminePreVote_WithInvalidPrimaryPreVote(t *testing.T) { require.Equal(t, gs.head.Hash(), pv.hash) } -func TestIsFinalizable_True(t *testing.T) { +func TestIsFinalisable_True(t *testing.T) { gs, st := newTestService(t) branches := make(map[int]int) @@ -970,12 +970,12 @@ func TestIsFinalizable_True(t *testing.T) { } } - finalizable, err := gs.isFinalizable(gs.state.round) + finalisable, err := gs.isFinalisable(gs.state.round) require.NoError(t, err) - require.True(t, finalizable) + require.True(t, finalisable) } -func TestIsFinalizable_False(t *testing.T) { +func TestIsFinalisable_False(t *testing.T) { gs, st := newTestService(t) branches := make(map[int]int) @@ -1000,16 +1000,16 @@ func TestIsFinalizable_False(t *testing.T) { } } - // previous round has finalized block # higher than current, so round is not finalizable + // previous round has finalised block # higher than current, so round is not finalisable gs.state.round = 1 gs.bestFinalCandidate[0] = &Vote{ number: 4, } gs.preVotedBlock[gs.state.round] = voteA - finalizable, err := gs.isFinalizable(gs.state.round) + finalisable, err := gs.isFinalisable(gs.state.round) require.NoError(t, err) - require.False(t, finalizable) + require.False(t, finalisable) } func TestGetGrandpaGHOST_CommonAncestor(t *testing.T) { diff --git a/lib/grandpa/message.go b/lib/grandpa/message.go index 8fe22a927c..0a4f88e521 100644 --- a/lib/grandpa/message.go +++ b/lib/grandpa/message.go @@ -140,7 +140,7 @@ func (v *VoteMessage) ToConsensusMessage() (*ConsensusMessage, error) { }, nil } -// NeighbourMessage represents a network-level neighbor message +// NeighbourMessage represents a network-level neighbour message type NeighbourMessage struct { Version byte Round uint64 @@ -194,7 +194,7 @@ func (d *AuthData) Decode(r io.Reader) error { return nil } -// CommitMessage represents a network finalization message +// CommitMessage represents a network finalisation message type CommitMessage struct { Round uint64 SetID uint64 diff --git a/lib/grandpa/message_handler.go b/lib/grandpa/message_handler.go index e30f655735..af09b9e23b 100644 --- a/lib/grandpa/message_handler.go +++ b/lib/grandpa/message_handler.go @@ -106,7 +106,7 @@ func (h *MessageHandler) handleNeighbourMessage(from peer.ID, msg *NeighbourMess } // TODO: make linter british - logger.Debug("got neighbor message", "number", msg.Number, "set id", msg.SetID, "round", msg.Round) + logger.Debug("got neighbour message", "number", msg.Number, "set id", msg.SetID, "round", msg.Round) h.blockNumToSetID.Store(msg.Number, msg.SetID) h.grandpa.network.SendJustificationRequest(from, msg.Number) @@ -117,14 +117,14 @@ func (h *MessageHandler) handleNeighbourMessage(from peer.ID, msg *NeighbourMess return err } - // don't finalize too close to head, until we add justification request + verification functionality. + // don't finalise too close to head, until we add justification request + verification functionality. // this prevents us from marking the wrong block as final and getting stuck on the wrong chain if uint32(head.Int64())-4 < msg.Number { return nil } - // TODO: instead of assuming the finalized hash is the one we currently know about, - // request the justification from the network before setting it as finalized. + // TODO: instead of assuming the finalised hash is the one we currently know about, + // request the justification from the network before setting it as finalised. hash, err := h.grandpa.blockState.GetHashByNumber(big.NewInt(int64(msg.Number))) if err != nil { return err @@ -138,12 +138,12 @@ func (h *MessageHandler) handleNeighbourMessage(from peer.ID, msg *NeighbourMess return err } - logger.Info("πŸ”¨ finalized block", "number", msg.Number, "hash", hash) + logger.Info("πŸ”¨ finalised block", "number", msg.Number, "hash", hash) return nil } func (h *MessageHandler) handleCommitMessage(msg *CommitMessage) (*ConsensusMessage, error) { - logger.Debug("received finalization message", "round", msg.Round, "hash", msg.Vote.hash) + logger.Debug("received finalisation message", "round", msg.Round, "hash", msg.Vote.hash) if has, _ := h.blockState.HasFinalizedBlock(msg.Round, h.grandpa.state.setID); has { return nil, nil @@ -155,13 +155,13 @@ func (h *MessageHandler) handleCommitMessage(msg *CommitMessage) (*ConsensusMess return nil, err } - // set finalized head for round in db + // set finalised head for round in db err = h.blockState.SetFinalizedHash(msg.Vote.hash, msg.Round, h.grandpa.state.setID) if err != nil { return nil, err } - // set latest finalized head in db + // set latest finalised head in db err = h.blockState.SetFinalizedHash(msg.Vote.hash, 0, 0) if err != nil { return nil, err @@ -334,7 +334,7 @@ func (h *MessageHandler) verifyCommitMessageJustification(fm *CommitMessage) err // confirm total # signatures >= grandpa threshold if uint64(count) < h.grandpa.state.threshold() { - logger.Error("minimum votes not met for finalization message", "votes needed", h.grandpa.state.threshold(), + logger.Error("minimum votes not met for finalisation message", "votes needed", h.grandpa.state.threshold(), "votes received", len(fm.Precommits)) return ErrMinVotesNotMet } diff --git a/lib/grandpa/message_handler_test.go b/lib/grandpa/message_handler_test.go index c00bf08af1..c94d25573a 100644 --- a/lib/grandpa/message_handler_test.go +++ b/lib/grandpa/message_handler_test.go @@ -217,9 +217,9 @@ func TestMessageHandler_NeighbourMessage(t *testing.T) { require.NoError(t, err) require.Nil(t, out) - finalized, err := st.Block.GetFinalizedHash(0, 0) + finalised, err := st.Block.GetFinalizedHash(0, 0) require.NoError(t, err) - require.Equal(t, block.Header.Hash(), finalized) + require.Equal(t, block.Header.Hash(), finalised) } func TestMessageHandler_VerifyJustification_InvalidSig(t *testing.T) { diff --git a/lib/grandpa/round_test.go b/lib/grandpa/round_test.go index ef5357dd98..63cb801515 100644 --- a/lib/grandpa/round_test.go +++ b/lib/grandpa/round_test.go @@ -40,14 +40,14 @@ var testTimeout = 20 * time.Second type testNetwork struct { t *testing.T out chan GrandpaMessage - finalized chan GrandpaMessage + finalised chan GrandpaMessage } func newTestNetwork(t *testing.T) *testNetwork { return &testNetwork{ t: t, out: make(chan GrandpaMessage, 128), - finalized: make(chan GrandpaMessage, 128), + finalised: make(chan GrandpaMessage, 128), } } @@ -59,7 +59,7 @@ func (n *testNetwork) SendMessage(msg NotificationsMessage) { require.NoError(n.t, err) if gmsg.Type() == commitType { - n.finalized <- gmsg + n.finalised <- gmsg } else { n.out <- gmsg } @@ -112,11 +112,11 @@ func setupGrandpa(t *testing.T, kp *ed25519.Keypair) (*Service, chan GrandpaMess gs, err := NewService(cfg) require.NoError(t, err) - return gs, gs.in, net.out, net.finalized + return gs, gs.in, net.out, net.finalised } func TestGrandpa_BaseCase(t *testing.T) { - // this is a base test case that asserts that all validators finalize the same block if they all see the + // this is a base test case that asserts that all validators finalise the same block if they all see the // same pre-votes and pre-commits, even if their chains are different kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -140,16 +140,16 @@ func TestGrandpa_BaseCase(t *testing.T) { for _, gs := range gss { precommits[gs.publicKeyBytes()], err = gs.determinePreCommit() require.NoError(t, err) - err = gs.finalize() + err = gs.finalise() require.NoError(t, err) has, err := gs.blockState.HasJustification(gs.head.Hash()) require.NoError(t, err) require.True(t, has) } - finalized := gss[0].head.Hash() + finalised := gss[0].head.Hash() for _, gs := range gss { - require.Equal(t, finalized, gs.head.Hash()) + require.Equal(t, finalised, gs.head.Hash()) } } @@ -158,7 +158,7 @@ func TestGrandpa_DifferentChains(t *testing.T) { t.Skip() } - // this asserts that all validators finalize the same block if they all see the + // this asserts that all validators finalise the same block if they all see the // same pre-votes and pre-commits, even if their chains are different lengths kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -190,18 +190,18 @@ func TestGrandpa_DifferentChains(t *testing.T) { for _, gs := range gss { precommits[gs.publicKeyBytes()], err = gs.determinePreCommit() require.NoError(t, err) - err = gs.finalize() + err = gs.finalise() require.NoError(t, err) } t.Log(gss[0].blockState.BlocktreeAsString()) - finalized := gss[0].head + finalised := gss[0].head for i, gs := range gss { // TODO: this can be changed to equal once attemptToFinalizeRound is implemented (needs check for >=2/3 precommits) - headOk := onSameChain(gss[0].blockState, finalized.Hash(), gs.head.Hash()) - finalizedOK := onSameChain(gs.blockState, finalized.Hash(), gs.head.Hash()) - require.True(t, headOk || finalizedOK, "node %d did not match: %s", i, gs.blockState.BlocktreeAsString()) + headOk := onSameChain(gss[0].blockState, finalised.Hash(), gs.head.Hash()) + finalisedOK := onSameChain(gs.blockState, finalised.Hash(), gs.head.Hash()) + require.True(t, headOk || finalisedOK, "node %d did not match: %s", i, gs.blockState.BlocktreeAsString()) } } @@ -224,7 +224,7 @@ func cleanup(gs *Service, in, out chan GrandpaMessage, done *bool) { //nolint } func TestPlayGrandpaRound_BaseCase(t *testing.T) { - // this asserts that all validators finalize the same block if they all see the + // this asserts that all validators finalise the same block if they all see the // same pre-votes and pre-commits, even if their chains are different lengths kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -259,26 +259,26 @@ func TestPlayGrandpaRound_BaseCase(t *testing.T) { wg := sync.WaitGroup{} wg.Add(len(kr.Keys)) - finalized := make([]*CommitMessage, len(kr.Keys)) + finalised := make([]*CommitMessage, len(kr.Keys)) for i, fin := range fins { go func(i int, fin <-chan GrandpaMessage) { select { case f := <-fin: - // receive first message, which is finalized block from previous round + // receive first message, which is finalised block from previous round if f.(*CommitMessage).Round == 0 { select { case f = <-fin: case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } } - finalized[i] = f.(*CommitMessage) + finalised[i] = f.(*CommitMessage) case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } wg.Done() }(i, fin) @@ -287,14 +287,14 @@ func TestPlayGrandpaRound_BaseCase(t *testing.T) { wg.Wait() - for _, fb := range finalized { + for _, fb := range finalised { require.NotNil(t, fb) require.GreaterOrEqual(t, len(fb.Precommits), len(kr.Keys)/2) - finalized[0].Precommits = []*Vote{} - finalized[0].AuthData = []*AuthData{} + finalised[0].Precommits = []*Vote{} + finalised[0].AuthData = []*AuthData{} fb.Precommits = []*Vote{} fb.AuthData = []*AuthData{} - require.Equal(t, finalized[0], fb) + require.Equal(t, finalised[0], fb) } } @@ -303,7 +303,7 @@ func TestPlayGrandpaRound_VaryingChain(t *testing.T) { t.Skip() } - // this asserts that all validators finalize the same block if they all see the + // this asserts that all validators finalise the same block if they all see the // same pre-votes and pre-commits, even if their chains are different lengths kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -359,7 +359,7 @@ func TestPlayGrandpaRound_VaryingChain(t *testing.T) { wg := sync.WaitGroup{} wg.Add(len(kr.Keys)) - finalized := make([]*CommitMessage, len(kr.Keys)) + finalised := make([]*CommitMessage, len(kr.Keys)) for i, fin := range fins { @@ -367,18 +367,19 @@ func TestPlayGrandpaRound_VaryingChain(t *testing.T) { select { case f := <-fin: - // receive first message, which is finalized block from previous round + // receive first message, which is finalised block from previous round if f.(*CommitMessage).Round == 0 { select { case f = <-fin: case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } } - finalized[i] = f.(*CommitMessage) + finalised[i] = f.(*CommitMessage) + case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } wg.Done() }(i, fin) @@ -387,15 +388,15 @@ func TestPlayGrandpaRound_VaryingChain(t *testing.T) { wg.Wait() - for _, fb := range finalized { + for _, fb := range finalised { require.NotNil(t, fb) require.GreaterOrEqual(t, len(fb.Precommits), len(kr.Keys)/2) require.GreaterOrEqual(t, len(fb.AuthData), len(kr.Keys)/2) - finalized[0].Precommits = []*Vote{} - finalized[0].AuthData = []*AuthData{} + finalised[0].Precommits = []*Vote{} + finalised[0].AuthData = []*AuthData{} fb.Precommits = []*Vote{} fb.AuthData = []*AuthData{} - require.Equal(t, finalized[0], fb) + require.Equal(t, finalised[0], fb) } } @@ -404,7 +405,7 @@ func TestPlayGrandpaRound_OneThirdEquivocating(t *testing.T) { t.Skip() } - // this asserts that all validators finalize the same block even if 1/3 of voters equivocate + // this asserts that all validators finalise the same block even if 1/3 of voters equivocate kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -459,7 +460,7 @@ func TestPlayGrandpaRound_OneThirdEquivocating(t *testing.T) { wg := sync.WaitGroup{} wg.Add(len(kr.Keys)) - finalized := make([]*CommitMessage, len(kr.Keys)) + finalised := make([]*CommitMessage, len(kr.Keys)) for i, fin := range fins { @@ -467,18 +468,19 @@ func TestPlayGrandpaRound_OneThirdEquivocating(t *testing.T) { select { case f := <-fin: - // receive first message, which is finalized block from previous round + // receive first message, which is finalised block from previous round if f.(*CommitMessage).Round == 0 { + select { case f = <-fin: case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } } - finalized[i] = f.(*CommitMessage) + finalised[i] = f.(*CommitMessage) case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } wg.Done() }(i, fin) @@ -487,15 +489,15 @@ func TestPlayGrandpaRound_OneThirdEquivocating(t *testing.T) { wg.Wait() - for _, fb := range finalized { + for _, fb := range finalised { require.NotNil(t, fb) require.GreaterOrEqual(t, len(fb.Precommits), len(kr.Keys)/2) require.GreaterOrEqual(t, len(fb.AuthData), len(kr.Keys)/2) - finalized[0].Precommits = []*Vote{} - finalized[0].AuthData = []*AuthData{} + finalised[0].Precommits = []*Vote{} + finalised[0].AuthData = []*AuthData{} fb.Precommits = []*Vote{} fb.AuthData = []*AuthData{} - require.Equal(t, finalized[0], fb) + require.Equal(t, finalised[0], fb) } } @@ -504,7 +506,7 @@ func TestPlayGrandpaRound_MultipleRounds(t *testing.T) { t.Skip() } - // this asserts that all validators finalize the same block in successive rounds + // this asserts that all validators finalise the same block in successive rounds kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -543,7 +545,7 @@ func TestPlayGrandpaRound_MultipleRounds(t *testing.T) { wg := sync.WaitGroup{} wg.Add(len(kr.Keys)) - finalized := make([]*CommitMessage, len(kr.Keys)) + finalised := make([]*CommitMessage, len(kr.Keys)) for i, fin := range fins { @@ -551,18 +553,18 @@ func TestPlayGrandpaRound_MultipleRounds(t *testing.T) { select { case f := <-fin: - // receive first message, which is finalized block from previous round + // receive first message, which is finalised block from previous round if f.(*CommitMessage).Round == uint64(j) { select { case f = <-fin: case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } } - finalized[i] = f.(*CommitMessage) + finalised[i] = f.(*CommitMessage) case <-time.After(testTimeout): - t.Errorf("did not receive finalized block from %d", i) + t.Errorf("did not receive finalised block from %d", i) } wg.Done() }(i, fin) @@ -572,16 +574,16 @@ func TestPlayGrandpaRound_MultipleRounds(t *testing.T) { wg.Wait() head := gss[0].blockState.(*state.BlockState).BestBlockHash() - for _, fb := range finalized { + for _, fb := range finalised { require.NotNil(t, fb) require.Equal(t, head, fb.Vote.hash) require.GreaterOrEqual(t, len(fb.Precommits), len(kr.Keys)/2) require.GreaterOrEqual(t, len(fb.AuthData), len(kr.Keys)/2) - finalized[0].Precommits = []*Vote{} - finalized[0].AuthData = []*AuthData{} + finalised[0].Precommits = []*Vote{} + finalised[0].AuthData = []*AuthData{} fb.Precommits = []*Vote{} fb.AuthData = []*AuthData{} - require.Equal(t, finalized[0], fb) + require.Equal(t, finalised[0], fb) } for _, gs := range gss { diff --git a/lib/grandpa/types.go b/lib/grandpa/types.go index ceb25ea801..cb61e5fff7 100644 --- a/lib/grandpa/types.go +++ b/lib/grandpa/types.go @@ -226,7 +226,7 @@ func (v *Vote) String() string { return fmt.Sprintf("hash=%s number=%d", v.hash, v.number) } -// SignedPrecommit represents a signed precommit message for a finalized block +// SignedPrecommit represents a signed precommit message for a finalised block type SignedPrecommit struct { Vote *Vote Signature [64]byte diff --git a/lib/grandpa/vote_message.go b/lib/grandpa/vote_message.go index 3b46659204..71fd6a2c5c 100644 --- a/lib/grandpa/vote_message.go +++ b/lib/grandpa/vote_message.go @@ -246,7 +246,7 @@ func (s *Service) checkForEquivocation(voter *Voter, vote *Vote, stage subround) } // validateVote checks if the block that is being voted for exists, and that it is a descendant of a -// previously finalized block. +// previously finalised block. func (s *Service) validateVote(v *Vote) error { // check if v.hash corresponds to a valid block has, err := s.blockState.HasHeader(v.hash) @@ -258,7 +258,7 @@ func (s *Service) validateVote(v *Vote) error { return ErrBlockDoesNotExist } - // check if the block is an eventual descendant of a previously finalized block + // check if the block is an eventual descendant of a previously finalised block isDescendant, err := s.blockState.IsDescendantOf(s.head.Hash(), v.hash) if err != nil { return err diff --git a/lib/keystore/keyring.go b/lib/keystore/keyring.go index cef7b99d50..9835f6e0c0 100644 --- a/lib/keystore/keyring.go +++ b/lib/keystore/keyring.go @@ -66,7 +66,7 @@ type Sr25519Keyring struct { Keys []*sr25519.Keypair } -// NewSr25519Keyring returns an initialized sr25519 Keyring +// NewSr25519Keyring returns an initialised sr25519 Keyring func NewSr25519Keyring() (*Sr25519Keyring, error) { kr := new(Sr25519Keyring) v := reflect.ValueOf(kr).Elem() @@ -152,7 +152,7 @@ type Ed25519Keyring struct { Keys []*ed25519.Keypair } -// NewEd25519Keyring returns an initialized ed25519 Keyring +// NewEd25519Keyring returns an initialised ed25519 Keyring func NewEd25519Keyring() (*Ed25519Keyring, error) { kr := new(Ed25519Keyring) v := reflect.ValueOf(kr).Elem() diff --git a/lib/runtime/constants.go b/lib/runtime/constants.go index fe20618c7e..28aa82a734 100644 --- a/lib/runtime/constants.go +++ b/lib/runtime/constants.go @@ -38,10 +38,11 @@ const ( HOST_API_TEST_RUNTIME_URL = "https://github.com/noot/polkadot-spec/blob/master/test/hostapi_runtime.compact.wasm?raw=true" ) +//nolint var ( // CoreVersion is the runtime API call Core_version CoreVersion = "Core_version" - // CoreInitializeBlock is the runtime API call Core_initialize_block + // CoreInitialiseBlock is the runtime API call Core_initialize_block CoreInitializeBlock = "Core_initialize_block" // CoreExecuteBlock is the runtime API call Core_execute_block CoreExecuteBlock = "Core_execute_block" diff --git a/lib/runtime/extrinsic/unchecked_extrinsic_test.go b/lib/runtime/extrinsic/unchecked_extrinsic_test.go index 665df992b7..f44b023109 100644 --- a/lib/runtime/extrinsic/unchecked_extrinsic_test.go +++ b/lib/runtime/extrinsic/unchecked_extrinsic_test.go @@ -83,7 +83,7 @@ func TestUncheckedExtrinsic_Encode(t *testing.T) { func TestMain(m *testing.M) { k, err := keystore.NewSr25519Keyring() if err != nil { - log.Fatal(fmt.Errorf("error initializing keyring")) + log.Fatal(fmt.Errorf("error initialising keyring")) } kr = *k testTransFunc = createFunction() diff --git a/lib/runtime/life/exports.go b/lib/runtime/life/exports.go index b662307bcc..cc04df8112 100644 --- a/lib/runtime/life/exports.go +++ b/lib/runtime/life/exports.go @@ -85,7 +85,7 @@ func (in *Instance) GrandpaAuthorities() ([]*types.Authority, error) { return types.GrandpaAuthoritiesRawToAuthorities(adr.([]*types.GrandpaAuthoritiesRaw)) } -// InitializeBlock calls runtime API function Core_initialize_block +// InitializeBlock calls runtime API function Core_initialise_block func (in *Instance) InitializeBlock(header *types.Header) error { encodedHeader, err := scale.Encode(header) if err != nil { @@ -106,6 +106,7 @@ func (in *Instance) ApplyExtrinsic(data types.Extrinsic) ([]byte, error) { return in.Exec(runtime.BlockBuilderApplyExtrinsic, data) } +//nolint // FinalizeBlock calls runtime API function BlockBuilder_finalize_block func (in *Instance) FinalizeBlock() (*types.Header, error) { data, err := in.Exec(runtime.BlockBuilderFinalizeBlock, []byte{}) diff --git a/lib/runtime/sig_verifier.go b/lib/runtime/sig_verifier.go index 0e72e7c98a..458d18ee09 100644 --- a/lib/runtime/sig_verifier.go +++ b/lib/runtime/sig_verifier.go @@ -31,7 +31,7 @@ type SignatureVerifier struct { sync.WaitGroup } -// NewSignatureVerifier initializes SignatureVerifier which does background verification of signatures. +// NewSignatureVerifier initialises SignatureVerifier which does background verification of signatures. // Start() is called to start the verification process. // Finish() is called to stop the verification process. // Signatures can be added to the batch using Add(). diff --git a/lib/runtime/storage/trie_test.go b/lib/runtime/storage/trie_test.go index 9e3e5eda5f..c2e22ad62a 100644 --- a/lib/runtime/storage/trie_test.go +++ b/lib/runtime/storage/trie_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" ) -// newTestTrieState returns an initialized TrieState +// newTestTrieState returns an initialised TrieState func newTestTrieState(t *testing.T) *TrieState { ts, err := NewTrieState(nil) require.NoError(t, err) diff --git a/lib/runtime/wasmer/exports.go b/lib/runtime/wasmer/exports.go index fa5234f2ff..a5c21699ad 100644 --- a/lib/runtime/wasmer/exports.go +++ b/lib/runtime/wasmer/exports.go @@ -106,7 +106,7 @@ func (in *Instance) GrandpaAuthorities() ([]*types.Authority, error) { return types.GrandpaAuthoritiesRawToAuthorities(adr.([]*types.GrandpaAuthoritiesRaw)) } -// InitializeBlock calls runtime API function Core_initialize_block +// InitializeBlock calls runtime API function Core_initialise_block func (in *Instance) InitializeBlock(header *types.Header) error { encodedHeader, err := scale.Encode(header) if err != nil { @@ -127,6 +127,7 @@ func (in *Instance) ApplyExtrinsic(data types.Extrinsic) ([]byte, error) { return in.exec(runtime.BlockBuilderApplyExtrinsic, data) } +//nolint // FinalizeBlock calls runtime API function BlockBuilder_finalize_block func (in *Instance) FinalizeBlock() (*types.Header, error) { data, err := in.exec(runtime.BlockBuilderFinalizeBlock, []byte{}) diff --git a/lib/runtime/wasmer/exports_test.go b/lib/runtime/wasmer/exports_test.go index 3d6a993084..b00abcd238 100644 --- a/lib/runtime/wasmer/exports_test.go +++ b/lib/runtime/wasmer/exports_test.go @@ -459,7 +459,7 @@ func TestInstance_ApplyExtrinsic_GossamerRuntime(t *testing.T) { require.NoError(t, err) instance.SetContextStorage(parentState) - //initialize block header + //initialise block header parentHash := common.MustHexToHash("0x35a28a7dbaf0ba07d1485b0f3da7757e3880509edc8c31d0850cb6dd6219361d") header, err := types.NewHeader(parentHash, common.Hash{}, common.Hash{}, big.NewInt(1), types.NewEmptyDigest()) require.NoError(t, err) diff --git a/lib/runtime/wasmtime/exports.go b/lib/runtime/wasmtime/exports.go index 4302e7a393..e2574f53c1 100644 --- a/lib/runtime/wasmtime/exports.go +++ b/lib/runtime/wasmtime/exports.go @@ -98,6 +98,7 @@ func (in *Instance) ValidateTransaction(e types.Extrinsic) (*transaction.Validit return v, err } +//nolint // InitializeBlock calls runtime API function Core_initialize_block func (in *Instance) InitializeBlock(header *types.Header) error { encodedHeader, err := scale.Encode(header) @@ -119,6 +120,7 @@ func (in *Instance) ApplyExtrinsic(data types.Extrinsic) ([]byte, error) { return in.exec(runtime.BlockBuilderApplyExtrinsic, data) } +//nolint // FinalizeBlock calls runtime API function BlockBuilder_finalize_block func (in *Instance) FinalizeBlock() (*types.Header, error) { data, err := in.exec(runtime.BlockBuilderFinalizeBlock, []byte{}) diff --git a/lib/scale/decode.go b/lib/scale/decode.go index c8dc52a882..898b78073b 100644 --- a/lib/scale/decode.go +++ b/lib/scale/decode.go @@ -473,7 +473,7 @@ func (sd *Decoder) DecodeSlice(t interface{}) (interface{}, error) { } // DecodeTuple accepts a byte array representing the SCALE encoded tuple and an interface. This interface should be a pointer -// to a struct which the encoded tuple should be marshaled into. If it is a valid encoding for the struct, it returns the +// to a struct which the encoded tuple should be marshalled into. If it is a valid encoding for the struct, it returns the // decoded struct, otherwise error, // Note that we return the same interface that was passed to this function; this is because we are writing directly to the // struct that is passed in, using reflect to get each of the fields. diff --git a/lib/trie/database_test.go b/lib/trie/database_test.go index 42fff69904..4e8fc12aed 100644 --- a/lib/trie/database_test.go +++ b/lib/trie/database_test.go @@ -35,7 +35,7 @@ func newTestDB(t *testing.T) chaindb.Database { InMemory: true, } - // TODO: don't initialize new DB but pass it in + // TODO: don't initialise new DB but pass it in db, err := chaindb.NewBadgerDB(cfg) require.NoError(t, err) return chaindb.NewTable(db, "trie") diff --git a/lib/trie/trie_test.go b/lib/trie/trie_test.go index 28f26caaa9..795ead0d62 100644 --- a/lib/trie/trie_test.go +++ b/lib/trie/trie_test.go @@ -72,14 +72,14 @@ var ( func TestNewEmptyTrie(t *testing.T) { trie := NewEmptyTrie() if trie == nil { - t.Error("did not initialize trie") + t.Error("did not initialise trie") } } func TestNewTrie(t *testing.T) { trie := NewTrie(&leaf{key: []byte{0}, value: []byte{17}}) if trie == nil { - t.Error("did not initialize trie") + t.Error("did not initialise trie") } } diff --git a/scripts/install-lint.sh b/scripts/install-lint.sh index 5efd724247..8f0837bdbf 100755 --- a/scripts/install-lint.sh +++ b/scripts/install-lint.sh @@ -6,7 +6,7 @@ fi if ! command -v golangci-lint &> /dev/null then - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.32.2 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0 fi export PATH=$PATH:$(go env GOPATH)/bin \ No newline at end of file diff --git a/tests/stress/errors.go b/tests/stress/errors.go index 488e028ef8..f7d1fb3119 100644 --- a/tests/stress/errors.go +++ b/tests/stress/errors.go @@ -6,8 +6,8 @@ import ( //nolint var ( - errFinalizedBlockMismatch = errors.New("node finalized head hashes don't match") - errNoFinalizedBlock = errors.New("did not finalize block for round") + errFinalizedBlockMismatch = errors.New("node finalised head hashes don't match") + errNoFinalizedBlock = errors.New("did not finalise block for round") errNoBlockAtNumber = errors.New("no blocks found for given number") errBlocksAtNumberMismatch = errors.New("different blocks found for given number") errChainHeadMismatch = errors.New("node chain head hashes don't match") diff --git a/tests/stress/grandpa_test.go b/tests/stress/grandpa_test.go index e9be10c47b..737023a567 100644 --- a/tests/stress/grandpa_test.go +++ b/tests/stress/grandpa_test.go @@ -68,7 +68,7 @@ func TestStress_Grandpa_ThreeAuthorities(t *testing.T) { for i := 1; i < numRounds+1; i++ { fin, err := compareFinalizedHeadsWithRetry(t, nodes, uint64(i)) require.NoError(t, err) - t.Logf("finalized hash in round %d: %s", i, fin) + t.Logf("finalised hash in round %d: %s", i, fin) } } @@ -90,7 +90,7 @@ func TestStress_Grandpa_SixAuthorities(t *testing.T) { for i := 1; i < numRounds+1; i++ { fin, err := compareFinalizedHeadsWithRetry(t, nodes, uint64(i)) require.NoError(t, err) - t.Logf("finalized hash in round %d: %s", i, fin) + t.Logf("finalised hash in round %d: %s", i, fin) } } @@ -115,7 +115,7 @@ func TestStress_Grandpa_NineAuthorities(t *testing.T) { for i := 1; i < numRounds+1; i++ { fin, err := compareFinalizedHeadsWithRetry(t, nodes, uint64(i)) require.NoError(t, err) - t.Logf("finalized hash in round %d: %s", i, fin) + t.Logf("finalised hash in round %d: %s", i, fin) } } @@ -137,7 +137,7 @@ func TestStress_Grandpa_CatchUp(t *testing.T) { }() time.Sleep(time.Second * 70) // let some rounds run - + //nolint node, err := utils.RunGossamer(t, numNodes-1, utils.TestDir(t, utils.KeyList[numNodes-1]), utils.GenesisSixAuths, utils.ConfigDefault, false) require.NoError(t, err) nodes = append(nodes, node) @@ -146,6 +146,6 @@ func TestStress_Grandpa_CatchUp(t *testing.T) { for i := 1; i < numRounds+1; i++ { fin, err := compareFinalizedHeadsWithRetry(t, nodes, uint64(i)) require.NoError(t, err) - t.Logf("finalized hash in round %d: %s", i, fin) + t.Logf("finalised hash in round %d: %s", i, fin) } } diff --git a/tests/stress/helpers.go b/tests/stress/helpers.go index 6751cb2223..32d6078ee2 100644 --- a/tests/stress/helpers.go +++ b/tests/stress/helpers.go @@ -148,12 +148,12 @@ doneBlockProduction: } // compareFinalizedHeads calls getFinalizedHeadByRound for each node in the array -// it returns a map of finalizedHead hashes to node key names, and an error if the hashes don't all match +// it returns a map of finalisedHead hashes to node key names, and an error if the hashes don't all match func compareFinalizedHeads(t *testing.T, nodes []*utils.Node) (map[common.Hash][]string, error) { hashes := make(map[common.Hash][]string) for _, node := range nodes { hash := utils.GetFinalizedHead(t, node) - logger.Info("got finalized head from node", "hash", hash, "node", node.Key) + logger.Info("got finalised head from node", "hash", hash, "node", node.Key) hashes[hash] = append(hashes[hash], node.Key) } @@ -170,7 +170,7 @@ func compareFinalizedHeads(t *testing.T, nodes []*utils.Node) (map[common.Hash][ } // compareFinalizedHeadsByRound calls getFinalizedHeadByRound for each node in the array -// it returns a map of finalizedHead hashes to node key names, and an error if the hashes don't all match +// it returns a map of finalisedHead hashes to node key names, and an error if the hashes don't all match func compareFinalizedHeadsByRound(t *testing.T, nodes []*utils.Node, round uint64) (map[common.Hash][]string, error) { hashes := make(map[common.Hash][]string) for _, node := range nodes { @@ -179,7 +179,7 @@ func compareFinalizedHeadsByRound(t *testing.T, nodes []*utils.Node, round uint6 return nil, err } - logger.Info("got finalized head from node", "hash", hash, "node", node.Key, "round", round) + logger.Info("got finalised head from node", "hash", hash, "node", node.Key, "round", round) hashes[hash] = append(hashes[hash], node.Key) } @@ -196,7 +196,7 @@ func compareFinalizedHeadsByRound(t *testing.T, nodes []*utils.Node, round uint6 } // compareFinalizedHeadsWithRetry calls compareFinalizedHeadsByRound, retrying up to maxRetries times if it errors. -// it returns the finalized hash if it succeeds +// it returns the finalised hash if it succeeds func compareFinalizedHeadsWithRetry(t *testing.T, nodes []*utils.Node, round uint64) (common.Hash, error) { var hashes map[common.Hash][]string var err error diff --git a/tests/stress/stress_test.go b/tests/stress/stress_test.go index 23c7ee27a8..27a287eea9 100644 --- a/tests/stress/stress_test.go +++ b/tests/stress/stress_test.go @@ -99,6 +99,7 @@ func TestSync_SingleBlockProducer(t *testing.T) { utils.SetLogLevel(log.LvlInfo) // start block producing node first + //nolint node, err := utils.RunGossamer(t, numNodes-1, utils.TestDir(t, utils.KeyList[numNodes-1]), utils.GenesisDefault, utils.ConfigBABEMaxThreshold, false) require.NoError(t, err) @@ -311,6 +312,7 @@ func TestSync_Restart(t *testing.T) { utils.SetLogLevel(log.LvlInfo) // start block producing node first + //nolint node, err := utils.RunGossamer(t, numNodes-1, utils.TestDir(t, utils.KeyList[numNodes-1]), utils.GenesisDefault, utils.ConfigBABEMaxThreshold, false) require.NoError(t, err) @@ -367,7 +369,7 @@ func TestPendingExtrinsic(t *testing.T) { numNodes := 3 // index of node to submit tx to - idx := numNodes - 1 // TODO: randomize this + idx := numNodes - 1 // TODO: randomise this // start block producing node first node, err := utils.RunGossamer(t, numNodes-1, utils.TestDir(t, utils.KeyList[numNodes-1]), utils.GenesisDefault, utils.ConfigBABEMaxThreshold, false) diff --git a/tests/sync/sync_test.go b/tests/sync/sync_test.go index 5f0a63a147..5b45bc7501 100644 --- a/tests/sync/sync_test.go +++ b/tests/sync/sync_test.go @@ -49,7 +49,7 @@ func TestMain(m *testing.M) { } fw, err := utils.InitFramework(3) if err != nil { - log.Fatal(fmt.Errorf("error initializing test framework")) + log.Fatal(fmt.Errorf("error initialising test framework")) } framework = *fw // Start all tests diff --git a/tests/utils/chain.go b/tests/utils/chain.go index 322c2d4947..d43b6529a2 100644 --- a/tests/utils/chain.go +++ b/tests/utils/chain.go @@ -81,7 +81,7 @@ func GetBlockHash(t *testing.T, node *Node, num string) (common.Hash, error) { return common.MustHexToHash(hash), nil } -// GetFinalizedHead calls the endpoint chain_getFinalizedHead to get the latest finalized head +// GetFinalizedHead calls the endpoint chain_getFinalizedHead to get the latest finalised head func GetFinalizedHead(t *testing.T, node *Node) common.Hash { respBody, err := PostRPC(ChainGetFinalizedHead, NewEndpoint(node.RPCPort), "[]") require.NoError(t, err) @@ -92,7 +92,7 @@ func GetFinalizedHead(t *testing.T, node *Node) common.Hash { return common.MustHexToHash(hash) } -// GetFinalizedHeadByRound calls the endpoint chain_getFinalizedHeadByRound to get the finalized head at a given round +// GetFinalizedHeadByRound calls the endpoint chain_getFinalizedHeadByRound to get the finalised head at a given round // TODO: add setID, hard-coded at 1 for now func GetFinalizedHeadByRound(t *testing.T, node *Node, round uint64) (common.Hash, error) { p := strconv.Itoa(int(round)) diff --git a/tests/utils/gossamer_utils.go b/tests/utils/gossamer_utils.go index 2511dfd029..0106f150a1 100644 --- a/tests/utils/gossamer_utils.go +++ b/tests/utils/gossamer_utils.go @@ -89,7 +89,7 @@ type Node struct { WSPort string } -// InitGossamer initializes given node number and returns node reference +// InitGossamer initialises given node number and returns node reference func InitGossamer(idx int, basePath, genesis, config string) (*Node, error) { //nolint cmdInit := exec.Command(gossamerCMD, "init", @@ -100,15 +100,15 @@ func InitGossamer(idx int, basePath, genesis, config string) (*Node, error) { ) //add step for init - logger.Info("initializing gossamer...", "cmd", cmdInit) + logger.Info("initialising gossamer...", "cmd", cmdInit) stdOutInit, err := cmdInit.CombinedOutput() if err != nil { fmt.Printf("%s", stdOutInit) return nil, err } - // TODO: get init exit code to see if node was successfully initialized - logger.Info("initialized gossamer!", "node", idx) + // TODO: get init exit code to see if node was successfully initialised + logger.Info("initialised gossamer!", "node", idx) return &Node{ Idx: idx, @@ -213,11 +213,11 @@ func StartGossamer(t *testing.T, node *Node, websocket bool) error { return nil } -// RunGossamer will initialize and start a gossamer instance +// RunGossamer will initialise and start a gossamer instance func RunGossamer(t *testing.T, idx int, basepath, genesis, config string, websocket bool) (*Node, error) { node, err := InitGossamer(idx, basepath, genesis, config) if err != nil { - logger.Crit("could not initialize gossamer", "error", err) + logger.Crit("could not initialise gossamer", "error", err) os.Exit(1) } @@ -261,7 +261,7 @@ func KillProcess(t *testing.T, cmd *exec.Cmd) error { return err } -// InitNodes initializes given number of nodes +// InitNodes initialises given number of nodes func InitNodes(num int, config string) ([]*Node, error) { var nodes []*Node tempDir, err := ioutil.TempDir("", "gossamer-stress-")