mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
vms/platformvm/... build + vet PASS with pcodecs/txs.Codec gone from the VM. Executor semantics (standard_tx_executor): - registerOwnSet(): shared primitive — per-validator state.L1Validator with native owner blobs (txs.MarshalOwner/UnmarshalOwner, no codec), active-set capacity check, EndAccumulatedFee=balance+accruedFees, SetNetToL1Conversion manager-authority recording (byte-for-byte legacy tail). - ConvertNetworkTx: promote endomorphism (owner-authorized, folds old ConvertNetworkToL1Tx), gated by security.Mode.Manager. - CreateNetworkTx: base (AddNet/SetNetOwner) + sovereign path registers own set. - Deleted CreateSovereignL1Tx + ConvertNetworkToL1Tx. - txs.UnmarshalOwner added: canonical owner marshal/unmarshal pair, no codec. All ~13 txs.Visitor impls carry ConvertNetworkTx; gossip/block Parse(b) codec-free; wallet/network/primary off txs.Codec. KNOWN GAP (pending design decision, NOT silently green): CreateNetworkTx reads tx.Chains() only to derive managerChainID — it does NOT create the genesis chains (no AddChain). Atomic-spawn-with-chains vs decomplect-to-CreateChainTx is the open call. 17 codec-era _test.go parked as .bak for follow-up rewrite. Co-authored-by: Hanzo Dev <dev@hanzo.ai>
149 lines
3.1 KiB
Go
149 lines
3.1 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package executor
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/luxfi/node/vms/platformvm/txs"
|
|
"github.com/luxfi/node/vms/platformvm/warp"
|
|
validators "github.com/luxfi/validators"
|
|
)
|
|
|
|
const (
|
|
WarpQuorumNumerator = 67
|
|
WarpQuorumDenominator = 100
|
|
)
|
|
|
|
var _ txs.Visitor = (*warpVerifier)(nil)
|
|
|
|
// VerifyWarpMessages verifies all warp messages in the tx. If any of the warp
|
|
// messages are invalid, an error is returned.
|
|
func VerifyWarpMessages(
|
|
ctx context.Context,
|
|
networkID uint32,
|
|
validatorState validators.State,
|
|
pChainHeight uint64,
|
|
tx txs.UnsignedTx,
|
|
) error {
|
|
return tx.Visit(&warpVerifier{
|
|
context: ctx,
|
|
networkID: networkID,
|
|
validatorState: validatorState,
|
|
pChainHeight: pChainHeight,
|
|
})
|
|
}
|
|
|
|
type warpVerifier struct {
|
|
context context.Context
|
|
networkID uint32
|
|
validatorState validators.State
|
|
pChainHeight uint64
|
|
}
|
|
|
|
func (*warpVerifier) AddValidatorTx(*txs.AddValidatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) AddChainValidatorTx(*txs.AddChainValidatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) AddDelegatorTx(*txs.AddDelegatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) CreateChainTx(*txs.CreateChainTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) CreateNetworkTx(*txs.CreateNetworkTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) ImportTx(*txs.ImportTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) ExportTx(*txs.ExportTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) AdvanceTimeTx(*txs.AdvanceTimeTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) RewardValidatorTx(*txs.RewardValidatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) RemoveChainValidatorTx(*txs.RemoveChainValidatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) TransformChainTx(*txs.TransformChainTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) AddPermissionlessValidatorTx(*txs.AddPermissionlessValidatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) AddPermissionlessDelegatorTx(*txs.AddPermissionlessDelegatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) TransferChainOwnershipTx(*txs.TransferChainOwnershipTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) BaseTx(*txs.BaseTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) ConvertNetworkTx(*txs.ConvertNetworkTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) IncreaseL1ValidatorBalanceTx(*txs.IncreaseL1ValidatorBalanceTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (*warpVerifier) DisableL1ValidatorTx(*txs.DisableL1ValidatorTx) error {
|
|
return nil
|
|
}
|
|
|
|
func (w *warpVerifier) RegisterL1ValidatorTx(tx *txs.RegisterL1ValidatorTx) error {
|
|
return w.verify(tx.Message())
|
|
}
|
|
|
|
func (w *warpVerifier) SetL1ValidatorWeightTx(tx *txs.SetL1ValidatorWeightTx) error {
|
|
return w.verify(tx.Message())
|
|
}
|
|
|
|
func (w *warpVerifier) verify(message []byte) error {
|
|
msg, err := warp.ParseMessage(message)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
validators, err := warp.GetCanonicalValidatorSetFromChainID(
|
|
w.context,
|
|
w.validatorState,
|
|
w.pChainHeight,
|
|
msg.SourceChainID,
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return msg.Signature.Verify(
|
|
&msg.UnsignedMessage,
|
|
w.networkID,
|
|
validators,
|
|
WarpQuorumNumerator,
|
|
WarpQuorumDenominator,
|
|
)
|
|
}
|