Generic firmware/family support #103
Closed
ankitgoswami
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
ePIC firmware runs on Antminer hardware and gets fully discovered by asic-rs (the underlying Rust library, v0.5.0): it returns
firmware="ePIC"andmake="AntMiner"for ePIC-on-Antminer, andmake="ePIC",firmware="ePIC"for native ePIC hardware. But the proto-fleet asicrs plugin rejects it because of a chain of hardcoded enums/tables in plugin/asicrs/src/capabilities.rs:FAMILY_*) and per variant (VARIANT_*)make_to_family()table that requires every aftermarket firmware name to be listedfirmware_to_variant()substring matcher with a fixed set of armsfirmware_manufacturer()map from variant key → display nameconfig.yamlthat explicitly lists every family/variant under an opt-inenabled: trueflagEvery time asic-rs adds a new firmware (e.g., ePIC) or a new make, proto-fleet has to add five+ constants, three+ table entries, and a config block. That's the rigidity to fix.
The asic-rs library already gives us clean canonical strings via the
MinerFirmwareandMinerMakeDisplayimpls — we should use them as the keys and stop maintaining a parallel taxonomy. Once we do, ePIC support drops out for free.Design
Principle: asic-rs's
makeandfirmwareDisplay strings are the source of truth. The plugin layer normalizes them (lowercase, alphanumeric only) into config keys and uses them directly. New firmwares/makes from asic-rs flow through automatically. Specialization (credentials, auth strategies) stays explicit but degrades gracefully to sensible defaults so new entries work without code.What changes
Replace identification constants with a normalize function in plugin/asicrs/src/capabilities.rs:
Replace
make_to_family/firmware_to_variant/detect_variantwith two thin wrappers that operate on the asic-rs Display strings:detect_variantis no longer needed because asic-rs always populatesdevice_info.firmwarevia theMinerFirmwareDisplayimpl. (Confirmed: see asic-rs-firmwares/epic/src/firmware.rs L66-70 and the corresponding impls for vnish/marathon/etc.) The signature-based caller in plugin/asicrs/src/device.rs:773-774 (VNish hostname strategy) only needsvariant_key("VNish") == "vnish", which works.Drop
firmware_manufacturer()entirely. The display name is already indevice_info.firmware(canonical asic-rs Display string like"ePIC"). In driver.rs:354-356 and driver.rs:513-515, replace:with:
This means VNish devices will show
"VNish"(whatever asic-rs returns) — no parallelDISPLAY_*table to keep in sync.Default-allow config in plugin/asicrs/src/config.rs:
default_enabled: boolfield toPluginSettings(defaults totrue).is_firmware_enabled(family, variant)returns the explicitenabledvalue if aminers.<family>.<variant>entry exists, otherwisedefault_enabled.self.config.miners.contains_key(family)early-reject in driver.rs:293-296 —is_firmware_enablednow handles unknown families cleanly.Shrink config.yaml to just the explicit overrides:
New asic-rs miners/firmwares (ePIC today, the next one tomorrow) need zero config.
canonical_port(family)in driver.rs:74-83 — keep the explicit map for known families but fall back to 80 for unknown families (HTTP web is the most common asic-rs default). Update the match to a small static table with a default arm. Replacecrate::capabilities::FAMILY_*references with string literals ("whatsminer", etc.).default_credentials(family, variant)in capabilities.rs:326-356 — restructure so credentials are keyed by variant first (firmware vendor sets the auth, not the hardware), with family as fallback for stock:admin/letmein(one line)admin/adminif family is also unknownaccessfieldUpdate plugin/asicrs/src/device.rs:773-774 to use the new function:
No change to existing behavior; just the call site.
Defensive Go-plugin update in plugin/antminer/internal/driver/driver.go:42-52:
firmwareMarkerEpic = "epic"and append tononStockFirmwareMarkers.GetVersion()should fail to handshake anyway — but the marker is documentation for the next reader and a safety net.What stays the same
verify_identity,normalize_mac, capability probing (probe_capabilities,static_base_capabilities,driver_base_capabilities) — already dynamic via the asic-rsMinertrait.DefaultCredentialstruct.MinerFamilyConfigschema (miners.<family>.<variant>.enabled) — only the resolution logic changes.Migration / behavioral deltas to be aware of
firmware_to_variant("MARAFW_1.0.0")returns"marathon"via an explicit alias. With the new scheme,variant_key("MaraFW")(the asic-rs Display string) returns"marafw", not"marathon". Two options:marafw. Cleaner, no aliases.{"marafw": "marathon"}. Less surprise for existing config files but reintroduces the table.marafwmatches asic-rs's Display.DISPLAY_VNISH = "VNish"etc. matches asic-rs's Display anyway, so swapping to "use whatever asic-rs returns" should be a no-op for existing variants. Verify via the existing antminer-vnish contract test.default_enabled: true, native ePIC hardware (family=epic, variant=epic) auto-enables. No explicit config needed. The existingepic.stockblock in config.yaml:35-37 becomes obsolete and can be deleted.Beta Was this translation helpful? Give feedback.
All reactions