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

tmpnet: Add support for subnets #2492

Merged
merged 7 commits into from
Jan 17, 2024
Merged

tmpnet: Add support for subnets #2492

merged 7 commits into from
Jan 17, 2024

Conversation

marun
Copy link
Contributor

@marun marun commented Dec 15, 2023

Add subnet support to tmpnet fixture to support both in-repo subnet testing and tmpnet usage by subnet-evm.

Follow-on PRs that use this code include:

TODO

  • Update README to reflect subnet support
  • Improve output of subnet creation process

@marun marun added testing This primarily focuses on testing e2e-subnets Enable e2e testing for subnets labels Dec 15, 2023
@marun marun self-assigned this Dec 15, 2023
@marun marun force-pushed the tmpnet-subnets branch 5 times, most recently from d24f48e to 4e17abf Compare December 18, 2023 03:32
@marun marun linked an issue Dec 18, 2023 that may be closed by this pull request
6 tasks
@marun marun force-pushed the tmpnet-subnets branch 2 times, most recently from 85776ec to 6b65ce9 Compare December 18, 2023 04:56
@marun marun force-pushed the tmpnet-subnets branch 6 times, most recently from 8bdc55f to 7667986 Compare December 18, 2023 06:55
@marun marun mentioned this pull request Dec 18, 2023
5 tasks
@marun marun force-pushed the tmpnet-refactor-network branch 3 times, most recently from 80f6c63 to f1ec505 Compare December 19, 2023 22:43
@marun marun force-pushed the tmpnet-subnets branch 6 times, most recently from 9187355 to 6b7231a Compare December 23, 2023 01:13
Base automatically changed from tmpnet-refactor-network to dev January 5, 2024 21:06
@marun marun marked this pull request as ready for review January 8, 2024 12:23
@marun marun requested review from abi87 and gyuho as code owners January 8, 2024 12:23
Copy link
Contributor

@abi87 abi87 left a comment

Choose a reason for hiding this comment

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

left a few questions

Comment on lines -34 to +36
}
Env = &TestEnvironment{}
require.NoError(json.Unmarshal(envBytes, Env))
Env.require = require
Copy link
Contributor

Choose a reason for hiding this comment

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

q: why this change? It's fine, just wonder why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a subtle change, but it avoids the problem of the unmarshaled value overwriting the local instance of require with an unusable value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Because require is a non-exported variable, the unmarshaller won't touch it. But I think this does probably make things more clear.

} else {
network = StartNetwork(flagVars.AvalancheGoExecPath(), DefaultNetworkDir)
network = desiredNetwork
Copy link
Contributor

Choose a reason for hiding this comment

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

q: looks to me as if we don't really need to do the tmpnet.ReadNetwork above if desiredNetwork is specified. If this is correct can we just skip it?

Copy link
Contributor Author

@marun marun Jan 12, 2024

Choose a reason for hiding this comment

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

If networkDir is specified, then it's necessary to read the network from that path. desiredNetwork is then only used to configure subnets. This supports using an existing network (e.g. --use-existing-network) to reduce the setup cost for iterative test development (e.g. setup network once, use --use-existing-network to reuse it for multiple suite invocations).

tests/fixture/e2e/helpers.go Show resolved Hide resolved
Comment on lines +135 to +149
│ └── raZ51bwfepaSaZ1MNSRNYNs3ZPfj...U7pa3
│ └── config.json // Custom chain configuration for all nodes
Copy link
Contributor

Choose a reason for hiding this comment

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

nice catch

tests/fixture/tmpnet/network.go Show resolved Hide resolved
@@ -87,3 +87,12 @@ func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error) {
}
return keys, nil
}

func GetVMID(vmName string) (ids.ID, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe I am nitpicking but I have a bit of an issue with this: while a VMID must be unique it's name does not have to. Is seems that we are inforcing here a stricter relationship among VM ID and name.
It may be fine for our purposes, but maybe we should note it down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm afraid I don't have much insight here - this code was copied from ANR.

How important is it for this detail to be documented if it's just an implementation detail for a test-only deployment framework?

Copy link
Contributor

Choose a reason for hiding this comment

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

If ANR does like that it's fine with me. That is actually a user facing product so it's the most informative I guess

Copy link
Contributor

Choose a reason for hiding this comment

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

I've always hated this. This is really not what VMIDs are supposed to be at all... it's just an ugly hack because it happens to work with the VMs we've developed internally.

It is not possible to determine the VMID from the name of the VM (or chain, or subnet). Which is why I didn't allow this function into avalanchego's utils previously (internal ref: https://github.com/ava-labs/avalanchego-internal/pull/1388).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to do something else, I have no attachment here. I just want to be able to deploy subnets. How should it be determined?

Copy link
Contributor

Choose a reason for hiding this comment

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

How should it be determined?

Currently VMs arbitrarily specify their VMIDs. (so I think the user of tmpnet.Chain should just provide the VMID.

My hope in the future is that VMIDs will come from the public key of the developer of the VM or something which will fit nicely into a VM marketplace.

But I think rather than specifying names it should be expected to specify the ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

tests/fixture/tmpnet/README.md Outdated Show resolved Hide resolved
&txs.SubnetValidator{
Validator: txs.Validator{
NodeID: node.NodeID,
Start: uint64(startTime.Unix()),
Copy link
Contributor

Choose a reason for hiding this comment

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

comment: if Durango is already active in the test network, this should not be needed.
It's fine leaving like this rn, I'll make a pass through the codebase to clean this up as soon as Durango activates (we can also simplify the API inputs)

Copy link
Contributor

@abi87 abi87 left a comment

Choose a reason for hiding this comment

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

lgtm

@marun
Copy link
Contributor Author

marun commented Jan 12, 2024

Rebased


type Chain struct {
// Set statically
VMName string
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer for this to be VMID ids.ID - avalanchego doesn't know anything about VM names. (Then I think we can remove the GetVMID function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -87,3 +87,12 @@ func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error) {
}
return keys, nil
}

func GetVMID(vmName string) (ids.ID, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How should it be determined?

Currently VMs arbitrarily specify their VMIDs. (so I think the user of tmpnet.Chain should just provide the VMID.

My hope in the future is that VMIDs will come from the public key of the developer of the VM or something which will fit nicely into a VM marketplace.

But I think rather than specifying names it should be expected to specify the ID.

Comment on lines 496 to 500
subnetIDsValue := ""
if len(subnetIDs) > 0 {
subnetIDsValue = strings.Join(subnetIDs, ",")
}
flags[config.TrackSubnetsKey] = subnetIDsValue
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
subnetIDsValue := ""
if len(subnetIDs) > 0 {
subnetIDsValue = strings.Join(subnetIDs, ",")
}
flags[config.TrackSubnetsKey] = subnetIDsValue
flags[config.TrackSubnetsKey] = strings.Join(subnetIDs, ",")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@StephenButtolph StephenButtolph added this to the v1.10.18 milestone Jan 17, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Jan 17, 2024
Merged via the queue into dev with commit 26e329a Jan 17, 2024
17 checks passed
@StephenButtolph StephenButtolph deleted the tmpnet-subnets branch January 17, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e-subnets Enable e2e testing for subnets testing This primarily focuses on testing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add subnet support to the tmpnet fixture
3 participants