hashgraph / hashgraph/solo-weaver

refactor(bll): adopt EffectiveValue resolution for traffic shaping fields

Open
#1,093 0 comments 0 reactions 0 assignees View on GitHub
Improvement
Dominant language
Go
Stars
3
Forks
0
Avg merge
3d 5h
Merged PRs (30d)
47

Description

## Summary

Traffic shaping fields (EgressInterface, LinkRate, TrafficShapingEnabled, ShapeOverrides) bypass the `EffectiveValue` resolution pattern used by all other block node fields. Their resolution is scattered across four files using ad-hoc if-empty checks:

- **CLI layer** (`install.go`, `reconfigure.go`) — flag > interactive prompt > seed from persisted state
- **BLL helpers** (`helpers.go:226-255`) — pass-through from input, fallback to `state.Shaping.*` when empty
- **Reality checker** (`blocknode_checker.go:73-86`) — preserves persisted values across state rebuilds
- **Workflow step** (`step_network_tc_egress.go`) — auto-detects NIC from `/proc/net/route` if still empty

## Problem

The priority order is implicit and fragile — it's encoded as nested conditionals across multiple files rather than a declared strategy list. Adding a new source (e.g. environment variable for EgressInterface) requires finding every if-empty check and inserting at the correct position. Testing "does CLI flag beat persisted state?" requires wiring up the full CLI + BLL chain.

This is a maintainability and consistency problem, not a correctness bug. The current code produces the right values.

## Proposed solution

Move traffic shaping fields into `EffectiveValue[T]` resolution:

| Field | Sources to wire |
|---|---|
| `EgressInterface` | Reality (auto-detect from `/proc/net/route`) > State (persisted) > UserInput (CLI flag) > Default (`"auto"`) |
| `LinkRate` | Reality (sysfs link speed) > State (persisted) > UserInput (CLI flag) > Default (`"auto"`) |
| `TrafficShapingEnabled` | State (persisted) > UserInput (CLI flag) > Default (`false`) |
| `ShapeOverrides` | State (persisted, carried forward) > UserInput (CLI flag) |

1. Add these fields to the RSL resolver tier (new or extended resolver functions)
2. Remove the ad-hoc if-empty fallbacks from `helpers.go`, CLI prompt seeding, and step-level detection
3. Auto-detection logic (`DetectEgressInterface`, `ReadLinkSpeedMbit`) becomes the Reality strategy provider
4. Preserve the install vs upgrade distinction: install/reconfigure resolve fresh; upgrade re-asserts from state only

## Scope

- [ ] Add traffic shaping fields to RSL resolver with `EffectiveValue[T]`
- [ ] Wire auto-detection as Reality strategy
- [ ] Remove ad-hoc resolution from CLI, BLL helpers, and step layer
- [ ] Preserve `patchBlockNodeStateWithTrafficShaping` vs `patchBlockNodeState` semantics
- [ ] Unit tests for traffic shaping effective value resolution

Contributor guide

Open the contributing guide

Research direction

Trace the existing EffectiveValue resolver and compare it with traffic-shaping handling in install.go, reconfigure.go, helpers.go:226-255, blocknode_checker.go:73-86, and step_network_tc_egress.go. Read the current DetectEgressInterface and ReadLinkSpeedMbit paths first, then add unit coverage for the stated source priorities and verify install, reconfigure, and upgrade semantics are preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, cli, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.