Skip to content

feat(e2e): simplify the relation between manifest and testnet#3964

Merged
cason merged 11 commits intomainfrom
cason/e2e-refactor
Sep 4, 2024
Merged

feat(e2e): simplify the relation between manifest and testnet#3964
cason merged 11 commits intomainfrom
cason/e2e-refactor

Conversation

@cason
Copy link
Copy Markdown

@cason cason commented Sep 2, 2024

Refactors the e2e testbed to remove some unnecessary duplication between Manifest and Testnet, and ManifestNode and Node. Fields that are identical in the two types are removed from the latter, which includes (extends) the former. Fields that had the same name but different types or semantics in the two versions, were renamed in the manifest.

With this change, to add a new field to the configuration of a testnet or a node, it is enough to update the Manifest or ManifestNode. The new field must also be added to Testnet or Node if it needs to be somehow parsed (see the examples of the Seeds and PersistentPeers fields).


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

@cason cason force-pushed the cason/e2e-refactor branch from 4bbb231 to 4991c80 Compare September 2, 2024 11:17
@cason cason changed the title feat(e2e): some refactor [DRAFT] feat(e2e): simplify the relation between manifest and testnet Sep 2, 2024
@cason cason marked this pull request as ready for review September 2, 2024 12:19
@cason cason requested a review from a team as a code owner September 2, 2024 12:19
@cason cason requested a review from a team September 2, 2024 12:19
@cason cason added the e2e Related to our end-to-end tests label Sep 2, 2024
// Defaults to "validator". Full nodes do not get a signing key (a dummy key
// is generated), and seed nodes run in seed mode with the PEX reactor enabled.
Mode string `toml:"mode"`
ModeStr string `toml:"mode"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of putting type into a variable name?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have Testnet.Mode and had Manifest.Node. They are from different types.

Ok, it is true that type Mode = String but they are different variables.

I renamed all variables in Manifest that collide with names in Testnet.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also trying to understand the motivation for these renames here, struct fields are scoped to the struct, so you can't experience 'collisions' in a sense that you can't access fields of one struct while referencing another, even if fields have the same names.

Could you please point in the code where this collision could happen ? If it's just a matter of providing context via the field name, I'd think we should just apply KISS principle and leave the way it is. But I might have missed the point with the rename.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good

Copy link
Copy Markdown
Collaborator

@andynog andynog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed and made some comments and had some questions.

ValidatorUpdates: map[int64]map[*Node]int64{},
Nodes: []*Node{},
}
if testnet.InitialHeight == 0 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this if in the genesis validation if it's height = 0 it changes it to height = 1 ?

if genDoc.InitialHeight == 0 {

// Defaults to "validator". Full nodes do not get a signing key (a dummy key
// is generated), and seed nodes run in seed mode with the PEX reactor enabled.
Mode string `toml:"mode"`
ModeStr string `toml:"mode"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also trying to understand the motivation for these renames here, struct fields are scoped to the struct, so you can't experience 'collisions' in a sense that you can't access fields of one struct while referencing another, even if fields have the same names.

Could you please point in the code where this collision could happen ? If it's just a matter of providing context via the field name, I'd think we should just apply KISS principle and leave the way it is. But I might have missed the point with the rename.

Copy link
Copy Markdown
Collaborator

@andynog andynog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, overall it improves the code

@cason cason added this pull request to the merge queue Sep 4, 2024
Merged via the queue into main with commit 40c4b40 Sep 4, 2024
@cason cason deleted the cason/e2e-refactor branch September 4, 2024 13:17
github-merge-queue bot pushed a commit that referenced this pull request Sep 4, 2024
Addresses #3832.

Introduces a flag `config` to the manifest. It is a list of strings that
should have the format `key = value`. Keys are any of the configuration
parameters included in a CometBFT configuration file.

The flag can be global, meaning that the configurations will be applied
for every node in the network, or specific for a given node, when
inserted in the section referring to that node. Local/specific
configurations are applied after the global ones, therefore overriding
them.

Example:

```
config = [
   "p2p.send_rate = 51200",
   "filter_peers = true",
]
```

The configurations are applying using `viper`, as I could not find
another way to load configuration parameters. They are always loaded as
a string, and this appears to work correctly.

