From 5d8c590c8b4af08db7164ca61ceb2923607d71e0 Mon Sep 17 00:00:00 2001 From: Sam Liokumovich <65994425+samliok@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:21:46 -0400 Subject: [PATCH] Remove marshaling from transfer action (#1647) --- examples/morpheusvm/actions/transfer.go | 22 ---------------------- examples/morpheusvm/vm/vm.go | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/examples/morpheusvm/actions/transfer.go b/examples/morpheusvm/actions/transfer.go index 7ccd262a80..57cd253201 100644 --- a/examples/morpheusvm/actions/transfer.go +++ b/examples/morpheusvm/actions/transfer.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/hypersdk/chain" "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" "github.com/ava-labs/hypersdk/state" @@ -89,27 +88,6 @@ func (*Transfer) ValidRange(chain.Rules) (int64, int64) { return -1, -1 } -// Implementing chain.Marshaler is optional but can be used to optimize performance when hitting TPS limits -var _ chain.Marshaler = (*Transfer)(nil) - -func (t *Transfer) Size() int { - return codec.AddressLen + consts.Uint64Len + codec.BytesLen(t.Memo) -} - -func (t *Transfer) Marshal(p *codec.Packer) { - p.PackAddress(t.To) - p.PackLong(t.Value) - p.PackBytes(t.Memo) -} - -func UnmarshalTransfer(p *codec.Packer) (chain.Action, error) { - var transfer Transfer - p.UnpackAddress(&transfer.To) - transfer.Value = p.UnpackUint64(true) - p.UnpackBytes(MaxMemoSize, false, &transfer.Memo) - return &transfer, p.Err() -} - var _ codec.Typed = (*TransferResult)(nil) type TransferResult struct { diff --git a/examples/morpheusvm/vm/vm.go b/examples/morpheusvm/vm/vm.go index ee3d56e2b1..fc9497f35e 100644 --- a/examples/morpheusvm/vm/vm.go +++ b/examples/morpheusvm/vm/vm.go @@ -33,7 +33,7 @@ func init() { errs.Add( // When registering new actions, ALWAYS make sure to append at the end. // Pass nil as second argument if manual marshalling isn't needed (if in doubt, you probably don't) - ActionParser.Register(&actions.Transfer{}, actions.UnmarshalTransfer), + ActionParser.Register(&actions.Transfer{}, nil), // When registering new auth, ALWAYS make sure to append at the end. AuthParser.Register(&auth.ED25519{}, auth.UnmarshalED25519),