diff --git a/vms/platformvm/block/codec.go b/vms/platformvm/block/codec.go index dbb446161fb5..56b3590dcdc4 100644 --- a/vms/platformvm/block/codec.go +++ b/vms/platformvm/block/codec.go @@ -32,10 +32,9 @@ func init() { errs := wrappers.Errs{} for _, c := range []linearcodec.Codec{c, gc} { errs.Add( - RegisterApricotBlockTypes(c), - txs.RegisterUnsignedTxsTypes(c), - RegisterBanffBlockTypes(c), - txs.RegisterDurangoUnsignedTxsTypes(c), + RegisterApricotTypes(c), + RegisterBanffTypes(c), + RegisterDurangoTypes(c), ) } @@ -50,25 +49,33 @@ func init() { } } -// RegisterApricotBlockTypes allows registering relevant type of blocks package -// in the right sequence. Following repackaging of platformvm package, a few -// subpackage-level codecs were introduced, each handling serialization of -// specific types. -func RegisterApricotBlockTypes(targetCodec codec.Registry) error { +// RegisterApricotTypes registers the type information for blocks that were +// valid during the Apricot series of upgrades. +func RegisterApricotTypes(targetCodec linearcodec.Codec) error { return errors.Join( targetCodec.RegisterType(&ApricotProposalBlock{}), targetCodec.RegisterType(&ApricotAbortBlock{}), targetCodec.RegisterType(&ApricotCommitBlock{}), targetCodec.RegisterType(&ApricotStandardBlock{}), targetCodec.RegisterType(&ApricotAtomicBlock{}), + txs.RegisterApricotTypes(targetCodec), ) } -func RegisterBanffBlockTypes(targetCodec codec.Registry) error { +// RegisterBanffTypes registers the type information for blocks that were valid +// during the Banff series of upgrades. +func RegisterBanffTypes(targetCodec linearcodec.Codec) error { return errors.Join( + txs.RegisterBanffTypes(targetCodec), targetCodec.RegisterType(&BanffProposalBlock{}), targetCodec.RegisterType(&BanffAbortBlock{}), targetCodec.RegisterType(&BanffCommitBlock{}), targetCodec.RegisterType(&BanffStandardBlock{}), ) } + +// RegisterDurangoTypes registers the type information for blocks that were +// valid during the Durango series of upgrades. +func RegisterDurangoTypes(targetCodec linearcodec.Codec) error { + return txs.RegisterDurangoTypes(targetCodec) +} diff --git a/vms/platformvm/txs/codec.go b/vms/platformvm/txs/codec.go index 8fa09606897f..33c1b563392b 100644 --- a/vms/platformvm/txs/codec.go +++ b/vms/platformvm/txs/codec.go @@ -38,11 +38,14 @@ func init() { // we skip positions for the blocks. c.SkipRegistrations(5) - errs.Add(RegisterUnsignedTxsTypes(c)) + errs.Add( + RegisterApricotTypes(c), + RegisterBanffTypes(c), + ) c.SkipRegistrations(4) - errs.Add(RegisterDurangoUnsignedTxsTypes(c)) + errs.Add(RegisterDurangoTypes(c)) } Codec = codec.NewDefaultManager() @@ -56,14 +59,9 @@ func init() { } } -// RegisterUnsignedTxsTypes allows registering relevant type of unsigned package -// in the right sequence. Following repackaging of platformvm package, a few -// subpackage-level codecs were introduced, each handling serialization of -// specific types. -// -// RegisterUnsignedTxsTypes is made exportable so to guarantee that other codecs -// are coherent with components one. -func RegisterUnsignedTxsTypes(targetCodec linearcodec.Codec) error { +// RegisterApricotTypes registers the type information for transactions that +// were valid during the Apricot series of upgrades. +func RegisterApricotTypes(targetCodec linearcodec.Codec) error { errs := wrappers.Errs{} // The secp256k1fx is registered here because this is the same place it is @@ -90,8 +88,14 @@ func RegisterUnsignedTxsTypes(targetCodec linearcodec.Codec) error { targetCodec.RegisterType(&stakeable.LockIn{}), targetCodec.RegisterType(&stakeable.LockOut{}), + ) + return errs.Err +} - // Banff additions: +// RegisterBanffTypes registers the type information for transactions that were +// valid during the Banff series of upgrades. +func RegisterBanffTypes(targetCodec linearcodec.Codec) error { + return errors.Join( targetCodec.RegisterType(&RemoveSubnetValidatorTx{}), targetCodec.RegisterType(&TransformSubnetTx{}), targetCodec.RegisterType(&AddPermissionlessValidatorTx{}), @@ -100,10 +104,11 @@ func RegisterUnsignedTxsTypes(targetCodec linearcodec.Codec) error { targetCodec.RegisterType(&signer.Empty{}), targetCodec.RegisterType(&signer.ProofOfPossession{}), ) - return errs.Err } -func RegisterDurangoUnsignedTxsTypes(targetCodec linearcodec.Codec) error { +// RegisterDurangoTypes registers the type information for transactions that +// were valid during the Durango series of upgrades. +func RegisterDurangoTypes(targetCodec linearcodec.Codec) error { return errors.Join( targetCodec.RegisterType(&TransferSubnetOwnershipTx{}), targetCodec.RegisterType(&BaseTx{}),