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>
301 lines
6.9 KiB
Go
301 lines
6.9 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package builder
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/node/vms/platformvm/signer"
|
|
"github.com/luxfi/node/vms/platformvm/txs"
|
|
"github.com/luxfi/node/wallet/network/primary/common"
|
|
lux "github.com/luxfi/utxo"
|
|
"github.com/luxfi/utxo/secp256k1fx"
|
|
)
|
|
|
|
var _ Builder = (*builderWithOptions)(nil)
|
|
|
|
type builderWithOptions struct {
|
|
builder Builder
|
|
options []common.Option
|
|
}
|
|
|
|
// NewWithOptions returns a new builder that will use the given options by
|
|
// default.
|
|
//
|
|
// - [builder] is the builder that will be called to perform the underlying
|
|
// operations.
|
|
// - [options] will be provided to the builder in addition to the options
|
|
// provided in the method calls.
|
|
func NewWithOptions(builder Builder, options ...common.Option) Builder {
|
|
return &builderWithOptions{
|
|
builder: builder,
|
|
options: options,
|
|
}
|
|
}
|
|
|
|
func (b *builderWithOptions) Context() *Context {
|
|
return b.builder.Context()
|
|
}
|
|
|
|
func (b *builderWithOptions) GetBalance(
|
|
options ...common.Option,
|
|
) (map[ids.ID]uint64, error) {
|
|
return b.builder.GetBalance(
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) GetImportableBalance(
|
|
chainID ids.ID,
|
|
options ...common.Option,
|
|
) (map[ids.ID]uint64, error) {
|
|
return b.builder.GetImportableBalance(
|
|
chainID,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewBaseTx(
|
|
outputs []*lux.TransferableOutput,
|
|
options ...common.Option,
|
|
) (*txs.BaseTx, error) {
|
|
return b.builder.NewBaseTx(
|
|
outputs,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewAddValidatorTx(
|
|
vdr *txs.Validator,
|
|
rewardsOwner *secp256k1fx.OutputOwners,
|
|
shares uint32,
|
|
options ...common.Option,
|
|
) (*txs.AddValidatorTx, error) {
|
|
return b.builder.NewAddValidatorTx(
|
|
vdr,
|
|
rewardsOwner,
|
|
shares,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
// Removed in regenesis
|
|
func (b *builderWithOptions) NewAddChainValidatorTx(
|
|
vdr *txs.ChainValidator,
|
|
options ...common.Option,
|
|
) (*txs.AddChainValidatorTx, error) {
|
|
return b.builder.NewAddChainValidatorTx(
|
|
vdr,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
// Removed in regenesis
|
|
func (b *builderWithOptions) NewRemoveChainValidatorTx(
|
|
nodeID ids.NodeID,
|
|
netID ids.ID,
|
|
options ...common.Option,
|
|
) (*txs.RemoveChainValidatorTx, error) {
|
|
return b.builder.NewRemoveChainValidatorTx(
|
|
nodeID,
|
|
netID,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewAddDelegatorTx(
|
|
vdr *txs.Validator,
|
|
rewardsOwner *secp256k1fx.OutputOwners,
|
|
options ...common.Option,
|
|
) (*txs.AddDelegatorTx, error) {
|
|
return b.builder.NewAddDelegatorTx(
|
|
vdr,
|
|
rewardsOwner,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewCreateChainTx(
|
|
netID ids.ID,
|
|
genesis []byte,
|
|
vmID ids.ID,
|
|
fxIDs []ids.ID,
|
|
chainName string,
|
|
options ...common.Option,
|
|
) (*txs.CreateChainTx, error) {
|
|
return b.builder.NewCreateChainTx(
|
|
netID,
|
|
genesis,
|
|
vmID,
|
|
fxIDs,
|
|
chainName,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewCreateNetworkTx(
|
|
owner *secp256k1fx.OutputOwners,
|
|
options ...common.Option,
|
|
) (*txs.CreateNetworkTx, error) {
|
|
return b.builder.NewCreateNetworkTx(
|
|
owner,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
// Removed in regenesis
|
|
func (b *builderWithOptions) NewTransferChainOwnershipTx(
|
|
chainID ids.ID,
|
|
owner *secp256k1fx.OutputOwners,
|
|
options ...common.Option,
|
|
) (*txs.TransferChainOwnershipTx, error) {
|
|
return b.builder.NewTransferChainOwnershipTx(
|
|
chainID,
|
|
owner,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewImportTx(
|
|
sourceChainID ids.ID,
|
|
to *secp256k1fx.OutputOwners,
|
|
options ...common.Option,
|
|
) (*txs.ImportTx, error) {
|
|
return b.builder.NewImportTx(
|
|
sourceChainID,
|
|
to,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewExportTx(
|
|
chainID ids.ID,
|
|
outputs []*lux.TransferableOutput,
|
|
options ...common.Option,
|
|
) (*txs.ExportTx, error) {
|
|
return b.builder.NewExportTx(
|
|
chainID,
|
|
outputs,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
// Removed in regenesis
|
|
func (b *builderWithOptions) NewTransformChainTx(
|
|
netID ids.ID,
|
|
assetID ids.ID,
|
|
initialSupply uint64,
|
|
maxSupply uint64,
|
|
minConsumptionRate uint64,
|
|
maxConsumptionRate uint64,
|
|
minValidatorStake uint64,
|
|
maxValidatorStake uint64,
|
|
minStakeDuration time.Duration,
|
|
maxStakeDuration time.Duration,
|
|
minDelegationFee uint32,
|
|
minDelegatorStake uint64,
|
|
maxValidatorWeightFactor byte,
|
|
uptimeRequirement uint32,
|
|
options ...common.Option,
|
|
) (*txs.TransformChainTx, error) {
|
|
return b.builder.NewTransformChainTx(
|
|
netID,
|
|
assetID,
|
|
initialSupply,
|
|
maxSupply,
|
|
minConsumptionRate,
|
|
maxConsumptionRate,
|
|
minValidatorStake,
|
|
maxValidatorStake,
|
|
minStakeDuration,
|
|
maxStakeDuration,
|
|
minDelegationFee,
|
|
minDelegatorStake,
|
|
maxValidatorWeightFactor,
|
|
uptimeRequirement,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewAddPermissionlessValidatorTx(
|
|
vdr *txs.ChainValidator,
|
|
signer signer.Signer,
|
|
assetID ids.ID,
|
|
validationRewardsOwner *secp256k1fx.OutputOwners,
|
|
delegationRewardsOwner *secp256k1fx.OutputOwners,
|
|
shares uint32,
|
|
options ...common.Option,
|
|
) (*txs.AddPermissionlessValidatorTx, error) {
|
|
return b.builder.NewAddPermissionlessValidatorTx(
|
|
vdr,
|
|
signer,
|
|
assetID,
|
|
validationRewardsOwner,
|
|
delegationRewardsOwner,
|
|
shares,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewAddPermissionlessDelegatorTx(
|
|
vdr *txs.ChainValidator,
|
|
assetID ids.ID,
|
|
rewardsOwner *secp256k1fx.OutputOwners,
|
|
options ...common.Option,
|
|
) (*txs.AddPermissionlessDelegatorTx, error) {
|
|
return b.builder.NewAddPermissionlessDelegatorTx(
|
|
vdr,
|
|
assetID,
|
|
rewardsOwner,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewRegisterL1ValidatorTx(
|
|
balance uint64,
|
|
proofOfPossession [96]byte,
|
|
message []byte,
|
|
options ...common.Option,
|
|
) (*txs.RegisterL1ValidatorTx, error) {
|
|
return b.builder.NewRegisterL1ValidatorTx(
|
|
balance,
|
|
proofOfPossession,
|
|
message,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewSetL1ValidatorWeightTx(
|
|
message []byte,
|
|
options ...common.Option,
|
|
) (*txs.SetL1ValidatorWeightTx, error) {
|
|
return b.builder.NewSetL1ValidatorWeightTx(
|
|
message,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewIncreaseL1ValidatorBalanceTx(
|
|
validationID ids.ID,
|
|
balance uint64,
|
|
options ...common.Option,
|
|
) (*txs.IncreaseL1ValidatorBalanceTx, error) {
|
|
return b.builder.NewIncreaseL1ValidatorBalanceTx(
|
|
validationID,
|
|
balance,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|
|
|
|
func (b *builderWithOptions) NewDisableL1ValidatorTx(
|
|
validationID ids.ID,
|
|
options ...common.Option,
|
|
) (*txs.DisableL1ValidatorTx, error) {
|
|
return b.builder.NewDisableL1ValidatorTx(
|
|
validationID,
|
|
common.UnionOptions(b.options, options)...,
|
|
)
|
|
}
|