Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/fixture/subnet/xsvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/vms/example/xsvm"
"github.com/ava-labs/avalanchego/vms/example/xsvm/genesis"
)

Expand All @@ -35,7 +35,7 @@ func NewXSVMOrPanic(name string, key *secp256k1.PrivateKey, nodes ...*tmpnet.Nod
Name: name,
Chains: []*tmpnet.Chain{
{
VMID: xsvm.ID,
VMID: constants.XSVMID,
Genesis: genesisBytes,
PreFundedKey: key,
},
Expand Down
29 changes: 29 additions & 0 deletions utils/constants/vm_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,37 @@ package constants

import "github.com/ava-labs/avalanchego/ids"

const (
PlatformVMName = "platformvm"
AVMName = "avm"
EVMName = "evm"
SubnetEVMName = "subnetevm"
XSVMName = "xsvm"
Comment on lines +12 to +13
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I like having non-Primary-Network VMs here, but I guess there is no alternative?

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 isn't required per-say... But I felt like the UX improvement was worth the odd behavior... I actually don't have any issue with the xsvm being here... Having subnet-evm be here is suboptimal.

)

var (
PlatformVMID = ids.ID{'p', 'l', 'a', 't', 'f', 'o', 'r', 'm', 'v', 'm'}
AVMID = ids.ID{'a', 'v', 'm'}
EVMID = ids.ID{'e', 'v', 'm'}
SubnetEVMID = ids.ID{'s', 'u', 'b', 'n', 'e', 't', 'e', 'v', 'm'}
XSVMID = ids.ID{'x', 's', 'v', 'm'}
)

// VMName returns the name of the VM with the provided ID. If a human readable
// name isn't known, then the formatted ID is returned.
func VMName(vmID ids.ID) string {
switch vmID {
case PlatformVMID:
return PlatformVMName
case AVMID:
return AVMName
case EVMID:
return EVMName
case SubnetEVMID:
return SubnetEVMName
case XSVMID:
return XSVMName
default:
return vmID.String()
}
}
4 changes: 2 additions & 2 deletions vms/example/xsvm/cmd/chain/create/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/spf13/cobra"

"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/example/xsvm"
"github.com/ava-labs/avalanchego/vms/example/xsvm/genesis"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/avalanchego/wallet/subnet/primary"
Expand Down Expand Up @@ -72,7 +72,7 @@ func createFunc(c *cobra.Command, args []string) error {
createChainTxID, err := pWallet.IssueCreateChainTx(
config.SubnetID,
genesisBytes,
xsvm.ID,
constants.XSVMID,
nil,
config.Name,
common.WithContext(ctx),
Expand Down
5 changes: 3 additions & 2 deletions vms/example/xsvm/cmd/version/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"

"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/avalanchego/vms/example/xsvm"
)
Expand All @@ -29,8 +30,8 @@ func Command() *cobra.Command {
func versionFunc(*cobra.Command, []string) error {
fmt.Printf(
format,
xsvm.Name,
xsvm.ID,
constants.XSVMName,
constants.XSVMID,
xsvm.Version,
version.RPCChainVMProtocol,
)
Expand Down
21 changes: 6 additions & 15 deletions vms/example/xsvm/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@

package xsvm

import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/version"
)
import "github.com/ava-labs/avalanchego/version"

const Name = "xsvm"

var (
ID = ids.ID{'x', 's', 'v', 'm'}

Version = &version.Semantic{
Major: 1,
Minor: 0,
Patch: 4,
}
)
var Version = &version.Semantic{
Major: 1,
Minor: 0,
Patch: 4,
}
3 changes: 2 additions & 1 deletion vms/example/xsvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/json"
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/avalanchego/vms/example/xsvm/api"
Expand Down Expand Up @@ -124,7 +125,7 @@ func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
)
return map[string]http.Handler{
"": server,
}, server.RegisterService(api, Name)
}, server.RegisterService(api, constants.XSVMName)
}

func (*VM) HealthCheck(context.Context) (interface{}, error) {
Expand Down
4 changes: 2 additions & 2 deletions wallet/subnet/primary/examples/create-chain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/ava-labs/avalanchego/genesis"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/example/xsvm"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/avalanchego/wallet/subnet/primary"

Expand All @@ -33,7 +33,7 @@ func main() {
},
},
}
vmID := xsvm.ID
vmID := constants.XSVMID
name := "let there"

subnetID, err := ids.FromString(subnetIDStr)
Expand Down