Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Durango codec check #507

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/VictoriaMetrics/fastcache v1.10.0
github.com/ava-labs/avalanchego v1.11.2
github.com/ava-labs/avalanchego v1.11.3-codec-cleanup
github.com/cespare/cp v0.1.0
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set/v2 v2.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.2 h1:8iodZ+RjqpRwHdiXPPtvaNt72qravge7voGzw3yPRzg=
github.com/ava-labs/avalanchego v1.11.2/go.mod h1:oTVnF9idL57J4LM/6RByTmKhI4QvV6OCnF99ysyBljE=
github.com/ava-labs/avalanchego v1.11.3-codec-cleanup h1:vDaeub6mMehtmoYKDNrRf1V2DqGQmbHG2nnJgfvQv0s=
github.com/ava-labs/avalanchego v1.11.3-codec-cleanup/go.mod h1:oTVnF9idL57J4LM/6RByTmKhI4QvV6OCnF99ysyBljE=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
2 changes: 1 addition & 1 deletion peer/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func TestNetworkRouting(t *testing.T) {

func buildCodec(t *testing.T, types ...interface{}) codec.Manager {
codecManager := codec.NewDefaultManager()
c := linearcodec.NewDefault(time.Time{})
c := linearcodec.NewDefault()
for _, typ := range types {
assert.NoError(t, c.RegisterType(typ))
}
Expand Down
26 changes: 7 additions & 19 deletions plugin/evm/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package evm

import (
"fmt"
"time"

"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/linearcodec"
Expand All @@ -16,14 +15,12 @@ import (
// Codec does serialization and deserialization
var Codec codec.Manager

// TODO: Remove after v1.11.x has activated
//
// Invariant: InitCodec and Codec must not be accessed concurrently
func InitCodec(durangoTime time.Time) error {
func init() {
Codec = codec.NewDefaultManager()

var (
lc = linearcodec.NewDefault(durangoTime)
newCodec = codec.NewDefaultManager()
errs = wrappers.Errs{}
lc = linearcodec.NewDefault()
errs = wrappers.Errs{}
)
errs.Add(
lc.RegisterType(&UnsignedImportTx{}),
Expand All @@ -38,19 +35,10 @@ func InitCodec(durangoTime time.Time) error {
lc.RegisterType(&secp256k1fx.Credential{}),
lc.RegisterType(&secp256k1fx.Input{}),
lc.RegisterType(&secp256k1fx.OutputOwners{}),
newCodec.RegisterCodec(codecVersion, lc),
Codec.RegisterCodec(codecVersion, lc),
)
if errs.Errored() {
return errs.Err
}

Codec = newCodec
return nil
}

func init() {
if err := InitCodec(time.Time{}); err != nil {
panic(err)
panic(errs.Err)
}
}

Expand Down
6 changes: 2 additions & 4 deletions plugin/evm/message/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/units"
Expand All @@ -24,7 +22,7 @@ var (

func init() {
Codec = codec.NewManager(maxMessageSize)
c := linearcodec.NewDefault(time.Time{})
c := linearcodec.NewDefault()

errs := wrappers.Errs{}
errs.Add(
Expand Down Expand Up @@ -56,7 +54,7 @@ func init() {
}

CrossChainCodec = codec.NewManager(maxMessageSize)
ccc := linearcodec.NewDefault(time.Time{})
ccc := linearcodec.NewDefault()

errs = wrappers.Errs{}
errs.Add(
Expand Down
3 changes: 1 addition & 2 deletions plugin/evm/test_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package evm
import (
"math/big"
"math/rand"
"time"

"github.com/ava-labs/avalanchego/utils"

Expand Down Expand Up @@ -78,7 +77,7 @@ func (t *TestUnsignedTx) EVMStateTransfer(ctx *snow.Context, state *state.StateD

func testTxCodec() codec.Manager {
codec := codec.NewDefaultManager()
c := linearcodec.NewDefault(time.Time{})
c := linearcodec.NewDefault()

errs := wrappers.Errs{}
errs.Add(
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,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.NewDefault(time.Time{})
vm.baseCodec = linearcodec.NewDefault()

if err := vm.fx.Initialize(vm); err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions predicate/predicate_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package predicate
import (
"fmt"
"strings"
"time"

"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/linearcodec"
Expand All @@ -25,7 +24,7 @@ var Codec codec.Manager
func init() {
Codec = codec.NewManager(MaxResultsSize)

c := linearcodec.NewDefault(time.Time{})
c := linearcodec.NewDefault()
errs := wrappers.Errs{}
errs.Add(
c.RegisterType(Results{}),
Expand Down
2 changes: 1 addition & 1 deletion scripts/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
set -euo pipefail

# Don't export them as they're used in the context of other calls
avalanche_version=${AVALANCHE_VERSION:-'v1.11.2'}
avalanche_version=${AVALANCHE_VERSION:-'v1.11.3-codec-cleanup'}
2 changes: 1 addition & 1 deletion warp/aggregator/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func newValidator(t testing.TB, weight uint64) (*bls.SecretKey, *avalancheWarp.V
pk := bls.PublicFromSecretKey(sk)
return sk, &avalancheWarp.Validator{
PublicKey: pk,
PublicKeyBytes: bls.PublicKeyToBytes(pk),
PublicKeyBytes: bls.PublicKeyToCompressedBytes(pk),
darioush marked this conversation as resolved.
Show resolved Hide resolved
Weight: weight,
NodeIDs: []ids.NodeID{ids.GenerateTestNodeID()},
}
Expand Down
Loading