Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: refactor initialization with single node logic #1963

Merged
merged 6 commits into from
Jul 5, 2022

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Jul 4, 2022

Part of: #1879

What is the purpose of the change

Building up on #1898

This refactor separates the initialization logic into 2 parts:

  • initialization.InitChain() - for spinning up a chain with several validators
  • initialization.InitSingleNode() - for spinning up a single node (e.g. for testing state-sync)

The documentation for this is already merged and available here: https://github.com/osmosis-labs/osmosis/tree/main/tests/e2e/initialization

Testing and Verifying

This change is a trivial rework / code cleanup without any test coverage.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

@p0mvn p0mvn mentioned this pull request Jul 4, 2022
@p0mvn p0mvn marked this pull request as ready for review July 4, 2022 21:39
@p0mvn p0mvn requested review from a team and czarcas7ic July 4, 2022 21:39
Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

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

Incredible job with this! Was honestly really easy to follow despite the size. I say we merge asap and can address smaller bugs that may come up through watching it run on prod as we discussed in todays meeting


func InitSingleNode(chainId, dataDir string, existingGenesisDir string, nodeConfig *NodeConfig, votingPeriod time.Duration, trustHeight int64, trustHash string, stateSyncRPCServers []string) (*Node, error) {
if nodeConfig.IsValidator {
return nil, errors.New("creating individual validator nodes after starting up chain is not currently supported")
Copy link
Member

Choose a reason for hiding this comment

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

Should we make an issue for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can address this when there is a need for it in the future. Currently, for testing state sync we should be able to use a regular full node instead of a validator.

I don't think there's is a current use case for us to have the validator nodes

require.NoError(t, err)

actualNode, err := initialization.InitSingleNode(existingChain.ChainMeta.Id, dataDir, filepath.Join(existingChain.Nodes[0].ConfigDir, "config", "genesis.json"), expectedConfig, time.Second*3, 3, "testHash", []string{"some server"})
require.NoError(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should also check that the actual genesis.json file itself is the same between the single node and a randomly selected node from the chain, or do you think this is a good enough check already?

Copy link
Member Author

@p0mvn p0mvn Jul 5, 2022

Choose a reason for hiding this comment

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

I think this would be necessary to have if this was the actual system but since we are "testing a test", what we have now is sufficient IMO.

The goal for this test was to make sure the expected initialization files are created because I was finding myself doing that manually a lot while refactoring

tests/e2e/initialization/node.go Outdated Show resolved Hide resolved
existingChain, err := initialization.InitChain(id, dataDir, existingChainNodeConfigs, time.Second*3, forkHeight)
require.NoError(t, err)

actualNode, err := initialization.InitSingleNode(existingChain.ChainMeta.Id, dataDir, filepath.Join(existingChain.Nodes[0].ConfigDir, "config", "genesis.json"), expectedConfig, time.Second*3, 3, "testHash", []string{"some server"})
Copy link
Member

Choose a reason for hiding this comment

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

I assume the next step here is automating pulling a specified height hash from one of the validator's RPCs? Shouldn't we have enough here already to start filling in the RPC server address? IMO we should just fill this in with a single RPC twice ("1.23.45.67:26657,1.23.45.67:26657"), just makes it simpler to debug. Unless you feel we should be testing with two separate RPCs

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, the next step would be to start actually utilizing this initialization logic for spinning up a state-synching full node. I don't have that completed yet. Before I continue with this, there is one more large refactoring PR to merge.

And thanks for the advice, I will make sure to use the same one twice

@p0mvn p0mvn added the A:backport/v10.x backport patches to v10.x branch label Jul 5, 2022
@p0mvn p0mvn merged commit 1da14b8 into main Jul 5, 2022
@p0mvn p0mvn deleted the roman/e2e-single-node branch July 5, 2022 19:45
p0mvn added a commit that referenced this pull request Jul 5, 2022
* e2e: refactor initialization with single node logic

* lint and remove redundant getters from node

* restore accidental change

* rename init to InitChain

* persistentPeers typo
p0mvn added a commit that referenced this pull request Jul 5, 2022
…1975)

* e2e: refactor initialization with single node logic

* lint and remove redundant getters from node

* restore accidental change

* rename init to InitChain

* persistentPeers typo
@ValarDragon ValarDragon added A:backport/v10.x backport patches to v10.x branch and removed A:backport/v10.x backport patches to v10.x branch labels Jul 11, 2022
mergify bot pushed a commit that referenced this pull request Jul 11, 2022
* e2e: refactor initialization with single node logic

* lint and remove redundant getters from node

* restore accidental change

* rename init to InitChain

* persistentPeers typo

(cherry picked from commit 1da14b8)

# Conflicts:
#	tests/e2e/e2e_setup_test.go
#	tests/e2e/e2e_test.go
#	tests/e2e/e2e_util_test.go
#	tests/e2e/initialization/init.go
#	tests/e2e/initialization/init_test.go
#	tests/e2e/initialization/node/main.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v10.x backport patches to v10.x branch T:build
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants