[#976] Aggregate devshards stats with CurrentEpochStats#1001
[#976] Aggregate devshards stats with CurrentEpochStats#1001dcastro wants to merge 7 commits intodiogo/#976-subnet-rewards-end-of-epochfrom
devshards stats with CurrentEpochStats#1001Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends subnet host performance statistics with inference_count and validated, propagates those fields through protobuf/JSON boundaries (subnetctl + Kotlin client + chain types), and aggregates the resulting settlement stats into chain-side per-epoch storage and participant CurrentEpochStats.
Changes:
- Add
inference_countandvalidatedto subnet host stats data models and protobuf schemas; update hashing/serialization to include them. - Track
InferenceCountandValidatedin the subnet state machine, and add/adjust tests aroundValidatedcounter transitions. - Aggregate settlement host stats into chain
SubnetHostEpochStatsMapand intoParticipant.CurrentEpochStats, with keeper/msg-server test coverage.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| testermint/src/main/kotlin/data/subnet.kt | Adds inference_count and validated fields to Kotlin settlement host stats DTO. |
| subnet/types/state.pb.go | Regenerated protobuf bindings to include new host stats fields. |
| subnet/types/domain.go | Extends HostStats domain model with InferenceCount and Validated (+ doc comments). |
| subnet/state/machine.go | Updates state transitions to increment/decrement the new counters during inference/validation lifecycle. |
| subnet/state/machine_test.go | Adds tests validating HostStats.Validated transition behavior for validations. |
| subnet/state/hash.go | Includes new fields in host stats hash preimage (state root consistency). |
| subnet/proto/subnet/v1/state.proto | Adds new host stats fields to subnet state protobuf schema. |
| subnet/cmd/subnetctl/marshal_test.go | Updates settlement marshal/unmarshal tests to cover new fields. |
| subnet/cmd/subnetctl/main.go | Extends JSON marshaling output with the new host stats fields. |
| inference-chain/x/inference/types/subnet_settlement.pb.go | Regenerated chain settlement protobuf bindings to include new fields. |
| inference-chain/x/inference/types/subnet_escrow.pb.go | Regenerated chain escrow/epoch stats protobuf bindings to include new fields. |
| inference-chain/x/inference/module/commands.go | Extends CLI settlement JSON parsing/mapping to include new fields. |
| inference-chain/x/inference/keeper/subnet_settlement.go | Includes new fields in settlement host stats hash computation. |
| inference-chain/x/inference/keeper/subnet_settlement_test.go | Updates settlement hashing test fixtures for new fields. |
| inference-chain/x/inference/keeper/subnet_host_stats.go | Aggregates new fields into SubnetHostEpochStatsMap and introduces aggregation into Participant.CurrentEpochStats. |
| inference-chain/x/inference/keeper/msg_server_settle_subnet_escrow.go | Applies new aggregation into participant CurrentEpochStats during settlement processing. |
| inference-chain/x/inference/keeper/msg_server_settle_subnet_escrow_test.go | Adds tests ensuring settlement updates CurrentEpochStats and subnet epoch stats map. |
| inference-chain/proto/inference/inference/subnet_settlement.proto | Adds new fields to settlement protobuf schema. |
| inference-chain/proto/inference/inference/subnet_escrow.proto | Adds new fields to escrow/epoch stats protobuf schema. |
| inference-chain/api/inference/inference/subnet_settlement.pulsar.go | Regenerated Pulsar fast-reflection code for new settlement fields. |
| inference-chain/api/inference/inference/subnet_escrow.pulsar.go | Regenerated Pulsar fast-reflection code for new escrow/epoch stats fields. |
inference-chain/x/inference/keeper/msg_server_settle_subnet_escrow.go
Outdated
Show resolved
Hide resolved
ea7b921 to
ed38664
Compare
3ae0f1c to
233c554
Compare
heitor-lassarote
left a comment
There was a problem hiding this comment.
LGTM, the only thing that I think would be nice in addition would be a Testermint test, but since validations are currently not working in E2E as expected, I think this may be skipped. In addition, testing some things such as missed requests will probably require some extra infra, which sounds out of scope for this. So I think, for now all is fine.
233c554 to
15e5d46
Compare
ed38664 to
7507b2c
Compare
|
Here are new state fields, and on update it will lead to immediate consensus splits and data corruption on live networks. @gmorgachev How adding fields is supposed to be handled in subnets? It is not binded to block height of the mainnet |
|
Threads subnet Must fix
Should fix
Nits
|
akup
left a comment
There was a problem hiding this comment.
Should handle votes duplication, order-dependent ++/--, overflows checks
You mean in the updates of |
7507b2c to
458c54e
Compare
We want to integrate subnets' stats into the mainnet's host stats (see `CurrentEpochStats`). However, mainnet currently tracks the total inference count and validated inferences for hosts, and these stats are used to calculate the host's inactivity status and punishments at the of the epoch. This commit changes subnet's so that they now also track those 2 stats.
…in `MsgSettleSubnetEscrow` When the chain receives a settlement json from a subnet, it should parse these 2 new fields, and then add them to `MsgSettleSubnetEscrow.HostStats`
…entEpochStats` and `SubnetHostEpochStats` The inference chain keeps track of host stats in `CurrentEpochStats`, and of subnet-related stats in `SubnetHostEpochStats`. `SubnetHostEpochStats` are only for audit/debugging purposes, but the `CurrentEpochStats` stats are later used to calculate the hosts' inactivity status (see `status.go`) and punishments at the end of the epoch (see `accountsettle.go` and `bitcoin_rewards.go`) This commit adds the subnet's `InferenceCount` and `Validated` to both stats aggregations.
458c54e to
5e77938
Compare
14122ea to
26b7ffe
Compare
CurrentEpochStatsdevshards stats with CurrentEpochStats
In this PR: when a subnet is settled, we take the subnet's
HostStatsand merge them with theparticipant.CurrentEpochStats.NOTE:
participant.CurrentEpochStatskeeps track of the total number of inferences performed (InferenceCount) and the number of successfully validated inferences (Validated). Subnets were not keeping track of these 2 stats, so we had to alter the subnet to start doing that and include those stats in the settlement.Since the subnet's stats are now merged into
participant.CurrentEpochStats, they will automatically be taken into account when:WorkCoins/RewardCoins(seebitcoin_rewards.go)status.go->ComputeStatus)