diff --git a/api/keystore/codec.go b/api/keystore/codec.go index b925747c44ec..3f6df0cf765f 100644 --- a/api/keystore/codec.go +++ b/api/keystore/codec.go @@ -4,8 +4,6 @@ package keystore import ( - "time" - "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" "github.com/ava-labs/avalanchego/utils/units" @@ -20,7 +18,7 @@ const ( var Codec codec.Manager func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() Codec = codec.NewManager(maxPackerSize) if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { panic(err) diff --git a/chains/atomic/codec.go b/chains/atomic/codec.go index 290713b3c258..f53fac8c3f80 100644 --- a/chains/atomic/codec.go +++ b/chains/atomic/codec.go @@ -5,7 +5,6 @@ package atomic import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -17,7 +16,7 @@ const CodecVersion = 0 var Codec codec.Manager func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() Codec = codec.NewManager(math.MaxInt) if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { panic(err) diff --git a/codec/hierarchycodec/codec.go b/codec/hierarchycodec/codec.go index db2ffed0425d..b317a5a4006c 100644 --- a/codec/hierarchycodec/codec.go +++ b/codec/hierarchycodec/codec.go @@ -7,7 +7,6 @@ import ( "fmt" "reflect" "sync" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/reflectcodec" @@ -15,11 +14,6 @@ import ( "github.com/ava-labs/avalanchego/utils/wrappers" ) -const ( - // default max length of a slice being marshalled by Marshal(). Should be <= math.MaxUint32. - defaultMaxSliceLength = 256 * 1024 -) - var ( _ Codec = (*hierarchyCodec)(nil) _ codec.Codec = (*hierarchyCodec)(nil) @@ -51,19 +45,19 @@ type hierarchyCodec struct { } // New returns a new, concurrency-safe codec -func New(durangoTime time.Time, tagNames []string, maxSliceLen uint32) Codec { +func New(tagNames []string) Codec { hCodec := &hierarchyCodec{ currentGroupID: 0, nextTypeID: 0, registeredTypes: bimap.New[typeID, reflect.Type](), } - hCodec.Codec = reflectcodec.New(hCodec, tagNames, durangoTime, maxSliceLen) + hCodec.Codec = reflectcodec.New(hCodec, tagNames) return hCodec } // NewDefault returns a new codec with reasonable default values -func NewDefault(durangoTime time.Time) Codec { - return New(durangoTime, []string{reflectcodec.DefaultTagName}, defaultMaxSliceLength) +func NewDefault() Codec { + return New([]string{reflectcodec.DefaultTagName}) } // SkipRegistrations some number of type IDs diff --git a/codec/hierarchycodec/codec_test.go b/codec/hierarchycodec/codec_test.go index 8149cdcc65e2..a5dd8b5fd546 100644 --- a/codec/hierarchycodec/codec_test.go +++ b/codec/hierarchycodec/codec_test.go @@ -5,41 +5,25 @@ package hierarchycodec import ( "testing" - "time" "github.com/ava-labs/avalanchego/codec" - "github.com/ava-labs/avalanchego/utils/timer/mockable" ) func TestVectors(t *testing.T) { for _, test := range codec.Tests { - c := NewDefault(mockable.MaxTime) + c := NewDefault() test(c, t) } } func TestMultipleTags(t *testing.T) { for _, test := range codec.MultipleTagsTests { - c := New(mockable.MaxTime, []string{"tag1", "tag2"}, defaultMaxSliceLength) - test(c, t) - } -} - -func TestEnforceSliceLen(t *testing.T) { - for _, test := range codec.EnforceSliceLenTests { - c := NewDefault(mockable.MaxTime) - test(c, t) - } -} - -func TestIgnoreSliceLen(t *testing.T) { - for _, test := range codec.IgnoreSliceLenTests { - c := NewDefault(time.Time{}) + c := New([]string{"tag1", "tag2"}) test(c, t) } } func FuzzStructUnmarshalHierarchyCodec(f *testing.F) { - c := NewDefault(mockable.MaxTime) + c := NewDefault() codec.FuzzStructUnmarshal(c, f) } diff --git a/codec/linearcodec/codec.go b/codec/linearcodec/codec.go index 6ad36b8a197d..f690d1354fca 100644 --- a/codec/linearcodec/codec.go +++ b/codec/linearcodec/codec.go @@ -7,7 +7,6 @@ import ( "fmt" "reflect" "sync" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/reflectcodec" @@ -15,11 +14,6 @@ import ( "github.com/ava-labs/avalanchego/utils/wrappers" ) -const ( - // default max length of a slice being marshalled by Marshal(). Should be <= math.MaxUint32. - DefaultMaxSliceLength = 256 * 1024 -) - var ( _ Codec = (*linearCodec)(nil) _ codec.Codec = (*linearCodec)(nil) @@ -43,25 +37,20 @@ type linearCodec struct { registeredTypes *bimap.BiMap[uint32, reflect.Type] } -// New returns a new, concurrency-safe codec; it allow to specify -// both tagNames and maxSlicelenght -func New(durangoTime time.Time, tagNames []string, maxSliceLen uint32) Codec { +// New returns a new, concurrency-safe codec; it allow to specify tagNames. +func New(tagNames []string) Codec { hCodec := &linearCodec{ nextTypeID: 0, registeredTypes: bimap.New[uint32, reflect.Type](), } - hCodec.Codec = reflectcodec.New(hCodec, tagNames, durangoTime, maxSliceLen) + hCodec.Codec = reflectcodec.New(hCodec, tagNames) return hCodec } -// NewDefault is a convenience constructor; it returns a new codec with reasonable default values -func NewDefault(durangoTime time.Time) Codec { - return New(durangoTime, []string{reflectcodec.DefaultTagName}, DefaultMaxSliceLength) -} - -// NewCustomMaxLength is a convenience constructor; it returns a new codec with custom max length and default tags -func NewCustomMaxLength(durangoTime time.Time, maxSliceLen uint32) Codec { - return New(durangoTime, []string{reflectcodec.DefaultTagName}, maxSliceLen) +// NewDefault is a convenience constructor; it returns a new codec with default +// tagNames. +func NewDefault() Codec { + return New([]string{reflectcodec.DefaultTagName}) } // Skip some number of type IDs diff --git a/codec/linearcodec/codec_test.go b/codec/linearcodec/codec_test.go index 3d2f3efff68a..20b886f9cb62 100644 --- a/codec/linearcodec/codec_test.go +++ b/codec/linearcodec/codec_test.go @@ -5,41 +5,25 @@ package linearcodec import ( "testing" - "time" "github.com/ava-labs/avalanchego/codec" - "github.com/ava-labs/avalanchego/utils/timer/mockable" ) func TestVectors(t *testing.T) { for _, test := range codec.Tests { - c := NewDefault(mockable.MaxTime) + c := NewDefault() test(c, t) } } func TestMultipleTags(t *testing.T) { for _, test := range codec.MultipleTagsTests { - c := New(mockable.MaxTime, []string{"tag1", "tag2"}, DefaultMaxSliceLength) - test(c, t) - } -} - -func TestEnforceSliceLen(t *testing.T) { - for _, test := range codec.EnforceSliceLenTests { - c := NewDefault(mockable.MaxTime) - test(c, t) - } -} - -func TestIgnoreSliceLen(t *testing.T) { - for _, test := range codec.IgnoreSliceLenTests { - c := NewDefault(time.Time{}) + c := New([]string{"tag1", "tag2"}) test(c, t) } } func FuzzStructUnmarshalLinearCodec(f *testing.F) { - c := NewDefault(mockable.MaxTime) + c := NewDefault() codec.FuzzStructUnmarshal(c, f) } diff --git a/codec/reflectcodec/type_codec.go b/codec/reflectcodec/type_codec.go index 7f567d0bb7fa..5d22bf0e6398 100644 --- a/codec/reflectcodec/type_codec.go +++ b/codec/reflectcodec/type_codec.go @@ -10,7 +10,6 @@ import ( "math" "reflect" "slices" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/utils/set" @@ -71,19 +70,15 @@ type TypeCodec interface { // 6. Serialized fields must be exported // 7. nil slices are marshaled as empty slices type genericCodec struct { - typer TypeCodec - durangoTime time.Time // Time after which [maxSliceLen] will be ignored - maxSliceLen uint32 - fielder StructFielder + typer TypeCodec + fielder StructFielder } // New returns a new, concurrency-safe codec -func New(typer TypeCodec, tagNames []string, durangoTime time.Time, maxSliceLen uint32) codec.Codec { +func New(typer TypeCodec, tagNames []string) codec.Codec { return &genericCodec{ - typer: typer, - durangoTime: durangoTime, - maxSliceLen: maxSliceLen, - fielder: NewStructFielder(tagNames), + typer: typer, + fielder: NewStructFielder(tagNames), } } @@ -370,13 +365,6 @@ func (c *genericCodec) marshal( math.MaxInt32, ) } - if time.Now().Before(c.durangoTime) && uint32(numElts) > c.maxSliceLen { - return fmt.Errorf("%w; slice length, %d, exceeds maximum length, %d", - codec.ErrMaxSliceLenExceeded, - numElts, - c.maxSliceLen, - ) - } p.PackInt(uint32(numElts)) // pack # elements if p.Err != nil { return p.Err @@ -433,13 +421,6 @@ func (c *genericCodec) marshal( math.MaxInt32, ) } - if time.Now().Before(c.durangoTime) && uint32(numElts) > c.maxSliceLen { - return fmt.Errorf("%w; map length, %d, exceeds maximum length, %d", - codec.ErrMaxSliceLenExceeded, - numElts, - c.maxSliceLen, - ) - } p.PackInt(uint32(numElts)) // pack # elements if p.Err != nil { return p.Err @@ -602,13 +583,6 @@ func (c *genericCodec) unmarshal( math.MaxInt32, ) } - if time.Now().Before(c.durangoTime) && numElts32 > c.maxSliceLen { - return fmt.Errorf("%w; array length, %d, exceeds maximum length, %d", - codec.ErrMaxSliceLenExceeded, - numElts32, - c.maxSliceLen, - ) - } numElts := int(numElts32) sliceType := value.Type() @@ -710,13 +684,6 @@ func (c *genericCodec) unmarshal( math.MaxInt32, ) } - if time.Now().Before(c.durangoTime) && numElts32 > c.maxSliceLen { - return fmt.Errorf("%w; map length, %d, exceeds maximum length, %d", - codec.ErrMaxSliceLenExceeded, - numElts32, - c.maxSliceLen, - ) - } var ( numElts = int(numElts32) diff --git a/codec/test_codec.go b/codec/test_codec.go index d58e2d818f9e..8a5233e03dcf 100644 --- a/codec/test_codec.go +++ b/codec/test_codec.go @@ -8,8 +8,6 @@ import ( "testing" "github.com/stretchr/testify/require" - - "github.com/ava-labs/avalanchego/utils/wrappers" ) var ( @@ -44,20 +42,12 @@ var ( TestExtraSpace, TestSliceLengthOverflow, TestMap, + TestCanMarshalLargeSlices, } MultipleTagsTests = []func(c GeneralCodec, t testing.TB){ TestMultipleTags, } - - EnforceSliceLenTests = []func(c GeneralCodec, t testing.TB){ - TestCanNotMarshalLargeSlices, - TestCanNotUnmarshalLargeSlices, - } - - IgnoreSliceLenTests = []func(c GeneralCodec, t testing.TB){ - TestCanMarshalLargeSlices, - } ) // The below structs and interfaces exist @@ -1031,35 +1021,6 @@ func TestMap(codec GeneralCodec, t testing.TB) { require.Len(outerArrayBytes, outerArraySize) } -func TestCanNotMarshalLargeSlices(codec GeneralCodec, t testing.TB) { - require := require.New(t) - - data := make([]uint16, 1_000_000) - - manager := NewManager(math.MaxInt) - require.NoError(manager.RegisterCodec(0, codec)) - - _, err := manager.Marshal(0, data) - require.ErrorIs(err, ErrMaxSliceLenExceeded) -} - -func TestCanNotUnmarshalLargeSlices(codec GeneralCodec, t testing.TB) { - require := require.New(t) - - writer := wrappers.Packer{ - Bytes: make([]byte, 2+4+2_000_000), - } - writer.PackShort(0) - writer.PackInt(1_000_000) - - manager := NewManager(math.MaxInt) - require.NoError(manager.RegisterCodec(0, codec)) - - var data []uint16 - _, err := manager.Unmarshal(writer.Bytes, &data) - require.ErrorIs(err, ErrMaxSliceLenExceeded) -} - func TestCanMarshalLargeSlices(codec GeneralCodec, t testing.TB) { require := require.New(t) diff --git a/database/encdb/codec.go b/database/encdb/codec.go index 62223b4fdd2f..b786bec66916 100644 --- a/database/encdb/codec.go +++ b/database/encdb/codec.go @@ -4,8 +4,6 @@ package encdb import ( - "time" - "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" ) @@ -15,7 +13,7 @@ const CodecVersion = 0 var Codec codec.Manager func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() Codec = codec.NewDefaultManager() if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { diff --git a/database/linkeddb/codec.go b/database/linkeddb/codec.go index f1982e1c7cfd..63516a8480c7 100644 --- a/database/linkeddb/codec.go +++ b/database/linkeddb/codec.go @@ -5,7 +5,6 @@ package linkeddb import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -16,7 +15,7 @@ const CodecVersion = 0 var Codec codec.Manager func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() Codec = codec.NewManager(math.MaxInt32) if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { diff --git a/genesis/genesis.go b/genesis/genesis.go index 6a61b80aa559..e25088a59a12 100644 --- a/genesis/genesis.go +++ b/genesis/genesis.go @@ -553,7 +553,6 @@ func VMGenesis(genesisBytes []byte, vmID ids.ID) (*pchaintxs.Tx, error) { func AVAXAssetID(avmGenesisBytes []byte) (ids.ID, error) { parser, err := xchaintxs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/indexer/codec.go b/indexer/codec.go index afde47502ac3..795a59461914 100644 --- a/indexer/codec.go +++ b/indexer/codec.go @@ -5,7 +5,6 @@ package indexer import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -16,7 +15,7 @@ const CodecVersion = 0 var Codec codec.Manager func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() Codec = codec.NewManager(math.MaxInt) if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { diff --git a/node/node.go b/node/node.go index 13ae6071cfb0..10c171830a60 100644 --- a/node/node.go +++ b/node/node.go @@ -74,9 +74,7 @@ import ( "github.com/ava-labs/avalanchego/vms" "github.com/ava-labs/avalanchego/vms/avm" "github.com/ava-labs/avalanchego/vms/platformvm" - "github.com/ava-labs/avalanchego/vms/platformvm/block" "github.com/ava-labs/avalanchego/vms/platformvm/signer" - "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/registry" "github.com/ava-labs/avalanchego/vms/rpcchainvm/runtime" @@ -1118,17 +1116,6 @@ func (n *Node) initVMs() error { vdrs = validators.NewManager() } - durangoTime := version.GetDurangoTime(n.Config.NetworkID) - if err := txs.InitCodec(durangoTime); err != nil { - return err - } - if err := block.InitCodec(durangoTime); err != nil { - return err - } - if err := coreth.InitCodec(durangoTime); err != nil { - return err - } - // Register the VMs that Avalanche supports err := utils.Err( n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{ @@ -1160,7 +1147,7 @@ func (n *Node) initVMs() error { ApricotPhase5Time: version.GetApricotPhase5Time(n.Config.NetworkID), BanffTime: version.GetBanffTime(n.Config.NetworkID), CortinaTime: version.GetCortinaTime(n.Config.NetworkID), - DurangoTime: durangoTime, + DurangoTime: version.GetDurangoTime(n.Config.NetworkID), UseCurrentHeight: n.Config.UseCurrentHeight, }, }), @@ -1168,7 +1155,6 @@ func (n *Node) initVMs() error { Config: avmconfig.Config{ TxFee: n.Config.TxFee, CreateAssetTxFee: n.Config.CreateAssetTxFee, - DurangoTime: durangoTime, }, }), n.VMManager.RegisterFactory(context.TODO(), constants.EVMID, &coreth.Factory{}), diff --git a/snow/engine/avalanche/vertex/codec.go b/snow/engine/avalanche/vertex/codec.go index 12f387d0d25d..3a55f443467e 100644 --- a/snow/engine/avalanche/vertex/codec.go +++ b/snow/engine/avalanche/vertex/codec.go @@ -4,8 +4,6 @@ package vertex import ( - "time" - "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" "github.com/ava-labs/avalanchego/codec/reflectcodec" @@ -24,8 +22,8 @@ const ( var Codec codec.Manager func init() { - lc0 := linearcodec.New(time.Time{}, []string{reflectcodec.DefaultTagName + "V0"}, maxSize) - lc1 := linearcodec.New(time.Time{}, []string{reflectcodec.DefaultTagName + "V1"}, maxSize) + lc0 := linearcodec.New([]string{reflectcodec.DefaultTagName + "V0"}) + lc1 := linearcodec.New([]string{reflectcodec.DefaultTagName + "V1"}) Codec = codec.NewManager(maxSize) err := utils.Err( diff --git a/vms/avm/block/block_test.go b/vms/avm/block/block_test.go index 6100f1d6d987..37f0e5f5e54b 100644 --- a/vms/avm/block/block_test.go +++ b/vms/avm/block/block_test.go @@ -29,7 +29,6 @@ func TestInvalidBlock(t *testing.T) { require := require.New(t) parser, err := NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, @@ -45,7 +44,6 @@ func TestStandardBlocks(t *testing.T) { require := require.New(t) parser, err := NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/block/builder/builder_test.go b/vms/avm/block/builder/builder_test.go index d28507671cf6..89f043844b54 100644 --- a/vms/avm/block/builder/builder_test.go +++ b/vms/avm/block/builder/builder_test.go @@ -513,7 +513,6 @@ func TestBlockBuilderAddLocalTx(t *testing.T) { require.True(ok) parser, err := block.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/block/parser.go b/vms/avm/block/parser.go index f0c359a513b0..bfae841093d1 100644 --- a/vms/avm/block/parser.go +++ b/vms/avm/block/parser.go @@ -5,7 +5,6 @@ package block import ( "reflect" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/utils" @@ -31,8 +30,8 @@ type parser struct { txs.Parser } -func NewParser(durangoTime time.Time, fxs []fxs.Fx) (Parser, error) { - p, err := txs.NewParser(durangoTime, fxs) +func NewParser(fxs []fxs.Fx) (Parser, error) { + p, err := txs.NewParser(fxs) if err != nil { return nil, err } @@ -49,13 +48,12 @@ func NewParser(durangoTime time.Time, fxs []fxs.Fx) (Parser, error) { } func NewCustomParser( - durangoTime time.Time, typeToFxIndex map[reflect.Type]int, clock *mockable.Clock, log logging.Logger, fxs []fxs.Fx, ) (Parser, error) { - p, err := txs.NewCustomParser(durangoTime, typeToFxIndex, clock, log, fxs) + p, err := txs.NewCustomParser(typeToFxIndex, clock, log, fxs) if err != nil { return nil, err } diff --git a/vms/avm/config/config.go b/vms/avm/config/config.go index df6e4f7de2ae..08f6ab04240a 100644 --- a/vms/avm/config/config.go +++ b/vms/avm/config/config.go @@ -3,8 +3,6 @@ package config -import "time" - // Struct collecting all the foundational parameters of the AVM type Config struct { // Fee that is burned by every non-asset creating transaction @@ -12,7 +10,4 @@ type Config struct { // Fee that must be burned by every asset creating transaction CreateAssetTxFee uint64 - - // Time of the Durango network upgrade - DurangoTime time.Time } diff --git a/vms/avm/environment_test.go b/vms/avm/environment_test.go index 92675ef96dea..9c4e5eb6a6f0 100644 --- a/vms/avm/environment_test.go +++ b/vms/avm/environment_test.go @@ -8,7 +8,6 @@ import ( "encoding/json" "math/rand" "testing" - "time" "github.com/stretchr/testify/require" @@ -229,7 +228,6 @@ func getCreateTxFromGenesisTest(tb testing.TB, genesisBytes []byte, assetName st require := require.New(tb) parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/network/gossip_test.go b/vms/avm/network/gossip_test.go index afd08920f1c1..e84f259cbe37 100644 --- a/vms/avm/network/gossip_test.go +++ b/vms/avm/network/gossip_test.go @@ -5,7 +5,6 @@ package network import ( "testing" - "time" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" @@ -34,7 +33,6 @@ func TestMarshaller(t *testing.T) { require := require.New(t) parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, @@ -65,7 +63,7 @@ func TestGossipMempoolAdd(t *testing.T) { baseMempool, err := mempool.New("", metrics, toEngine) require.NoError(err) - parser, err := txs.NewParser(time.Time{}, nil) + parser, err := txs.NewParser(nil) require.NoError(err) mempool, err := newGossipMempool( @@ -102,7 +100,7 @@ func TestGossipMempoolAddVerified(t *testing.T) { baseMempool, err := mempool.New("", metrics, toEngine) require.NoError(err) - parser, err := txs.NewParser(time.Time{}, nil) + parser, err := txs.NewParser(nil) require.NoError(err) mempool, err := newGossipMempool( diff --git a/vms/avm/network/network_test.go b/vms/avm/network/network_test.go index 4fdd09b9230f..c33ee8af621c 100644 --- a/vms/avm/network/network_test.go +++ b/vms/avm/network/network_test.go @@ -64,7 +64,6 @@ func TestNetworkAppGossip(t *testing.T) { } parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, @@ -186,7 +185,6 @@ func TestNetworkAppGossip(t *testing.T) { ctrl := gomock.NewController(t) parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, &nftfx.Fx{}, @@ -320,7 +318,6 @@ func TestNetworkIssueTxFromRPC(t *testing.T) { ctrl := gomock.NewController(t) parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, &nftfx.Fx{}, @@ -414,7 +411,6 @@ func TestNetworkIssueTxFromRPCWithoutVerification(t *testing.T) { ctrl := gomock.NewController(t) parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, &nftfx.Fx{}, diff --git a/vms/avm/state/state_test.go b/vms/avm/state/state_test.go index 3657da0e3b2f..a6170c62c405 100644 --- a/vms/avm/state/state_test.go +++ b/vms/avm/state/state_test.go @@ -38,7 +38,6 @@ var ( func init() { var err error parser, err = block.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/static_service.go b/vms/avm/static_service.go index 31a7a5885a62..35a3554ef1d6 100644 --- a/vms/avm/static_service.go +++ b/vms/avm/static_service.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "net/http" - "time" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils" @@ -79,7 +78,6 @@ type BuildGenesisReply struct { // referenced in the UTXO. func (*StaticService) BuildGenesis(_ *http.Request, args *BuildGenesisArgs, reply *BuildGenesisReply) error { parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, &nftfx.Fx{}, diff --git a/vms/avm/txs/base_tx_test.go b/vms/avm/txs/base_tx_test.go index 5fb40642433a..5454554ba3d8 100644 --- a/vms/avm/txs/base_tx_test.go +++ b/vms/avm/txs/base_tx_test.go @@ -5,7 +5,6 @@ package txs import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -127,7 +126,6 @@ func TestBaseTxSerialization(t *testing.T) { }}} parser, err := NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/txs/create_asset_tx_test.go b/vms/avm/txs/create_asset_tx_test.go index 9ef548eedea2..83e6c99914fe 100644 --- a/vms/avm/txs/create_asset_tx_test.go +++ b/vms/avm/txs/create_asset_tx_test.go @@ -5,7 +5,6 @@ package txs import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -195,7 +194,6 @@ func TestCreateAssetTxSerialization(t *testing.T) { }} parser, err := NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, @@ -367,7 +365,6 @@ func TestCreateAssetTxSerializationAgain(t *testing.T) { } parser, err := NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/txs/executor/executor_test.go b/vms/avm/txs/executor/executor_test.go index d110e4a24a59..6be98183c1ca 100644 --- a/vms/avm/txs/executor/executor_test.go +++ b/vms/avm/txs/executor/executor_test.go @@ -5,7 +5,6 @@ package executor import ( "testing" - "time" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" @@ -38,7 +37,6 @@ func TestBaseTxExecutor(t *testing.T) { secpFx := &secp256k1fx.Fx{} parser, err := block.NewParser( - time.Time{}, []fxs.Fx{secpFx}, ) require.NoError(err) @@ -146,7 +144,6 @@ func TestCreateAssetTxExecutor(t *testing.T) { secpFx := &secp256k1fx.Fx{} parser, err := block.NewParser( - time.Time{}, []fxs.Fx{secpFx}, ) require.NoError(err) @@ -292,7 +289,6 @@ func TestOperationTxExecutor(t *testing.T) { secpFx := &secp256k1fx.Fx{} parser, err := block.NewParser( - time.Time{}, []fxs.Fx{secpFx}, ) require.NoError(err) diff --git a/vms/avm/txs/executor/semantic_verifier_test.go b/vms/avm/txs/executor/semantic_verifier_test.go index 5187dd9a38ad..db89e1e5a5e9 100644 --- a/vms/avm/txs/executor/semantic_verifier_test.go +++ b/vms/avm/txs/executor/semantic_verifier_test.go @@ -6,7 +6,6 @@ package executor import ( "reflect" "testing" - "time" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -36,7 +35,6 @@ func TestSemanticVerifierBaseTx(t *testing.T) { typeToFxIndex := make(map[reflect.Type]int) secpFx := &secp256k1fx.Fx{} parser, err := txs.NewCustomParser( - time.Time{}, typeToFxIndex, new(mockable.Clock), logging.NoWarn{}, @@ -394,7 +392,6 @@ func TestSemanticVerifierExportTx(t *testing.T) { typeToFxIndex := make(map[reflect.Type]int) secpFx := &secp256k1fx.Fx{} parser, err := txs.NewCustomParser( - time.Time{}, typeToFxIndex, new(mockable.Clock), logging.NoWarn{}, @@ -763,7 +760,6 @@ func TestSemanticVerifierExportTxDifferentSubnet(t *testing.T) { typeToFxIndex := make(map[reflect.Type]int) secpFx := &secp256k1fx.Fx{} parser, err := txs.NewCustomParser( - time.Time{}, typeToFxIndex, new(mockable.Clock), logging.NoWarn{}, @@ -880,7 +876,6 @@ func TestSemanticVerifierImportTx(t *testing.T) { typeToFxIndex := make(map[reflect.Type]int) fx := &secp256k1fx.Fx{} parser, err := txs.NewCustomParser( - time.Time{}, typeToFxIndex, new(mockable.Clock), logging.NoWarn{}, diff --git a/vms/avm/txs/executor/syntactic_verifier_test.go b/vms/avm/txs/executor/syntactic_verifier_test.go index 108ac9e94a60..8726e45477db 100644 --- a/vms/avm/txs/executor/syntactic_verifier_test.go +++ b/vms/avm/txs/executor/syntactic_verifier_test.go @@ -7,7 +7,6 @@ import ( "math" "strings" "testing" - "time" "github.com/stretchr/testify/require" @@ -38,7 +37,6 @@ func TestSyntacticVerifierBaseTx(t *testing.T) { fx := &secp256k1fx.Fx{} parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ fx, }, @@ -411,7 +409,6 @@ func TestSyntacticVerifierCreateAssetTx(t *testing.T) { fx := &secp256k1fx.Fx{} parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ fx, }, @@ -1021,7 +1018,6 @@ func TestSyntacticVerifierOperationTx(t *testing.T) { fx := &secp256k1fx.Fx{} parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ fx, }, @@ -1511,7 +1507,6 @@ func TestSyntacticVerifierImportTx(t *testing.T) { fx := &secp256k1fx.Fx{} parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ fx, }, @@ -1912,7 +1907,6 @@ func TestSyntacticVerifierExportTx(t *testing.T) { fx := &secp256k1fx.Fx{} parser, err := txs.NewParser( - time.Time{}, []fxs.Fx{ fx, }, diff --git a/vms/avm/txs/export_tx_test.go b/vms/avm/txs/export_tx_test.go index 0b714a911fa0..d7c71f6bd632 100644 --- a/vms/avm/txs/export_tx_test.go +++ b/vms/avm/txs/export_tx_test.go @@ -5,7 +5,6 @@ package txs import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -110,7 +109,6 @@ func TestExportTxSerialization(t *testing.T) { }} parser, err := NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/txs/import_tx_test.go b/vms/avm/txs/import_tx_test.go index 1f2bbe0ea341..b0cdd8198a5b 100644 --- a/vms/avm/txs/import_tx_test.go +++ b/vms/avm/txs/import_tx_test.go @@ -5,7 +5,6 @@ package txs import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -110,7 +109,6 @@ func TestImportTxSerialization(t *testing.T) { }} parser, err := NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, }, diff --git a/vms/avm/txs/initial_state_test.go b/vms/avm/txs/initial_state_test.go index 5f61deb3e7c6..48c15ae196c4 100644 --- a/vms/avm/txs/initial_state_test.go +++ b/vms/avm/txs/initial_state_test.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "testing" - "time" "github.com/stretchr/testify/require" @@ -24,7 +23,7 @@ var errTest = errors.New("non-nil error") func TestInitialStateVerifySerialization(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&secp256k1fx.TransferOutput{})) m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(CodecVersion, c)) @@ -81,7 +80,7 @@ func TestInitialStateVerifySerialization(t *testing.T) { func TestInitialStateVerifyNil(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(CodecVersion, c)) numFxs := 1 @@ -94,7 +93,7 @@ func TestInitialStateVerifyNil(t *testing.T) { func TestInitialStateVerifyUnknownFxID(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(CodecVersion, c)) numFxs := 1 @@ -109,7 +108,7 @@ func TestInitialStateVerifyUnknownFxID(t *testing.T) { func TestInitialStateVerifyNilOutput(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(CodecVersion, c)) numFxs := 1 @@ -125,7 +124,7 @@ func TestInitialStateVerifyNilOutput(t *testing.T) { func TestInitialStateVerifyInvalidOutput(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&avax.TestState{})) m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(CodecVersion, c)) @@ -142,7 +141,7 @@ func TestInitialStateVerifyInvalidOutput(t *testing.T) { func TestInitialStateVerifyUnsortedOutputs(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&avax.TestTransferable{})) m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(CodecVersion, c)) diff --git a/vms/avm/txs/operation_test.go b/vms/avm/txs/operation_test.go index 3ca4676eb370..ac9cf62530c6 100644 --- a/vms/avm/txs/operation_test.go +++ b/vms/avm/txs/operation_test.go @@ -5,7 +5,6 @@ package txs import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -80,7 +79,7 @@ func TestOperationVerify(t *testing.T) { func TestOperationSorting(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&testOperable{})) m := codec.NewDefaultManager() diff --git a/vms/avm/txs/parser.go b/vms/avm/txs/parser.go index 979c71d8a7c8..c5b7fe19edc0 100644 --- a/vms/avm/txs/parser.go +++ b/vms/avm/txs/parser.go @@ -7,7 +7,6 @@ import ( "fmt" "math" "reflect" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -40,9 +39,8 @@ type parser struct { gc linearcodec.Codec } -func NewParser(durangoTime time.Time, fxs []fxs.Fx) (Parser, error) { +func NewParser(fxs []fxs.Fx) (Parser, error) { return NewCustomParser( - durangoTime, make(map[reflect.Type]int), &mockable.Clock{}, logging.NoLog{}, @@ -51,14 +49,13 @@ func NewParser(durangoTime time.Time, fxs []fxs.Fx) (Parser, error) { } func NewCustomParser( - durangoTime time.Time, typeToFxIndex map[reflect.Type]int, clock *mockable.Clock, log logging.Logger, fxs []fxs.Fx, ) (Parser, error) { - gc := linearcodec.NewDefault(time.Time{}) - c := linearcodec.NewDefault(durangoTime) + gc := linearcodec.NewDefault() + c := linearcodec.NewDefault() gcm := codec.NewManager(math.MaxInt32) cm := codec.NewDefaultManager() diff --git a/vms/avm/vm.go b/vms/avm/vm.go index f401398f0a24..b33c3980f1fb 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -217,7 +217,6 @@ func (vm *VM) Initialize( vm.typeToFxIndex = map[reflect.Type]int{} vm.parser, err = block.NewCustomParser( - vm.DurangoTime, vm.typeToFxIndex, &vm.clock, ctx.Log, diff --git a/vms/components/avax/asset_test.go b/vms/components/avax/asset_test.go index ad7628ce98b9..ccb6f5549630 100644 --- a/vms/components/avax/asset_test.go +++ b/vms/components/avax/asset_test.go @@ -5,7 +5,6 @@ package avax import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -29,7 +28,7 @@ func TestAssetVerifyEmpty(t *testing.T) { func TestAssetID(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() manager := codec.NewDefaultManager() require.NoError(manager.RegisterCodec(codecVersion, c)) diff --git a/vms/components/avax/transferables_test.go b/vms/components/avax/transferables_test.go index 755a0124eb7b..f46d580e839a 100644 --- a/vms/components/avax/transferables_test.go +++ b/vms/components/avax/transferables_test.go @@ -5,7 +5,6 @@ package avax import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -43,7 +42,7 @@ func TestTransferableOutputVerify(t *testing.T) { func TestTransferableOutputSorting(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&TestTransferable{})) manager := codec.NewDefaultManager() require.NoError(manager.RegisterCodec(codecVersion, c)) @@ -85,7 +84,7 @@ func TestTransferableOutputSorting(t *testing.T) { func TestTransferableOutputSerialization(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&secp256k1fx.TransferOutput{})) manager := codec.NewDefaultManager() require.NoError(manager.RegisterCodec(codecVersion, c)) @@ -176,7 +175,7 @@ func TestTransferableInputVerify(t *testing.T) { func TestTransferableInputSorting(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&TestTransferable{})) ins := []*TransferableInput{ @@ -233,7 +232,7 @@ func TestTransferableInputSorting(t *testing.T) { func TestTransferableInputSerialization(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() require.NoError(c.RegisterType(&secp256k1fx.TransferInput{})) manager := codec.NewDefaultManager() require.NoError(manager.RegisterCodec(codecVersion, c)) diff --git a/vms/components/avax/utxo_fetching_test.go b/vms/components/avax/utxo_fetching_test.go index e36545c19cb7..25fe3fd91155 100644 --- a/vms/components/avax/utxo_fetching_test.go +++ b/vms/components/avax/utxo_fetching_test.go @@ -5,7 +5,6 @@ package avax import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -40,7 +39,7 @@ func TestFetchUTXOs(t *testing.T) { }, } - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() manager := codec.NewDefaultManager() require.NoError(c.RegisterType(&secp256k1fx.TransferOutput{})) @@ -73,7 +72,7 @@ func TestGetPaginatedUTXOs(t *testing.T) { addr2 := ids.GenerateTestShortID() addrs := set.Of(addr0, addr1) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() manager := codec.NewDefaultManager() require.NoError(c.RegisterType(&secp256k1fx.TransferOutput{})) diff --git a/vms/components/avax/utxo_id_test.go b/vms/components/avax/utxo_id_test.go index fed21d5ce986..09887c0312e9 100644 --- a/vms/components/avax/utxo_id_test.go +++ b/vms/components/avax/utxo_id_test.go @@ -6,7 +6,6 @@ package avax import ( "math" "testing" - "time" "github.com/stretchr/testify/require" @@ -24,7 +23,7 @@ func TestUTXOIDVerifyNil(t *testing.T) { func TestUTXOID(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() manager := codec.NewDefaultManager() require.NoError(manager.RegisterCodec(codecVersion, c)) diff --git a/vms/components/avax/utxo_state_test.go b/vms/components/avax/utxo_state_test.go index fa4c530e011a..09213bfa1bc6 100644 --- a/vms/components/avax/utxo_state_test.go +++ b/vms/components/avax/utxo_state_test.go @@ -5,7 +5,6 @@ package avax import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -42,7 +41,7 @@ func TestUTXOState(t *testing.T) { } utxoID := utxo.InputID() - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() manager := codec.NewDefaultManager() require.NoError(c.RegisterType(&secp256k1fx.MintOutput{})) diff --git a/vms/components/avax/utxo_test.go b/vms/components/avax/utxo_test.go index a79c8fcb6cd6..54f8360173a7 100644 --- a/vms/components/avax/utxo_test.go +++ b/vms/components/avax/utxo_test.go @@ -5,7 +5,6 @@ package avax import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -33,7 +32,7 @@ func TestUTXOVerifyEmpty(t *testing.T) { func TestUTXOSerialize(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() manager := codec.NewDefaultManager() require.NoError(c.RegisterType(&secp256k1fx.MintOutput{})) diff --git a/vms/components/keystore/codec.go b/vms/components/keystore/codec.go index 15576b73e4ea..4e5a01db6dd0 100644 --- a/vms/components/keystore/codec.go +++ b/vms/components/keystore/codec.go @@ -5,7 +5,6 @@ package keystore import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -20,9 +19,9 @@ var ( ) func init() { - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() Codec = codec.NewDefaultManager() - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() LegacyCodec = codec.NewManager(math.MaxInt32) err := utils.Err( diff --git a/vms/components/message/codec.go b/vms/components/message/codec.go index 5614125b1cee..3a0c4a416688 100644 --- a/vms/components/message/codec.go +++ b/vms/components/message/codec.go @@ -4,8 +4,6 @@ package message import ( - "time" - "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" "github.com/ava-labs/avalanchego/utils" @@ -22,7 +20,7 @@ var Codec codec.Manager func init() { Codec = codec.NewManager(maxMessageSize) - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() err := utils.Err( lc.RegisterType(&Tx{}), diff --git a/vms/example/xsvm/tx/codec.go b/vms/example/xsvm/tx/codec.go index f61c7bf18098..4ba775abb3f4 100644 --- a/vms/example/xsvm/tx/codec.go +++ b/vms/example/xsvm/tx/codec.go @@ -5,7 +5,6 @@ package tx import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -17,7 +16,7 @@ const CodecVersion = 0 var Codec codec.Manager func init() { - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() Codec = codec.NewManager(math.MaxInt32) err := utils.Err( diff --git a/vms/nftfx/fx_test.go b/vms/nftfx/fx_test.go index 1ed3426f5b11..99a047b11328 100644 --- a/vms/nftfx/fx_test.go +++ b/vms/nftfx/fx_test.go @@ -39,7 +39,7 @@ var ( func TestFxInitialize(t *testing.T) { vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } fx := Fx{} @@ -56,7 +56,7 @@ func TestFxVerifyMintOperation(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -92,7 +92,7 @@ func TestFxVerifyMintOperationWrongTx(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -126,7 +126,7 @@ func TestFxVerifyMintOperationWrongNumberUTXOs(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -157,7 +157,7 @@ func TestFxVerifyMintOperationWrongCredential(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -189,7 +189,7 @@ func TestFxVerifyMintOperationInvalidUTXO(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -220,7 +220,7 @@ func TestFxVerifyMintOperationFailingVerification(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -258,7 +258,7 @@ func TestFxVerifyMintOperationInvalidGroupID(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -296,7 +296,7 @@ func TestFxVerifyTransferOperation(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -346,7 +346,7 @@ func TestFxVerifyTransferOperationWrongUTXO(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -387,7 +387,7 @@ func TestFxVerifyTransferOperationFailedVerify(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -435,7 +435,7 @@ func TestFxVerifyTransferOperationWrongGroupID(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -486,7 +486,7 @@ func TestFxVerifyTransferOperationWrongBytes(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -537,7 +537,7 @@ func TestFxVerifyTransferOperationTooSoon(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -589,7 +589,7 @@ func TestFxVerifyOperationUnknownOperation(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -625,7 +625,7 @@ func TestFxVerifyTransfer(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) diff --git a/vms/platformvm/block/builder/helpers_test.go b/vms/platformvm/block/builder/helpers_test.go index 05164aff2968..708f67fb36c3 100644 --- a/vms/platformvm/block/builder/helpers_test.go +++ b/vms/platformvm/block/builder/helpers_test.go @@ -387,7 +387,7 @@ func defaultFx(t *testing.T, clk *mockable.Clock, log logging.Logger, isBootstra require := require.New(t) fxVMInt := &fxVMInt{ - registry: linearcodec.NewDefault(time.Time{}), + registry: linearcodec.NewDefault(), clk: clk, log: log, } diff --git a/vms/platformvm/block/codec.go b/vms/platformvm/block/codec.go index 33babbaf3a79..f0f66a414811 100644 --- a/vms/platformvm/block/codec.go +++ b/vms/platformvm/block/codec.go @@ -5,7 +5,6 @@ package block import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -26,13 +25,9 @@ var ( Codec codec.Manager ) -// TODO: Remove after v1.11.x has activated -// -// Invariant: InitCodec, Codec, and GenesisCodec must not be accessed -// concurrently -func InitCodec(durangoTime time.Time) error { - c := linearcodec.NewDefault(durangoTime) - gc := linearcodec.NewDefault(time.Time{}) +func init() { + c := linearcodec.NewDefault() + gc := linearcodec.NewDefault() errs := wrappers.Errs{} for _, c := range []linearcodec.Codec{c, gc} { @@ -44,24 +39,14 @@ func InitCodec(durangoTime time.Time) error { ) } - newCodec := codec.NewDefaultManager() - newGenesisCodec := codec.NewManager(math.MaxInt32) + Codec = codec.NewDefaultManager() + GenesisCodec = codec.NewManager(math.MaxInt32) errs.Add( - newCodec.RegisterCodec(CodecVersion, c), - newGenesisCodec.RegisterCodec(CodecVersion, gc), + Codec.RegisterCodec(CodecVersion, c), + GenesisCodec.RegisterCodec(CodecVersion, gc), ) if errs.Errored() { - return errs.Err - } - - Codec = newCodec - GenesisCodec = newGenesisCodec - return nil -} - -func init() { - if err := InitCodec(time.Time{}); err != nil { - panic(err) + panic(errs.Err) } } diff --git a/vms/platformvm/block/executor/helpers_test.go b/vms/platformvm/block/executor/helpers_test.go index 825625b7c77e..4f016808f3d4 100644 --- a/vms/platformvm/block/executor/helpers_test.go +++ b/vms/platformvm/block/executor/helpers_test.go @@ -408,7 +408,7 @@ func (fvi *fxVMInt) Logger() logging.Logger { func defaultFx(clk *mockable.Clock, log logging.Logger, isBootstrapped bool) fx.Fx { fxVMInt := &fxVMInt{ - registry: linearcodec.NewDefault(time.Time{}), + registry: linearcodec.NewDefault(), clk: clk, log: log, } diff --git a/vms/platformvm/state/metadata_codec.go b/vms/platformvm/state/metadata_codec.go index 65832ed77460..f2f5478a89d3 100644 --- a/vms/platformvm/state/metadata_codec.go +++ b/vms/platformvm/state/metadata_codec.go @@ -5,7 +5,6 @@ package state import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -23,8 +22,8 @@ const ( var MetadataCodec codec.Manager func init() { - c0 := linearcodec.New(time.Time{}, []string{CodecVersion0Tag}, math.MaxInt32) - c1 := linearcodec.New(time.Time{}, []string{CodecVersion0Tag, CodecVersion1Tag}, math.MaxInt32) + c0 := linearcodec.New([]string{CodecVersion0Tag}) + c1 := linearcodec.New([]string{CodecVersion0Tag, CodecVersion1Tag}) MetadataCodec = codec.NewManager(math.MaxInt32) err := utils.Err( diff --git a/vms/platformvm/txs/codec.go b/vms/platformvm/txs/codec.go index 36fe2e5a8eb0..a93477af7074 100644 --- a/vms/platformvm/txs/codec.go +++ b/vms/platformvm/txs/codec.go @@ -5,7 +5,6 @@ package txs import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -28,13 +27,9 @@ var ( GenesisCodec codec.Manager ) -// TODO: Remove after v1.11.x has activated -// -// Invariant: InitCodec, Codec, and GenesisCodec must not be accessed -// concurrently -func InitCodec(durangoTime time.Time) error { - c := linearcodec.NewDefault(durangoTime) - gc := linearcodec.NewDefault(time.Time{}) +func init() { + c := linearcodec.NewDefault() + gc := linearcodec.NewDefault() errs := wrappers.Errs{} for _, c := range []linearcodec.Codec{c, gc} { @@ -50,24 +45,14 @@ func InitCodec(durangoTime time.Time) error { errs.Add(RegisterDUnsignedTxsTypes(c)) } - newCodec := codec.NewDefaultManager() - newGenesisCodec := codec.NewManager(math.MaxInt32) + Codec = codec.NewDefaultManager() + GenesisCodec = codec.NewManager(math.MaxInt32) errs.Add( - newCodec.RegisterCodec(CodecVersion, c), - newGenesisCodec.RegisterCodec(CodecVersion, gc), + Codec.RegisterCodec(CodecVersion, c), + GenesisCodec.RegisterCodec(CodecVersion, gc), ) if errs.Errored() { - return errs.Err - } - - Codec = newCodec - GenesisCodec = newGenesisCodec - return nil -} - -func init() { - if err := InitCodec(time.Time{}); err != nil { - panic(err) + panic(errs.Err) } } diff --git a/vms/platformvm/txs/executor/helpers_test.go b/vms/platformvm/txs/executor/helpers_test.go index f319b19826a2..643060ddbdb3 100644 --- a/vms/platformvm/txs/executor/helpers_test.go +++ b/vms/platformvm/txs/executor/helpers_test.go @@ -364,7 +364,7 @@ func (fvi *fxVMInt) Logger() logging.Logger { func defaultFx(clk *mockable.Clock, log logging.Logger, isBootstrapped bool) fx.Fx { fxVMInt := &fxVMInt{ - registry: linearcodec.NewDefault(time.Time{}), + registry: linearcodec.NewDefault(), clk: clk, log: log, } diff --git a/vms/platformvm/vm.go b/vms/platformvm/vm.go index 30e1b8c3d63d..3a2297f29b39 100644 --- a/vms/platformvm/vm.go +++ b/vms/platformvm/vm.go @@ -133,7 +133,7 @@ func (vm *VM) Initialize( vm.db = db // Note: this codec is never used to serialize anything - vm.codecRegistry = linearcodec.NewDefault(time.Time{}) + vm.codecRegistry = linearcodec.NewDefault() vm.fx = &secp256k1fx.Fx{} if err := vm.fx.Initialize(vm); err != nil { return err diff --git a/vms/platformvm/warp/codec.go b/vms/platformvm/warp/codec.go index 6ef6e526bdc1..8d2193827346 100644 --- a/vms/platformvm/warp/codec.go +++ b/vms/platformvm/warp/codec.go @@ -5,7 +5,6 @@ package warp import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -18,7 +17,7 @@ var Codec codec.Manager func init() { Codec = codec.NewManager(math.MaxInt) - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() err := utils.Err( lc.RegisterType(&BitSetSignature{}), diff --git a/vms/platformvm/warp/payload/codec.go b/vms/platformvm/warp/payload/codec.go index d188029abfed..b89db089d454 100644 --- a/vms/platformvm/warp/payload/codec.go +++ b/vms/platformvm/warp/payload/codec.go @@ -4,8 +4,6 @@ package payload import ( - "time" - "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" "github.com/ava-labs/avalanchego/utils" @@ -22,7 +20,7 @@ var Codec codec.Manager func init() { Codec = codec.NewManager(MaxMessageSize) - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() err := utils.Err( lc.RegisterType(&Hash{}), diff --git a/vms/propertyfx/fx_test.go b/vms/propertyfx/fx_test.go index 0cd995ba5282..10a96e6e5b0b 100644 --- a/vms/propertyfx/fx_test.go +++ b/vms/propertyfx/fx_test.go @@ -39,7 +39,7 @@ var ( func TestFxInitialize(t *testing.T) { vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } fx := Fx{} @@ -56,7 +56,7 @@ func TestFxVerifyMintOperation(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -98,7 +98,7 @@ func TestFxVerifyMintOperationWrongTx(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -132,7 +132,7 @@ func TestFxVerifyMintOperationWrongNumberUTXOs(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -163,7 +163,7 @@ func TestFxVerifyMintOperationWrongCredential(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -195,7 +195,7 @@ func TestFxVerifyMintOperationInvalidUTXO(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -226,7 +226,7 @@ func TestFxVerifyMintOperationFailingVerification(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -264,7 +264,7 @@ func TestFxVerifyMintOperationInvalidGroupID(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -301,7 +301,7 @@ func TestFxVerifyTransferOperation(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -335,7 +335,7 @@ func TestFxVerifyTransferOperationWrongUTXO(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -364,7 +364,7 @@ func TestFxVerifyTransferOperationFailedVerify(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -399,7 +399,7 @@ func TestFxVerifyOperationUnknownOperation(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -431,7 +431,7 @@ func TestFxVerifyTransfer(t *testing.T) { require := require.New(t) vm := secp256k1fx.TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) diff --git a/vms/proposervm/block/codec.go b/vms/proposervm/block/codec.go index ca2318002093..a00ad7de2506 100644 --- a/vms/proposervm/block/codec.go +++ b/vms/proposervm/block/codec.go @@ -5,7 +5,6 @@ package block import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -17,7 +16,7 @@ const CodecVersion = 0 var Codec codec.Manager func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() // The maximum block size is enforced by the p2p message size limit. // See: [constants.DefaultMaxMessageSize] Codec = codec.NewManager(math.MaxInt) diff --git a/vms/proposervm/state/codec.go b/vms/proposervm/state/codec.go index 63727894e356..d533ed948c8d 100644 --- a/vms/proposervm/state/codec.go +++ b/vms/proposervm/state/codec.go @@ -5,7 +5,6 @@ package state import ( "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -16,7 +15,7 @@ const CodecVersion = 0 var Codec codec.Manager func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() Codec = codec.NewManager(math.MaxInt32) err := Codec.RegisterCodec(CodecVersion, lc) diff --git a/vms/proposervm/summary/codec.go b/vms/proposervm/summary/codec.go index 41a9eb9a37d0..72617101b84c 100644 --- a/vms/proposervm/summary/codec.go +++ b/vms/proposervm/summary/codec.go @@ -6,7 +6,6 @@ package summary import ( "errors" "math" - "time" "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" @@ -21,7 +20,7 @@ var ( ) func init() { - lc := linearcodec.NewDefault(time.Time{}) + lc := linearcodec.NewDefault() Codec = codec.NewManager(math.MaxInt32) if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { panic(err) diff --git a/vms/secp256k1fx/credential_test.go b/vms/secp256k1fx/credential_test.go index e69b98b286e7..c08548e0bcc7 100644 --- a/vms/secp256k1fx/credential_test.go +++ b/vms/secp256k1fx/credential_test.go @@ -5,7 +5,6 @@ package secp256k1fx import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -28,7 +27,7 @@ func TestCredentialVerifyNil(t *testing.T) { func TestCredentialSerialize(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(0, c)) diff --git a/vms/secp256k1fx/fx_test.go b/vms/secp256k1fx/fx_test.go index dcdf78385404..388d7bc14d84 100644 --- a/vms/secp256k1fx/fx_test.go +++ b/vms/secp256k1fx/fx_test.go @@ -53,7 +53,7 @@ func init() { func TestFxInitialize(t *testing.T) { vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } fx := Fx{} @@ -69,7 +69,7 @@ func TestFxInitializeInvalid(t *testing.T) { func TestFxVerifyTransfer(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -107,7 +107,7 @@ func TestFxVerifyTransfer(t *testing.T) { func TestFxVerifyTransferNilTx(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -143,7 +143,7 @@ func TestFxVerifyTransferNilTx(t *testing.T) { func TestFxVerifyTransferNilOutput(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -170,7 +170,7 @@ func TestFxVerifyTransferNilOutput(t *testing.T) { func TestFxVerifyTransferNilInput(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -201,7 +201,7 @@ func TestFxVerifyTransferNilInput(t *testing.T) { func TestFxVerifyTransferNilCredential(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -233,7 +233,7 @@ func TestFxVerifyTransferNilCredential(t *testing.T) { func TestFxVerifyTransferInvalidOutput(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -270,7 +270,7 @@ func TestFxVerifyTransferInvalidOutput(t *testing.T) { func TestFxVerifyTransferWrongAmounts(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -307,7 +307,7 @@ func TestFxVerifyTransferWrongAmounts(t *testing.T) { func TestFxVerifyTransferTimelocked(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -344,7 +344,7 @@ func TestFxVerifyTransferTimelocked(t *testing.T) { func TestFxVerifyTransferTooManySigners(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -382,7 +382,7 @@ func TestFxVerifyTransferTooManySigners(t *testing.T) { func TestFxVerifyTransferTooFewSigners(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -417,7 +417,7 @@ func TestFxVerifyTransferTooFewSigners(t *testing.T) { func TestFxVerifyTransferMismatchedSigners(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -455,7 +455,7 @@ func TestFxVerifyTransferMismatchedSigners(t *testing.T) { func TestFxVerifyTransferInvalidSignature(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -495,7 +495,7 @@ func TestFxVerifyTransferInvalidSignature(t *testing.T) { func TestFxVerifyTransferWrongSigner(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -535,7 +535,7 @@ func TestFxVerifyTransferWrongSigner(t *testing.T) { func TestFxVerifyTransferSigIndexOOB(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -575,7 +575,7 @@ func TestFxVerifyTransferSigIndexOOB(t *testing.T) { func TestFxVerifyOperation(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -627,7 +627,7 @@ func TestFxVerifyOperation(t *testing.T) { func TestFxVerifyOperationUnknownTx(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -679,7 +679,7 @@ func TestFxVerifyOperationUnknownTx(t *testing.T) { func TestFxVerifyOperationUnknownOperation(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -709,7 +709,7 @@ func TestFxVerifyOperationUnknownOperation(t *testing.T) { func TestFxVerifyOperationUnknownCredential(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -757,7 +757,7 @@ func TestFxVerifyOperationUnknownCredential(t *testing.T) { func TestFxVerifyOperationWrongNumberOfUTXOs(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -810,7 +810,7 @@ func TestFxVerifyOperationWrongNumberOfUTXOs(t *testing.T) { func TestFxVerifyOperationUnknownUTXOType(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -855,7 +855,7 @@ func TestFxVerifyOperationUnknownUTXOType(t *testing.T) { func TestFxVerifyOperationInvalidOperationVerify(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -905,7 +905,7 @@ func TestFxVerifyOperationInvalidOperationVerify(t *testing.T) { func TestFxVerifyOperationMismatchedMintOutputs(t *testing.T) { require := require.New(t) vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC) @@ -952,7 +952,7 @@ func TestFxVerifyOperationMismatchedMintOutputs(t *testing.T) { func TestVerifyPermission(t *testing.T) { vm := TestVM{ - Codec: linearcodec.NewDefault(time.Time{}), + Codec: linearcodec.NewDefault(), Log: logging.NoLog{}, } fx := Fx{} diff --git a/vms/secp256k1fx/transfer_input_test.go b/vms/secp256k1fx/transfer_input_test.go index c155d848e559..4434584e1a9d 100644 --- a/vms/secp256k1fx/transfer_input_test.go +++ b/vms/secp256k1fx/transfer_input_test.go @@ -5,7 +5,6 @@ package secp256k1fx import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -81,7 +80,7 @@ func TestTransferInputVerifyUnsorted(t *testing.T) { func TestTransferInputSerialize(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(0, c)) diff --git a/vms/secp256k1fx/transfer_output_test.go b/vms/secp256k1fx/transfer_output_test.go index 864fb85b9ff0..b1d8a2170b5a 100644 --- a/vms/secp256k1fx/transfer_output_test.go +++ b/vms/secp256k1fx/transfer_output_test.go @@ -5,7 +5,6 @@ package secp256k1fx import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -136,7 +135,7 @@ func TestOutputVerifyDuplicated(t *testing.T) { func TestOutputSerialize(t *testing.T) { require := require.New(t) - c := linearcodec.NewDefault(time.Time{}) + c := linearcodec.NewDefault() m := codec.NewDefaultManager() require.NoError(m.RegisterCodec(0, c)) diff --git a/wallet/chain/x/constants.go b/wallet/chain/x/constants.go index 47efbfc2ff6d..690fa168b5fd 100644 --- a/wallet/chain/x/constants.go +++ b/wallet/chain/x/constants.go @@ -4,8 +4,6 @@ package x import ( - "time" - "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/nftfx" @@ -25,7 +23,6 @@ var Parser block.Parser func init() { var err error Parser, err = block.NewParser( - time.Time{}, []fxs.Fx{ &secp256k1fx.Fx{}, &nftfx.Fx{},