Note: this PR is based atop #3964 for simplicity, but it does not need
to.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
github-merge-queue bot pushed a commit that referenced this pull request Sep 4, 2024
Closes #3961.

Similarly to #3967, introduces a new `genesis` field for manifest files.
The format is `key = value` and multiple entries can be provided. For
example,

```
genesis = [ 
    "consensus_params.evidence.max_bytes = 1000", 
    "chain_id = pr3969" 
]
```

After the genesis document is produced by the `setup` implementation of
the runner, the provided genesis customized configurations are applied
to the generated genesis file. The solution also uses `viper`, as it
allows setting only some specific keys, leaving the pre-produced content
untouched.

Note: this PR is based atop
#3964 for simplicity, but it
does not need to.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
sergio-mena pushed a commit that referenced this pull request Sep 24, 2024
As per title.

It was like this before #3964,
so restoring original name.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
hvanz pushed a commit that referenced this pull request Sep 25, 2024
Refactors the `e2e` testbed to remove some unnecessary duplication
between `Manifest` and `Testnet`, and `ManifestNode` and `Node`. Fields
that are identical in the two types are removed from the latter, which
includes (extends) the former. Fields that had the same name but
different types or semantics in the two versions, were renamed in the
manifest.

With this change, to add a new field to the configuration of a testnet
or a node, it is enough to update the `Manifest` or `ManifestNode`. The
new field must also be added to `Testnet` or `Node` if it needs to be
somehow parsed (see the examples of the `Seeds` and `PersistentPeers`
fields).

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
hvanz pushed a commit that referenced this pull request Sep 25, 2024
Refactors the `e2e` testbed to remove some unnecessary duplication
between `Manifest` and `Testnet`, and `ManifestNode` and `Node`. Fields
that are identical in the two types are removed from the latter, which
includes (extends) the former. Fields that had the same name but
different types or semantics in the two versions, were renamed in the
manifest.

With this change, to add a new field to the configuration of a testnet
or a node, it is enough to update the `Manifest` or `ManifestNode`. The
new field must also be added to `Testnet` or `Node` if it needs to be
somehow parsed (see the examples of the `Seeds` and `PersistentPeers`
fields).

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
mergify bot pushed a commit that referenced this pull request Oct 20, 2024
Refactors the `e2e` testbed to remove some unnecessary duplication
between `Manifest` and `Testnet`, and `ManifestNode` and `Node`. Fields
that are identical in the two types are removed from the latter, which
includes (extends) the former. Fields that had the same name but
different types or semantics in the two versions, were renamed in the
manifest.

With this change, to add a new field to the configuration of a testnet
or a node, it is enough to update the `Manifest` or `ManifestNode`. The
new field must also be added to `Testnet` or `Node` if it needs to be
somehow parsed (see the examples of the `Seeds` and `PersistentPeers`
fields).

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
(cherry picked from commit 40c4b40)

# Conflicts:
#	test/e2e/generator/generate.go
#	test/e2e/pkg/testnet.go
mergify bot added a commit that referenced this pull request Oct 20, 2024
Addresses #3832.

Introduces a flag `config` to the manifest. It is a list of strings that
should have the format `key = value`. Keys are any of the configuration
parameters included in a CometBFT configuration file.

The flag can be global, meaning that the configurations will be applied
for every node in the network, or specific for a given node, when
inserted in the section referring to that node. Local/specific
configurations are applied after the global ones, therefore overriding
them.

Example:

```
config = [
   "p2p.send_rate = 51200",
   "filter_peers = true",
]
```

The configurations are applying using `viper`, as I could not find
another way to load configuration parameters. They are always loaded as
a string, and this appears to work correctly.

Note: this PR is based atop #3964 for simplicity, but it does not need
to.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
(cherry picked from commit cea82b1)
mergify bot pushed a commit that referenced this pull request Oct 20, 2024
Closes #3961.

Similarly to #3967, introduces a new `genesis` field for manifest files.
The format is `key = value` and multiple entries can be provided. For
example,

```
genesis = [
    "consensus_params.evidence.max_bytes = 1000",
    "chain_id = pr3969"
]
```

