@@ -37,8 +37,8 @@ import (
3737
3838var (
3939 MainnetCChainID = ids .FromStringOrPanic ("2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5" )
40+ MainnetXChainID = ids .FromStringOrPanic ("2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM" )
4041
41- mainnetXChainID = ids .FromStringOrPanic ("2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM" )
4242 mainnetAvaxAssetID = ids .FromStringOrPanic ("FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z" )
4343)
4444
@@ -187,6 +187,9 @@ type VMParams struct {
187187 ConfigBytes []byte
188188 SubnetID ids.ID
189189 ChainID ids.ID
190+ // ChainToSubnet maps chain IDs to their subnet IDs. This mapping is used by
191+ // the VM to validate cross-chain operations and warp messages.
192+ ChainToSubnet map [ids.ID ]ids.ID
190193}
191194
192195// NewMainnetVM creates and initializes a VM configured for mainnet block
@@ -218,13 +221,6 @@ func NewMainnetVM(
218221 sharedMemoryDB := prefixdb .New ([]byte ("sharedmemory" ), db )
219222 atomicMemory := atomic .NewMemory (sharedMemoryDB )
220223
221- chainIDToSubnetID := map [ids.ID ]ids.ID {
222- mainnetXChainID : constants .PrimaryNetworkID ,
223- MainnetCChainID : constants .PrimaryNetworkID ,
224- vmParams .ChainID : vmParams .SubnetID ,
225- ids .Empty : constants .PrimaryNetworkID ,
226- }
227-
228224 if err := vm .Initialize (
229225 ctx ,
230226 & snow.Context {
@@ -235,7 +231,7 @@ func NewMainnetVM(
235231 PublicKey : blsPublicKey ,
236232 NetworkUpgrades : upgrade .Mainnet ,
237233
238- XChainID : mainnetXChainID ,
234+ XChainID : MainnetXChainID ,
239235 CChainID : MainnetCChainID ,
240236 AVAXAssetID : mainnetAvaxAssetID ,
241237
@@ -248,7 +244,7 @@ func NewMainnetVM(
248244
249245 ValidatorState : & validatorstest.State {
250246 GetSubnetIDF : func (_ context.Context , chainID ids.ID ) (ids.ID , error ) {
251- subnetID , ok := chainIDToSubnetID [chainID ]
247+ subnetID , ok := vmParams . ChainToSubnet [chainID ]
252248 if ok {
253249 return subnetID , nil
254250 }
0 commit comments