-
Notifications
You must be signed in to change notification settings - Fork 701
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
Conversation
d24f48e
to
4e17abf
Compare
85776ec
to
6b65ce9
Compare
b86451d
to
99eecff
Compare
8bdc55f
to
7667986
Compare
80f6c63
to
f1ec505
Compare
7667986
to
d7d4751
Compare
f1ec505
to
6939831
Compare
9187355
to
6b7231a
Compare
There was a problem hiding this 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
} | ||
Env = &TestEnvironment{} | ||
require.NoError(json.Unmarshal(envBytes, Env)) | ||
Env.require = require |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
│ └── raZ51bwfepaSaZ1MNSRNYNs3ZPfj...U7pa3 | ||
│ └── config.json // Custom chain configuration for all nodes |
There was a problem hiding this comment.
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/utils.go
Outdated
@@ -87,3 +87,12 @@ func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error) { | |||
} | |||
return keys, nil | |||
} | |||
|
|||
func GetVMID(vmName string) (ids.ID, error) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 VMID
s. (so I think the user of tmpnet.Chain
should just provide the VMID
.
My hope in the future is that VMID
s 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
&txs.SubnetValidator{ | ||
Validator: txs.Validator{ | ||
NodeID: node.NodeID, | ||
Start: uint64(startTime.Unix()), |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Rebased |
tests/fixture/tmpnet/subnet.go
Outdated
|
||
type Chain struct { | ||
// Set statically | ||
VMName string |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/fixture/tmpnet/utils.go
Outdated
@@ -87,3 +87,12 @@ func NewPrivateKeys(keyCount int) ([]*secp256k1.PrivateKey, error) { | |||
} | |||
return keys, nil | |||
} | |||
|
|||
func GetVMID(vmName string) (ids.ID, error) { |
There was a problem hiding this comment.
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 VMID
s. (so I think the user of tmpnet.Chain
should just provide the VMID
.
My hope in the future is that VMID
s 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.
tests/fixture/tmpnet/network.go
Outdated
subnetIDsValue := "" | ||
if len(subnetIDs) > 0 { | ||
subnetIDsValue = strings.Join(subnetIDs, ",") | ||
} | ||
flags[config.TrackSubnetsKey] = subnetIDsValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subnetIDsValue := "" | |
if len(subnetIDs) > 0 { | |
subnetIDsValue = strings.Join(subnetIDs, ",") | |
} | |
flags[config.TrackSubnetsKey] = subnetIDsValue | |
flags[config.TrackSubnetsKey] = strings.Join(subnetIDs, ",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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:
e2e
: Add basic warp test with xsvm #2043vms
: Migrate timestampvm #2493e2e
: Switch to the tmpnet fixture subnet-evm#1027TODO