After the genesis document is produced by the `setup` implementation of
the runner, the provided genesis customized configurations are applied
to the generated genesis file. The solution also uses `viper`, as it
allows setting only some specific keys, leaving the pre-produced content
untouched.

Note: this PR is based atop
#3964 for simplicity, but it
does not need to.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
(cherry picked from commit 6c5cd32)

# Conflicts:
#	test/e2e/pkg/manifest.go
#	test/e2e/pkg/testnet.go
#	test/e2e/runner/setup.go
mergify bot added a commit that referenced this pull request Oct 20, 2024
#3964) (#4308)

Refactors the `e2e` testbed to remove some unnecessary duplication
between `Manifest` and `Testnet`, and `ManifestNode` and `Node`. Fields
that are identical in the two types are removed from the latter, which
includes (extends) the former. Fields that had the same name but
different types or semantics in the two versions, were renamed in the
manifest.

With this change, to add a new field to the configuration of a testnet
or a node, it is enough to update the `Manifest` or `ManifestNode`. The
new field must also be added to `Testnet` or `Node` if it needs to be
somehow parsed (see the examples of the `Seeds` and `PersistentPeers`
fields).

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
<hr>This is an automatic backport of pull request #3964 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Daniel <daniel.cason@informal.systems>
cason pushed a commit that referenced this pull request Oct 20, 2024
Closes #3961.

Similarly to #3967, introduces a new `genesis` field for manifest files.
The format is `key = value` and multiple entries can be provided. For
example,

```
genesis = [ 
    "consensus_params.evidence.max_bytes = 1000", 
    "chain_id = pr3969" 
]
```

After the genesis document is produced by the `setup` implementation of
the runner, the provided genesis customized configurations are applied
to the generated genesis file. The solution also uses `viper`, as it
allows setting only some specific keys, leaving the pre-produced content
untouched.

Note: this PR is based atop
#3964 for simplicity, but it
does not need to.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
mergify bot added a commit that referenced this pull request Oct 20, 2024
…ort #3967) (#4309)

Addresses #3832.

Introduces a flag `config` to the manifest. It is a list of strings that
should have the format `key = value`. Keys are any of the configuration
parameters included in a CometBFT configuration file.

The flag can be global, meaning that the configurations will be applied
for every node in the network, or specific for a given node, when
inserted in the section referring to that node. Local/specific
configurations are applied after the global ones, therefore overriding
them.

Example:

```
config = [
   "p2p.send_rate = 51200",
   "filter_peers = true",
]
```

The configurations are applying using `viper`, as I could not find
another way to load configuration parameters. They are always loaded as
a string, and this appears to work correctly.

Note: this PR is based atop #3964 for simplicity, but it does not need
to.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
<hr>This is an automatic backport of pull request #3967 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Daniel <daniel.cason@informal.systems>
cason pushed a commit that referenced this pull request Oct 20, 2024
Closes #3961.

Similarly to #3967, introduces a new `genesis` field for manifest files.
The format is `key = value` and multiple entries can be provided. For
example,

```
genesis = [ 
    "consensus_params.evidence.max_bytes = 1000", 
    "chain_id = pr3969" 
]
```

After the genesis document is produced by the `setup` implementation of
the runner, the provided genesis customized configurations are applied
to the generated genesis file. The solution also uses `viper`, as it
allows setting only some specific keys, leaving the pre-produced content
untouched.

Note: this PR is based atop
#3964 for simplicity, but it
does not need to.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
cason pushed a commit that referenced this pull request Oct 20, 2024
…port #3969) (#4312)

Closes #3961.

Similarly to #3967, introduces a new `genesis` field for manifest files.
The format is `key = value` and multiple entries can be provided. For
example,

```
genesis = [ 
    "consensus_params.evidence.max_bytes = 1000", 
    "chain_id = pr3969" 
]
```

After the genesis document is produced by the `setup` implementation of
the runner, the provided genesis customized configurations are applied
to the generated genesis file. The solution also uses `viper`, as it
allows setting only some specific keys, leaving the pre-produced content
untouched.

Note: this PR is based atop
#3964 for simplicity, but it
does not need to.

---

This is an manual backport of pull request
#3969.

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e Related to our end-to-end tests

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants