From a063b68ea98c58c5a6add739b7a4dfaf5d339d55 Mon Sep 17 00:00:00 2001 From: Timothy Wu Date: Thu, 12 Dec 2024 16:04:23 -0500 Subject: [PATCH] update comments --- internal/client/db/backend.go | 4 +- .../client/db/backend_integration_test.go | 8 ++-- internal/client/db/utils.go | 4 -- internal/client/state-db/statedb_test.go | 2 +- internal/kvdb/kvdb.go | 2 +- internal/kvdb/memory-kvdb/memory_kvdb_test.go | 1 - internal/primitives/blockchain/backend.go | 20 ++++----- .../primitives/blockchain/header_metadata.go | 8 ++-- internal/primitives/core/crypto/crypto.go | 28 ++++++------ internal/primitives/core/ed25519/ed25519.go | 45 +++++++++---------- internal/primitives/database/database.go | 22 ++++----- internal/primitives/database/mem.go | 6 +-- internal/primitives/runtime/digest.go | 4 +- internal/primitives/runtime/generic/block.go | 6 +-- internal/primitives/runtime/generic/header.go | 4 +- internal/primitives/runtime/runtime.go | 2 +- .../state-machine/trie_backend_test.go | 4 +- 17 files changed, 81 insertions(+), 89 deletions(-) diff --git a/internal/client/db/backend.go b/internal/client/db/backend.go index eeff2aa126..6a539023b9 100644 --- a/internal/client/db/backend.go +++ b/internal/client/db/backend.go @@ -61,7 +61,7 @@ func (BlocksPruningSome) isBlocksPruning() {} type DatabaseSource struct { // the handle to the custom storage DB database.Database[hash.H256] - // if set, the `create` flag will be required to open such datasource + // if set, the create flag will be required to open such datasource RequireCreateFlag bool } @@ -385,8 +385,6 @@ type Backend[ genesisState *dbGenesisStorage[H, Hasher] // can be nil to represent no genesisState genesisStateMtx sync.RWMutex sharedTrieCache *cache.SharedTrieCache[H] // can be nil to respresent no shared trie cache - // io_stats: FrozenForDuration<(kvdb::IoStats, StateUsageInfo)>, - // state_usage: Arc, } // Create a new instance of database backend. diff --git a/internal/client/db/backend_integration_test.go b/internal/client/db/backend_integration_test.go index 5fdc7f20f1..4cb8ab4c11 100644 --- a/internal/client/db/backend_integration_test.go +++ b/internal/client/db/backend_integration_test.go @@ -17,7 +17,7 @@ func TestBackend_Integration(t *testing.T) { t.Run("tree_route_regression", func(t *testing.T) { // NOTE: this is a test for a regression introduced in #3665, the result // of tree_route would be erroneously computed, since it was taking into - // account the `ancestor` in `CachedHeaderMetadata` for the comparison. + // account the ancestor in CachedHeaderMetadata for the comparison. // in this test we simulate the same behavior with the side-effect // triggering the issue being eviction of a previously fetched record // from the cache, therefore this test is dependent on the LRU cache @@ -38,13 +38,13 @@ func TestBackend_Integration(t *testing.T) { } block7000 := parent - // This will cause the ancestor of `block100` to be set to `genesis` as a side-effect. + // This will cause the ancestor of block100 to be set to genesis as a side-effect. _, err := p_blockchain.LowestCommonAncestor(blockchain, genesis, block100) require.NoError(t, err) // While traversing the tree we will have to do 6900 calls to - // `header_metadata`, which will make sure we will exhaust our cache - // which only takes 5000 elements. In particular, the `CachedHeaderMetadata` struct for + // HeaderMetadata, which will make sure we will exhaust our cache + // which only takes 5000 elements. In particular, the CachedHeaderMetadata struct for // block #100 will be evicted and will get a new value (with ancestor set to its parent). treeRoute, err := p_blockchain.NewTreeRoute(blockchain, block100, block7000) require.NoError(t, err) diff --git a/internal/client/db/utils.go b/internal/client/db/utils.go index b6649e657e..618ea889e2 100644 --- a/internal/client/db/utils.go +++ b/internal/client/db/utils.go @@ -286,10 +286,6 @@ var ( ) func openDatabase(dbSource DatabaseSource, create bool) (database.Database[hash.H256], error) { - // Maybe migrate (copy) the database to a type specific subdirectory to make it - // possible that light and full databases coexist - // NOTE: This function can be removed in a few releases - // maybe_migrate_to_type_subdir::(db_source, db_type)?; if dbSource.RequireCreateFlag && !create { return nil, errDoesNotExist } diff --git a/internal/client/state-db/statedb_test.go b/internal/client/state-db/statedb_test.go index 6c5c5e31c2..d691b2964a 100644 --- a/internal/client/state-db/statedb_test.go +++ b/internal/client/state-db/statedb_test.go @@ -164,7 +164,7 @@ func TestStateDB_BlockRecordUnavailable(t *testing.T) { assert.Equal(t, IsPrunedPruned, stateDB.IsPruned(hash.NewH256FromLowUint64BigEndian(3), 3)) // canonicalize block 5 but not commit it to db, block 4 is not pruned due to it is not - // commit to db yet (unavailable), return `MaybePruned` here because `apply_pending` is not + // commit to db yet (unavailable), return MaybePruned here because apply_pending is not // called and block 3 is still in cache c2, err := stateDB.CanonicalizeBlock(hash.NewH256FromLowUint64BigEndian(5)) assert.NoError(t, err) diff --git a/internal/kvdb/kvdb.go b/internal/kvdb/kvdb.go index eff74563c1..03594b827c 100644 --- a/internal/kvdb/kvdb.go +++ b/internal/kvdb/kvdb.go @@ -132,7 +132,7 @@ type KeyValueDB interface { // For a given start prefix (inclusive), returns the correct end prefix (non-inclusive). // This assumes the key bytes are ordered in lexicographical order. // Since key length is not limited, for some case we return nil because there is -// no bounded limit (every keys in the series `[]`, `[255]`, `[255, 255]` ...). +// no bounded limit (every keys in the series [], [255], [255, 255] ...). func EndPrefix(prefix []byte) []byte { for len(prefix) > 0 && prefix[len(prefix)-1] == 0xff { prefix = prefix[:len(prefix)-1] diff --git a/internal/kvdb/memory-kvdb/memory_kvdb_test.go b/internal/kvdb/memory-kvdb/memory_kvdb_test.go index b7ac49bb8f..3e50dce2b1 100644 --- a/internal/kvdb/memory-kvdb/memory_kvdb_test.go +++ b/internal/kvdb/memory-kvdb/memory_kvdb_test.go @@ -13,7 +13,6 @@ import ( var _ kvdb.KeyValueDB = &MemoryKVDB{} -// The number of columns required to run `test_delete_prefix`. const DeletePrefixNumColumns uint32 = 7 func Test_MemoryKVDB(t *testing.T) { diff --git a/internal/primitives/blockchain/backend.go b/internal/primitives/blockchain/backend.go index b2097887e8..b66d7bb3b8 100644 --- a/internal/primitives/blockchain/backend.go +++ b/internal/primitives/blockchain/backend.go @@ -12,7 +12,7 @@ import ( // Header is the blockchain database header backend. Does not perform any validation. type HeaderBackend[Hash runtime.Hash, N runtime.Number, Header runtime.Header[N, Hash]] interface { - // Get block header. Returns `nil` if block is not found. + // Get block header. Returns nil if block is not found. Header(hash Hash) (*Header, error) // Get blockchain info. @@ -21,10 +21,10 @@ type HeaderBackend[Hash runtime.Hash, N runtime.Number, Header runtime.Header[N, // Get block status. Status(hash Hash) (BlockStatus, error) - // Get block number by hash. Returns `nil` if the header is not in the chain. + // Get block number by hash. Returns nil if the header is not in the chain. Number(hash Hash) (*N, error) - // Get block hash by number. Returns `nil` if the header is not in the chain. + // Get block hash by number. Returns nil if the header is not in the chain. Hash(number N) (*Hash, error) // Convert an arbitrary block ID into a block hash. @@ -39,9 +39,9 @@ type Backend[Hash runtime.Hash, N runtime.Number, Header runtime.Header[N, Hash] HeaderBackend[Hash, N, Header] HeaderMetadata[Hash, N] - // Get block body. Returns `nil` if block is not found. + // Get block body. Returns nil if block is not found. Body(hash Hash) ([]runtime.Extrinsic, error) - // Get block justifications. Returns `nil` if no justification exists. + // Get block justifications. Returns nil if no justification exists. Justifications(hash Hash) (runtime.Justifications, error) // Get last finalized block hash. LastFinalized() (Hash, error) @@ -53,23 +53,23 @@ type Backend[Hash runtime.Hash, N runtime.Number, Header runtime.Header[N, Hash] // Returns displaced leaves after the given block would be finalized. // - // The returned leaves do not contain the leaves from the same height as `blockNumber`. + // The returned leaves do not contain the leaves from the same height as blockNumber. DisplacedLeavesAfterFinalizing(blockNumber N) ([]Hash, error) - // Return hashes of all blocks that are children of the block with `parentHash`. + // Return hashes of all blocks that are children of the block with parentHash. Children(parentHash Hash) ([]Hash, error) // Get the most recent block hash of the longest chain that contains - // a block with the given `baseHash`. + // a block with the given baseHash. // // The search space is always limited to blocks which are in the finalized // chain or descendents of it. // - // Returns `nil` if `basehash` is not found in search space. + // Returns nil if basehash is not found in search space. LongestContaining(baseHash Hash, importLock *sync.RWMutex) (*Hash, error) // Get single indexed transaction by content hash. Note that this will only fetch transactions - // that are indexed by the runtime with `storage_index_transaction`. + // that are indexed by the runtime with storage_index_transaction. IndexedTransaction(hash Hash) ([]byte, error) // Check if indexed transaction exists. diff --git a/internal/primitives/blockchain/header_metadata.go b/internal/primitives/blockchain/header_metadata.go index 4054d5e1ff..66f67e7800 100644 --- a/internal/primitives/blockchain/header_metadata.go +++ b/internal/primitives/blockchain/header_metadata.go @@ -172,7 +172,7 @@ type HashNumber[H runtime.Hash, N runtime.Number] struct { // The ancestry sets will include the given blocks, and thus the tree-route is // never empty. // -// ```text +// “ // Tree route from R1 to E2. Retracted is [R1, R2, R3], Common is C, enacted [E1, E2] // // <- R3 <- R2 <- R1 @@ -182,12 +182,12 @@ type HashNumber[H runtime.Hash, N runtime.Number] struct { // // \-> E1 -> E2 // -// ``` +// “ // -// ```text +// “ // Tree route from C to E2. Retracted empty. Common is C, enacted [E1, E2] // C -> E1 -> E2 -// ``` +// “ type TreeRoute[H runtime.Hash, N runtime.Number] struct { // route: Vec>, Route []HashNumber[H, N] diff --git a/internal/primitives/core/crypto/crypto.go b/internal/primitives/core/crypto/crypto.go index bcdd7427e8..5eb60e2625 100644 --- a/internal/primitives/core/crypto/crypto.go +++ b/internal/primitives/core/crypto/crypto.go @@ -18,7 +18,7 @@ const DevPhrase = "bottom drive obey lake curtain smoke basket hold race lonely // DeriveJunction is a since derivation junction description. It is the single parameter // used when creating a new secret key from an existing secret key and, in the case of -// `SoftRaw` and `SoftIndex` a new public key from an existing public key. +// SoftRaw and SoftIndex a new public key from an existing public key. type DeriveJunction struct { inner any } @@ -113,7 +113,7 @@ var junctionRegex = regexp.MustCompile(`/(/?[^/]+)`) // Trait used for types that are really just a fixed-length array. type Bytes interface { - // Return a `Vec` filled with raw data. + // Return a []byte filled with raw data. Bytes() []byte } @@ -125,29 +125,29 @@ type Public[Signature any] interface { Verify(sig Signature, message []byte) bool } -// SecretURI A secret uri (`SURI`) that can be used to generate a key pair. +// SecretURI A secret uri (SURI) that can be used to generate a key pair. // -// The `SURI` can be parsed from a string. The string is interpreted in the following way: +// The SURI can be parsed from a string. The string is interpreted in the following way: // -// - If `string` is a possibly `0x` prefixed 64-digit hex string, then it will be interpreted -// directly as a secret key (aka "seed" in `subkey`). -// - If `string` is a valid BIP-39 key phrase of 12, 15, 18, 21 or 24 words, then the key will +// - If string is a possibly 0x prefixed 64-digit hex string, then it will be interpreted +// directly as a secret key (aka "seed" in subkey). +// - If string is a valid BIP-39 key phrase of 12, 15, 18, 21 or 24 words, then the key will // be derived from it. In this case: -// - the phrase may be followed by one or more items delimited by `/` characters. -// - the path may be followed by `///`, in which case everything after the `///` is treated +// - the phrase may be followed by one or more items delimited by "/" characters. +// - the path may be followed by "///", in which case everything after the "///" is treated // // as a password. -// - If `string` begins with a `/` character it is prefixed with the public `DevPhrase` +// - If string begins with a "/" character it is prefixed with the public DevPhrase // and interpreted as above. // // In this case they are interpreted as HDKD junctions; purely numeric items are interpreted as -// integers, non-numeric items as strings. Junctions prefixed with `/` are interpreted as soft -// junctions, and with `//` as hard junctions. +// integers, non-numeric items as strings. Junctions prefixed with "/"" are interpreted as soft +// junctions, and with "//" as hard junctions. // -// There is no correspondence mapping between `SURI` strings and the keys they represent. +// There is no correspondence mapping between SURI strings and the keys they represent. // Two different non-identical strings can actually lead to the same secret being derived. // Notably, integer junction indices may be legally prefixed with arbitrary number of zeros. -// Similarly an empty password (ending the `SURI` with `///`) is perfectly valid and will +// Similarly an empty password (ending the SURI with "///") is perfectly valid and will // generally be equivalent to no password at all. type SecretURI struct { // The phrase to derive the private key. diff --git a/internal/primitives/core/ed25519/ed25519.go b/internal/primitives/core/ed25519/ed25519.go index 78e4bdc990..9f6a296625 100644 --- a/internal/primitives/core/ed25519/ed25519.go +++ b/internal/primitives/core/ed25519/ed25519.go @@ -34,7 +34,7 @@ func (p Public) Verify(sig Signature, message []byte) bool { return ed25519.Verify(p[:], message, sig[:]) } -// NewPublic creates a new instance from the given 32-byte `data`. +// NewPublic creates a new instance from the given 32-byte data. // // NOTE: No checking goes on to ensure this is a real public key. Only use it if // you are certain that the array actually is a pubkey. @@ -112,7 +112,7 @@ func (p Pair) Sign(message []byte) Signature { // NewGeneratedPair will generate new secure (random) key pair. // // This is only for ephemeral keys really, since you won't have access to the secret key -// for storage. If you want a persistent key pair, use `generate_with_phrase` instead. +// for storage. If you want a persistent key pair, use [NewGeneratedPairWithPhrase] instead. func NewGeneratedPair() (Pair, [32]byte) { seedSlice := make([]byte, 32) _, err := rand.Read(seedSlice) @@ -127,9 +127,9 @@ func NewGeneratedPair() (Pair, [32]byte) { // NewGeneratedPairWithPhrase will generate new secure (random) key pair and provide the recovery phrase. // -// You can recover the same key later with `from_phrase`. +// You can recover the same key later with NewPairFromPhrase. // -// This is generally slower than `generate()`, so prefer that unless you need to persist +// This is generally slower than generate(), so prefer that unless you need to persist // the key from the current session. func NewGeneratedPairWithPhrase(password *string) (Pair, string, [32]byte) { entropy, err := bip39.NewEntropy(128) @@ -147,7 +147,7 @@ func NewGeneratedPairWithPhrase(password *string) (Pair, string, [32]byte) { return pair, phrase, seed } -// NewPairFromPhrase returns the KeyPair from the English BIP39 seed `phrase`, or `None` if it's invalid. +// NewPairFromPhrase returns the KeyPair from the English BIP39 seed phrase. func NewPairFromPhrase(phrase string, password *string) (pair Pair, seed [32]byte, err error) { pass := "" if password != nil { @@ -167,18 +167,17 @@ func NewPairFromPhrase(phrase string, password *string) (pair Pair, seed [32]byt return NewPairFromSeedSlice(seedSlice), seed, nil } -// NewPairFromSeed will generate new key pair from the provided `seed`. +// NewPairFromSeed will generate new key pair from the provided seed. // -// @WARNING: THIS WILL ONLY BE SECURE IF THE `seed` IS SECURE. If it can be guessed +// @WARNING: THIS WILL ONLY BE SECURE IF THE seed IS SECURE. If it can be guessed // by an attacker then they can also derive your key. func NewPairFromSeed(seed [32]byte) Pair { return NewPairFromSeedSlice(seed[:]) } -// NewPairFromSeedSlice will make a new key pair from secret seed material. The slice must be the correct size or -// it will return `None`. +// NewPairFromSeedSlice will make a new key pair from secret seed material. // -// @WARNING: THIS WILL ONLY BE SECURE IF THE `seed` IS SECURE. If it can be guessed +// @WARNING: THIS WILL ONLY BE SECURE IF THE seed IS SECURE. If it can be guessed // by an attacker then they can also derive your key. func NewPairFromSeedSlice(seedSlice []byte) Pair { secret := ed25519.NewKeyFromSeed(seedSlice) @@ -189,37 +188,37 @@ func NewPairFromSeedSlice(seedSlice []byte) Pair { } } -// NewPairFromStringWithSeed interprets the string `s` in order to generate a key Pair. Returns +// NewPairFromStringWithSeed interprets the string s in order to generate a key Pair. Returns // both the pair and an optional seed, in the case that the pair can be expressed as a direct // derivation from a seed (some cases, such as Sr25519 derivations with path components, cannot). // // This takes a helper function to do the key generation from a phrase, password and // junction iterator. // -// - If `s` is a possibly `0x` prefixed 64-digit hex string, then it will be interpreted -// directly as a secret key (aka "seed" in `subkey`). -// - If `s` is a valid BIP-39 key phrase of 12, 15, 18, 21 or 24 words, then the key will +// - If s is a possibly "0x" prefixed 64-digit hex string, then it will be interpreted +// directly as a secret key (aka "seed" in subkey). +// - If s is a valid BIP-39 key phrase of 12, 15, 18, 21 or 24 words, then the key will // be derived from it. In this case: -// - the phrase may be followed by one or more items delimited by `/` characters. -// - the path may be followed by `///`, in which case everything after the `///` is treated +// - the phrase may be followed by one or more items delimited by "/" characters. +// - the path may be followed by "///", in which case everything after the "///" is treated // // as a password. -// - If `s` begins with a `/` character it is prefixed with the Substrate public `DevPhrase` +// - If s begins with a "/" character it is prefixed with the Substrate public DevPhrase // and // // interpreted as above. // // In this case they are interpreted as HDKD junctions; purely numeric items are interpreted as -// integers, non-numeric items as strings. Junctions prefixed with `/` are interpreted as soft -// junctions, and with `//` as hard junctions. +// integers, non-numeric items as strings. Junctions prefixed with "/" are interpreted as soft +// junctions, and with "//" as hard junctions. // // There is no correspondence mapping between SURI strings and the keys they represent. // Two different non-identical strings can actually lead to the same secret being derived. // Notably, integer junction indices may be legally prefixed with arbitrary number of zeros. -// Similarly an empty password (ending the SURI with `///`) is perfectly valid and will +// Similarly an empty password (ending the SURI with "///") is perfectly valid and will // generally be equivalent to no password at all. // -// `nil` is returned if no matches are found. +// nil is returned if no matches are found. func NewPairFromStringWithSeed(s string, passwordOverride *string) ( pair crypto.Pair[[32]byte, Signature], seed [32]byte, err error, ) { @@ -255,7 +254,7 @@ func NewPairFromStringWithSeed(s string, passwordOverride *string) ( return root.Derive(sURI.Junctions, &seed) } -// NewPairFromString interprets the string `s` in order to generate a key pair. +// NewPairFromString interprets the string s in order to generate a key pair. func NewPairFromString(s string, passwordOverride *string) (crypto.Pair[[32]byte, Signature], error) { pair, _, err := NewPairFromStringWithSeed(s, passwordOverride) return pair, err @@ -266,7 +265,7 @@ var _ crypto.Pair[[32]byte, Signature] = Pair{} // Signature is a signature (a 512-bit value). type Signature [64]byte -// NewSignatureFromRaw constructors a new instance from the given 64-byte `data`. +// NewSignatureFromRaw constructors a new instance from the given 64-byte data. // // NOTE: No checking goes on to ensure this is a real signature. Only use it if // you are certain that the array actually is a signature. diff --git a/internal/primitives/database/database.go b/internal/primitives/database/database.go index 88dff8e0fb..ea34ddf6bb 100644 --- a/internal/primitives/database/database.go +++ b/internal/primitives/database/database.go @@ -61,44 +61,44 @@ type Release[H any] struct { func (Release[H]) isChange() {} // Transaction is a series of changes to the database that can be committed atomically. They do not take effect until -// passed into `Database.Commit`. +// passed into Database.Commit. type Transaction[H any] []Change -// Set the value of `key` in `col` to `value`, replacing anything that is there currently. +// Set the value of key in col to value, replacing anything that is there currently. func (t *Transaction[H]) Set(col ColumnID, key []byte, value []byte) { *t = append(*t, Set{col, key, value}) } -// Remove the value of `key` in `col`. +// Remove the value of key in col. func (t *Transaction[H]) Remove(col ColumnID, key []byte) { *t = append(*t, Remove{col, key}) } -// Store the `preimage` of `hash` into the database, so that it may be looked up later with -// `Database.Get`. This may be called multiple times, but subsequent -// calls will ignore `preimage` and simply increase the number of references on `hash`. +// Store the preimage of hash into the database, so that it may be looked up later with +// Database.Get. This may be called multiple times, but subsequent +// calls will ignore preimage and simply increase the number of references on hash. func (t *Transaction[H]) Store(col ColumnID, hash H, preimage []byte) { *t = append(*t, Store[H]{col, hash, preimage}) } -// Reference will increase the number of references for `hash` in the database. +// Reference will increase the number of references for hash in the database. func (t *Transaction[H]) Reference(col ColumnID, hash H) { *t = append(*t, Reference[H]{col, hash}) } -// Release the preimage of `hash` from the database. An equal number of these to the number of corresponding `store`s -// must have been given before it is legal for `Database::get` to be unable to provide the preimage. +// Release the preimage of hash from the database. An equal number of these to the number of corresponding stores +// must have been given before Get() will be unable to provide the preimage. func (t *Transaction[H]) Release(col ColumnID, hash H) { *t = append(*t, Release[H]{col, hash}) } // Database is the interface to commit transactions as well as retrieve values type Database[H runtime.Hash] interface { - // Commit the `transaction` to the database atomically. Any further calls to `get` or `lookup` + // Commit the transaction to the database atomically. Any further calls to get or lookup // will reflect the new state. Commit(transaction Transaction[H]) error - // Retrieve the value previously stored against `key` or `nil` if `key` is not currently in the database. + // Retrieve the value previously stored against key or nil if key is not currently in the database. Get(col ColumnID, key []byte) []byte // Check if the value exists in the database without retrieving it. diff --git a/internal/primitives/database/mem.go b/internal/primitives/database/mem.go index a39889d71d..e0db49e83e 100644 --- a/internal/primitives/database/mem.go +++ b/internal/primitives/database/mem.go @@ -15,7 +15,7 @@ type refCountValue struct { value []byte } -// MemDB implements `Database` as an in-memory hash map. `Commit` is not atomic. +// MemDB implements Database as an in-memory hash map. Commit is not atomic. type MemDB[H runtime.Hash] struct { inner map[ColumnID]map[string]refCountValue sync.RWMutex @@ -28,7 +28,7 @@ func NewMemDB[H runtime.Hash]() *MemDB[H] { } } -// Commit the `transaction` to the database atomically. Any further calls to `get` or `lookup` +// Commit the transaction to the database atomically. Any further calls to get or lookup // will reflect the new state. func (mdb *MemDB[H]) Commit(transaction Transaction[H]) error { mdb.Lock() @@ -88,7 +88,7 @@ func (mdb *MemDB[H]) Commit(transaction Transaction[H]) error { return nil } -// Retrieve the value previously stored against `key` or `nil` if `key` is not currently in the database. +// Retrieve the value previously stored against key or nil if key is not currently in the database. func (mdb *MemDB[H]) Get(col ColumnID, key []byte) []byte { mdb.RLock() defer mdb.RUnlock() diff --git a/internal/primitives/runtime/digest.go b/internal/primitives/runtime/digest.go index 7ed6358c60..e748c346ae 100644 --- a/internal/primitives/runtime/digest.go +++ b/internal/primitives/runtime/digest.go @@ -26,8 +26,8 @@ func NewDigestItem[T DigestItemTypes](item T) DigestItem { // code and state duplication. It is erroneous for a runtime to produce // these, but this is not (yet) checked. // -// NOTE: the runtime is not allowed to panic or fail in an `on_initialize` -// call if an expected `PreRuntime` digest is not present. It is the +// NOTE: the runtime is not allowed to panic or fail in an on_initialize +// call if an expected PreRuntime digest is not present. It is the // responsibility of a external block verifier to check this. Runtime API calls // will initialize the block without pre-runtime digests, so initialization // cannot fail when they are missing. diff --git a/internal/primitives/runtime/generic/block.go b/internal/primitives/runtime/generic/block.go index 2a994d26e1..d0d9986e8e 100644 --- a/internal/primitives/runtime/generic/block.go +++ b/internal/primitives/runtime/generic/block.go @@ -15,12 +15,12 @@ type BlockID interface { isBlockID() } -// BlockIDTypes is the interface constraint of `BlockID`. +// BlockIDTypes is the interface constraint of BlockID. type BlockIDTypes[H runtime.Hash, N runtime.Number] interface { BlockIDHash[H] | BlockIDNumber[N] } -// NewBlockID is the constructor for `BlockID`. +// NewBlockID is the constructor for BlockID. func NewBlockID[H runtime.Hash, N runtime.Number, T BlockIDTypes[H, N]](blockID T) BlockID { return BlockID(blockID) } @@ -74,7 +74,7 @@ func (b Block[N, H, Hasher]) Hash() H { return hasher.HashEncoded(b.header) } -// NewBlock is the constructor for `Block`. +// NewBlock is the constructor for Block. func NewBlock[N runtime.Number, H runtime.Hash, Hasher runtime.Hasher[H]]( header runtime.Header[N, H], extrinsics []runtime.Extrinsic) Block[N, H, Hasher] { return Block[N, H, Hasher]{ diff --git a/internal/primitives/runtime/generic/header.go b/internal/primitives/runtime/generic/header.go index ef10c50ab4..0739f6949f 100644 --- a/internal/primitives/runtime/generic/header.go +++ b/internal/primitives/runtime/generic/header.go @@ -11,7 +11,7 @@ import ( "github.com/ChainSafe/gossamer/pkg/scale" ) -// Header is a block header, and implements a compatible encoding to `sp_runtime::generic::Header` +// Header is a block header, and implements a compatible encoding to sp_runtime::generic::Header type Header[N runtime.Number, H runtime.Hash, Hasher runtime.Hasher[H]] struct { // The parent hash. parentHash H @@ -113,7 +113,7 @@ func (h Header[N, H, Hasher]) Hash() H { return hasher.HashEncoded(h) } -// NewHeader is the constructor for `Header` +// NewHeader is the constructor for Header func NewHeader[N runtime.Number, H runtime.Hash, Hasher runtime.Hasher[H]]( number N, extrinsicsRoot H, diff --git a/internal/primitives/runtime/runtime.go b/internal/primitives/runtime/runtime.go index 61c1a22010..d30fabe6b0 100644 --- a/internal/primitives/runtime/runtime.go +++ b/internal/primitives/runtime/runtime.go @@ -9,7 +9,7 @@ import "slices" // // Essentially a finality proof. The exact formulation will vary between consensus algorithms. In the case where there // are multiple valid proofs, inclusion within the block itself would allow swapping justifications to change the -// block's hash (and thus fork the chain). Sending a `Justification` alongside a block instead bypasses this problem. +// block's hash (and thus fork the chain). Sending a Justification alongside a block instead bypasses this problem. // // Each justification is provided as an encoded blob, and is tagged with an ID to identify the consensus engine that // generated the proof (we might have multiple justifications from different engines for the same block). diff --git a/internal/primitives/state-machine/trie_backend_test.go b/internal/primitives/state-machine/trie_backend_test.go index 5993817877..8f4c2c944e 100644 --- a/internal/primitives/state-machine/trie_backend_test.go +++ b/internal/primitives/state-machine/trie_backend_test.go @@ -856,10 +856,10 @@ func TestTrieBackend(t *testing.T) { } }) - // Test to ensure that recording the same `key` for different tries works as expected. + // Test to ensure that recording the same key for different tries works as expected. // // Each trie stores a different value under the same key. The values are big enough to - // be not inlined with `StateVersion::V1`, this is important to test the expected behavior. The + // be not inlined with StateVersionV1, this is important to test the expected behavior. The // trie recorder is expected to differentiate key access based on the different storage roots // of the tries. t.Run("recording_same_key_access_in_different_tries", func(t *testing.T) {