vms/{evm,example,rpcchainvm}: rip luxfi/codec via pcodecs (wave 2D)

Small consumers swapped to pcodecs:
  evm/predicate/results.go         — codec.Manager + linearcodec init →
                                     pcodecs.Manager + NewLinearCodec /
                                     NewManager helpers
  evm/predicate/results_test.go    — codec sentinel errors →
                                     pcodecs.ErrCantUnpackVersion /
                                     ErrMaxSliceLenExceeded
  evm/lp176/lp176.go               — wrappers.LongLen → pcodecs.LongLen
  evm/lp176/lp176/lp176.go         — wrappers.LongLen → pcodecs.LongLen
  example/xsvm/tx/codec.go         — codec.Manager singleton via pcodecs
  example/xsvm/execute/tx.go       — wrappers.Errs → pcodecs.Errs
  rpcchainvm/runtime/subprocess/linux_stopper.go — wrappers.Errs → pcodecs.Errs

build: go build ./vms/...
test: go test ./vms/{evm,example,rpcchainvm}/...

zero direct luxfi/codec imports remain in vms/{evm,example,rpcchainvm}.
This commit is contained in:
Hanzo AI
2026-06-06 02:37:41 -07:00
parent cb85cd6f2e
commit aa9097c1b1
7 changed files with 30 additions and 34 deletions
+7 -7
View File
@@ -15,9 +15,9 @@ import (
"github.com/holiman/uint256"
"github.com/luxfi/node/vms/components/gas"
safemath "github.com/luxfi/math"
"github.com/luxfi/codec/wrappers"
"github.com/luxfi/node/vms/components/gas"
"github.com/luxfi/node/vms/pcodecs"
)
const (
@@ -35,7 +35,7 @@ const (
MinMaxPerSecond = MinTargetPerSecond * TargetToMax
MinMaxCapacity = MinMaxPerSecond * TimeToFillCapacity
StateSize = 3 * wrappers.LongLen
StateSize = 3 * pcodecs.LongLen
maxTargetExcess = 1_024_950_627 // TargetConversion * ln(MaxUint64 / MinTargetPerSecond) + 1
)
@@ -63,9 +63,9 @@ func ParseState(bytes []byte) (State, error) {
return State{
Gas: gas.State{
Capacity: gas.Gas(binary.BigEndian.Uint64(bytes)),
Excess: gas.Gas(binary.BigEndian.Uint64(bytes[wrappers.LongLen:])),
Excess: gas.Gas(binary.BigEndian.Uint64(bytes[pcodecs.LongLen:])),
},
TargetExcess: gas.Gas(binary.BigEndian.Uint64(bytes[2*wrappers.LongLen:])),
TargetExcess: gas.Gas(binary.BigEndian.Uint64(bytes[2*pcodecs.LongLen:])),
}, nil
}
@@ -172,8 +172,8 @@ func (s *State) UpdateTargetExcess(desiredTargetExcess gas.Gas) {
func (s *State) Bytes() []byte {
bytes := make([]byte, StateSize)
binary.BigEndian.PutUint64(bytes, uint64(s.Gas.Capacity))
binary.BigEndian.PutUint64(bytes[wrappers.LongLen:], uint64(s.Gas.Excess))
binary.BigEndian.PutUint64(bytes[2*wrappers.LongLen:], uint64(s.TargetExcess))
binary.BigEndian.PutUint64(bytes[pcodecs.LongLen:], uint64(s.Gas.Excess))
binary.BigEndian.PutUint64(bytes[2*pcodecs.LongLen:], uint64(s.TargetExcess))
return bytes
}
+7 -8
View File
@@ -15,10 +15,9 @@ import (
"github.com/holiman/uint256"
"github.com/luxfi/node/vms/components/gas"
"github.com/luxfi/codec/wrappers"
safemath "github.com/luxfi/math"
"github.com/luxfi/node/vms/components/gas"
"github.com/luxfi/node/vms/pcodecs"
)
const (
@@ -36,7 +35,7 @@ const (
MinMaxPerSecond = MinTargetPerSecond * TargetToMax
MinMaxCapacity = MinMaxPerSecond * TimeToFillCapacity
StateSize = 3 * wrappers.LongLen
StateSize = 3 * pcodecs.LongLen
maxTargetExcess = 1_024_950_627 // TargetConversion * ln(MaxUint64 / MinTargetPerSecond) + 1
)
@@ -64,9 +63,9 @@ func ParseState(bytes []byte) (State, error) {
return State{
Gas: gas.State{
Capacity: gas.Gas(binary.BigEndian.Uint64(bytes)),
Excess: gas.Gas(binary.BigEndian.Uint64(bytes[wrappers.LongLen:])),
Excess: gas.Gas(binary.BigEndian.Uint64(bytes[pcodecs.LongLen:])),
},
TargetExcess: gas.Gas(binary.BigEndian.Uint64(bytes[2*wrappers.LongLen:])),
TargetExcess: gas.Gas(binary.BigEndian.Uint64(bytes[2*pcodecs.LongLen:])),
}, nil
}
@@ -162,8 +161,8 @@ func (s *State) UpdateTargetExcess(desiredTargetExcess gas.Gas) {
func (s *State) Bytes() []byte {
bytes := make([]byte, StateSize)
binary.BigEndian.PutUint64(bytes, uint64(s.Gas.Capacity))
binary.BigEndian.PutUint64(bytes[wrappers.LongLen:], uint64(s.Gas.Excess))
binary.BigEndian.PutUint64(bytes[2*wrappers.LongLen:], uint64(s.TargetExcess))
binary.BigEndian.PutUint64(bytes[pcodecs.LongLen:], uint64(s.Gas.Excess))
binary.BigEndian.PutUint64(bytes[2*pcodecs.LongLen:], uint64(s.TargetExcess))
return bytes
}
+4 -5
View File
@@ -8,10 +8,9 @@ import (
"github.com/luxfi/geth/common"
"github.com/luxfi/codec"
"github.com/luxfi/codec/linearcodec"
"github.com/luxfi/constants"
"github.com/luxfi/math/set"
"github.com/luxfi/node/vms/pcodecs"
)
const (
@@ -33,12 +32,12 @@ const (
maxResultsSize = constants.MiB
)
var resultsCodec codec.Manager
var resultsCodec pcodecs.Manager
func init() {
resultsCodec = codec.NewManager(maxResultsSize)
resultsCodec = pcodecs.NewManager(maxResultsSize)
c := linearcodec.NewDefault()
c := pcodecs.NewLinearCodec()
if err := resultsCodec.RegisterCodec(version, c); err != nil {
panic(err)
}
+3 -3
View File
@@ -10,8 +10,8 @@ import (
"github.com/luxfi/geth/common"
"github.com/stretchr/testify/require"
"github.com/luxfi/codec"
"github.com/luxfi/math/set"
"github.com/luxfi/node/vms/pcodecs"
)
// Valid result parsing is tested by [TestBlockResultsBytes]
@@ -24,7 +24,7 @@ func TestParseBlockResultsInvalid(t *testing.T) {
{
name: "nil",
b: nil,
wantErr: codec.ErrCantUnpackVersion,
wantErr: pcodecs.ErrCantUnpackVersion,
},
{
name: "too_big",
@@ -50,7 +50,7 @@ func TestParseBlockResultsInvalid(t *testing.T) {
},
make([]byte, 1<<24), // Append the bitset
),
wantErr: codec.ErrMaxSliceLenExceeded,
wantErr: pcodecs.ErrMaxSliceLenExceeded,
},
}
for _, test := range tests {
+3 -3
View File
@@ -7,12 +7,12 @@ import (
"context"
"errors"
"github.com/luxfi/codec/wrappers"
hash "github.com/luxfi/crypto/hash"
"github.com/luxfi/database"
"github.com/luxfi/ids"
"github.com/luxfi/node/vms/example/xsvm/state"
"github.com/luxfi/node/vms/example/xsvm/tx"
"github.com/luxfi/node/vms/pcodecs"
"github.com/luxfi/node/vms/platformvm/warp"
"github.com/luxfi/runtime"
validators "github.com/luxfi/validators"
@@ -91,7 +91,7 @@ func (t *Tx) Export(e *tx.Export) error {
return err
}
var errs wrappers.Errs
var errs pcodecs.Errs
errs.Add(
state.IncrementNonce(t.Database, t.Sender, e.Nonce),
state.DecreaseBalance(t.Database, t.Sender, e.ChainID, t.ExportFee),
@@ -127,7 +127,7 @@ func (t *Tx) Import(i *tx.Import) error {
return err
}
var errs wrappers.Errs
var errs pcodecs.Errs
errs.Add(
state.IncrementNonce(t.Database, t.Sender, i.Nonce),
state.DecreaseBalance(t.Database, t.Sender, t.Runtime.ChainID, t.ImportFee),
+4 -6
View File
@@ -5,19 +5,17 @@ package tx
import (
"errors"
"math"
"github.com/luxfi/codec"
"github.com/luxfi/codec/linearcodec"
"github.com/luxfi/node/vms/pcodecs"
)
const CodecVersion = 0
var Codec codec.Manager
var Codec pcodecs.Manager
func init() {
c := linearcodec.NewDefault()
Codec = codec.NewManager(math.MaxInt32)
c := pcodecs.NewLinearCodec()
Codec = pcodecs.NewMaxInt32Manager()
err := errors.Join(
c.RegisterType(&Transfer{}),
@@ -14,8 +14,8 @@ import (
"syscall"
"github.com/luxfi/log"
"github.com/luxfi/node/vms/pcodecs"
"github.com/luxfi/node/vms/rpcchainvm/runtime"
"github.com/luxfi/codec/wrappers"
)
func NewCmd(path string, args ...string) *exec.Cmd {
@@ -31,7 +31,7 @@ func stop(ctx context.Context, log log.Logger, cmd *exec.Cmd) {
waitChan := make(chan error)
go func() {
// attempt graceful shutdown
errs := wrappers.Errs{}
errs := pcodecs.Errs{}
err := cmd.Process.Signal(syscall.SIGTERM)
errs.Add(err)
_, err = cmd.Process.Wait()