From 4cc1b042e7c1a5836728ccbda51532384320e63a Mon Sep 17 00:00:00 2001 From: Todd Stock Date: Mon, 21 Dec 2020 11:44:31 -0500 Subject: upgrade 1.1.1 codec --- plugin/evm/tx.go | 2 +- plugin/evm/vm.go | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'plugin') diff --git a/plugin/evm/tx.go b/plugin/evm/tx.go index 1c0ce48..c13592c 100644 --- a/plugin/evm/tx.go +++ b/plugin/evm/tx.go @@ -15,7 +15,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/utils" - "github.com/ava-labs/avalanchego/utils/codec" + "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/hashing" "github.com/ava-labs/avalanchego/vms/components/verify" diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 9335b51..fa5d3f5 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -8,6 +8,8 @@ import ( "encoding/json" "errors" "fmt" + "github.com/ava-labs/avalanchego/codec/linearcodec" + "github.com/ava-labs/avalanchego/codec/reflectcodec" "math/big" "strings" "sync" @@ -40,7 +42,7 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" - "github.com/ava-labs/avalanchego/utils/codec" + "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/formatting" @@ -122,14 +124,14 @@ var Codec codec.Manager func init() { Codec = codec.NewDefaultManager() - c := codec.NewDefault() + c := linearcodec.New(reflectcodec.DefaultTagName, 1<<20) errs := wrappers.Errs{} errs.Add( c.RegisterType(&UnsignedImportTx{}), c.RegisterType(&UnsignedExportTx{}), ) - c.Skip(3) + c.SkipRegistrations(3) errs.Add( c.RegisterType(&secp256k1fx.TransferInput{}), c.RegisterType(&secp256k1fx.MintOutput{}), @@ -225,9 +227,6 @@ func (vm *VM) getAtomicTx(block *types.Block) *Tx { // Codec implements the secp256k1fx interface func (vm *VM) Codec() codec.Manager { return vm.codec } -// CodecRegistry implements the secp256k1fx interface -func (vm *VM) CodecRegistry() codec.Registry { return vm.baseCodec } - // Clock implements the secp256k1fx interface func (vm *VM) Clock() *timer.Clock { return &vm.clock } @@ -418,7 +417,7 @@ func (vm *VM) Initialize( // so [vm.baseCodec] is a dummy codec use to fulfill the secp256k1fx VM // interface. The fx will register all of its types, which can be safely // ignored by the VM's codec. - vm.baseCodec = codec.NewDefault() + vm.baseCodec = linearcodec.New(reflectcodec.DefaultTagName, 1<<20) return vm.fx.Initialize(vm) } -- cgit v1.2.3-70-g09d2 From 3f485d21b7f0be08ee2256a26b7ff856fcd448cf Mon Sep 17 00:00:00 2001 From: Todd Stock Date: Mon, 21 Dec 2020 12:04:54 -0500 Subject: lint --- plugin/evm/tx.go | 2 +- plugin/evm/vm.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'plugin') diff --git a/plugin/evm/tx.go b/plugin/evm/tx.go index c13592c..f325159 100644 --- a/plugin/evm/tx.go +++ b/plugin/evm/tx.go @@ -11,11 +11,11 @@ import ( "github.com/ava-labs/coreth/core/state" + "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/utils" - "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/hashing" "github.com/ava-labs/avalanchego/vms/components/verify" diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index fa5d3f5..7634ca7 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -8,14 +8,15 @@ import ( "encoding/json" "errors" "fmt" - "github.com/ava-labs/avalanchego/codec/linearcodec" - "github.com/ava-labs/avalanchego/codec/reflectcodec" "math/big" "strings" "sync" "sync/atomic" "time" + "github.com/ava-labs/avalanchego/codec/linearcodec" + "github.com/ava-labs/avalanchego/codec/reflectcodec" + "github.com/ava-labs/coreth" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/state" @@ -36,13 +37,13 @@ import ( "github.com/ava-labs/avalanchego/api/admin" "github.com/ava-labs/avalanchego/cache" + "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" - "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto" "github.com/ava-labs/avalanchego/utils/formatting" @@ -124,7 +125,7 @@ var Codec codec.Manager func init() { Codec = codec.NewDefaultManager() - c := linearcodec.New(reflectcodec.DefaultTagName, 1<<20) + c := linearcodec.New(reflectcodec.DefaultTagName, 1<<20) errs := wrappers.Errs{} errs.Add( -- cgit v1.2.3-70-g09d2 From 1f6929d2c073ed4b735e0f60eb8282200262f60b Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Mon, 21 Dec 2020 12:13:21 -0500 Subject: Switch to using new default for linear codec --- plugin/evm/vm.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plugin') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 7634ca7..343b4ec 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -15,7 +15,6 @@ import ( "time" "github.com/ava-labs/avalanchego/codec/linearcodec" - "github.com/ava-labs/avalanchego/codec/reflectcodec" "github.com/ava-labs/coreth" "github.com/ava-labs/coreth/core" @@ -125,7 +124,7 @@ var Codec codec.Manager func init() { Codec = codec.NewDefaultManager() - c := linearcodec.New(reflectcodec.DefaultTagName, 1<<20) + c := linearcodec.NewDefault() errs := wrappers.Errs{} errs.Add( @@ -418,7 +417,7 @@ func (vm *VM) Initialize( // so [vm.baseCodec] is a dummy codec use to fulfill the secp256k1fx VM // interface. The fx will register all of its types, which can be safely // ignored by the VM's codec. - vm.baseCodec = linearcodec.New(reflectcodec.DefaultTagName, 1<<20) + vm.baseCodec = linearcodec.NewDefault() return vm.fx.Initialize(vm) } -- cgit v1.2.3-70-g09d2 From 4a1eb7db944fcb07ee85964ee8b34c19e3630d3d Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Mon, 21 Dec 2020 12:19:21 -0500 Subject: Add CodecRegistry to comply with secp fx interface --- plugin/evm/vm.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 343b4ec..50623c3 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -201,7 +201,7 @@ type VM struct { genlock sync.Mutex txSubmitChan <-chan struct{} atomicTxSubmitChan chan struct{} - baseCodec codec.Codec + baseCodec codec.Registry codec codec.Manager clock timer.Clock txFee uint64 @@ -227,6 +227,9 @@ func (vm *VM) getAtomicTx(block *types.Block) *Tx { // Codec implements the secp256k1fx interface func (vm *VM) Codec() codec.Manager { return vm.codec } +// CodecRegistry implements the secp256k1fx interface +func (vm *VM) CodecRegistry() codec.Registry { return vm.baseCodec } + // Clock implements the secp256k1fx interface func (vm *VM) Clock() *timer.Clock { return &vm.clock } -- cgit v1.2.3-70-g09d2