Files
node/vms/platformvm/metrics/block_metrics.go
T
zeekayandHanzo Dev c44cc2289f platformvm builds GREEN off the codec: executor fold + full consumer flip
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>
2026-07-10 14:25:08 -07:00

82 lines
1.6 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package metrics
import (
"github.com/luxfi/metric"
"github.com/luxfi/node/vms/platformvm/block"
)
const blkLabel = "blk"
var (
_ block.Visitor = (*blockMetrics)(nil)
blkLabels = []string{blkLabel}
)
type blockMetrics struct {
txMetrics *txMetrics
numBlocks metric.CounterVec
}
func newBlockMetrics(registerer metric.Registerer) (*blockMetrics, error) {
txMetrics, err := newTxMetrics(registerer)
if err != nil {
return nil, err
}
m := &blockMetrics{
txMetrics: txMetrics,
numBlocks: metric.NewCounterVec(
metric.CounterOpts{
Name: "blks_accepted",
Help: "number of blocks accepted",
},
blkLabels,
),
}
return m, nil
}
func (m *blockMetrics) AbortBlock(*block.AbortBlock) error {
m.numBlocks.With(metric.Labels{
blkLabel: "abort",
}).Inc()
return nil
}
func (m *blockMetrics) CommitBlock(*block.CommitBlock) error {
m.numBlocks.With(metric.Labels{
blkLabel: "commit",
}).Inc()
return nil
}
func (m *blockMetrics) ProposalBlock(b *block.ProposalBlock) error {
m.numBlocks.With(metric.Labels{
blkLabel: "proposal",
}).Inc()
// Txs() returns the decision txs followed by the proposal tx (last).
for _, tx := range b.Txs() {
if err := tx.Unsigned.Visit(m.txMetrics); err != nil {
return err
}
}
return nil
}
func (m *blockMetrics) StandardBlock(b *block.StandardBlock) error {
m.numBlocks.With(metric.Labels{
blkLabel: "standard",
}).Inc()
for _, tx := range b.Txs() {
if err := tx.Unsigned.Visit(m.txMetrics); err != nil {
return err
}
}
return nil
}