Skip to content

Conversation

@vgorkavenko
Copy link
Contributor

@vgorkavenko vgorkavenko commented Oct 17, 2025

Description

Separate Performance Collection module for CSMv3 and CMv2 Oracle daemons
https://hackmd.io/OkdagPjpTYKm7yN9sqHGhA?both

Related Issue/Task

  • Related task: #[task number]
  • Epic: [epic name or link, if applicable]

How Has This Been Tested?

Describe how you tested the changes:

  • Local tests (e.g., pytest)
  • Manual testing (describe steps)
  • Not tested (explain why)

Checklist

  • Documentation updated (if required)
  • New tests added (if applicable)
  • CSM_STATE_VERSION is bumped (if the new version affects data in the cache)

@vgorkavenko vgorkavenko added the wip Work In Progress label Oct 17, 2025
@vgorkavenko vgorkavenko changed the base branch from develop to csm-next October 21, 2025 08:47
@vgorkavenko vgorkavenko changed the title [WIP] [CMv2 | CSMv3] feat: separate performance collection and distribution [WIP] feat: separate performance collection and distribution Oct 21, 2025
"total_validators": len(validators)
})

for l_epoch, r_epoch in self.state.frames:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to understand that self.state.frames is not empty?
I mean, looks like fulfill_state need some pre-requirments before run. If yes - better to check this requirments and drop exceptions if the requirements are not met.

})

for epoch in sequence(l_epoch, r_epoch):
if epoch not in self.state.unprocessed_epochs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here

if epoch_data is None:
raise ValueError(f"Epoch {epoch} is missing in Performance Collector")

misses, props_vids, props_flags, syncs_vids, syncs_misses = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add types here

if is_pivot_missing:
br[pivot_index] = None

logger.debug({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.debug({
logger.info({

maybe

sync_bits = hex_bitvector_to_list(sync_aggregate.sync_committee_bits)
for index_in_committee in get_set_indices(sync_bits):
committee[index_in_committee].included = True
# Go through only UNSET indexes to get misses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should answer "why", not "what". Code represents "what" by itself.

present_duties = session.exec(
select(Duty.epoch).where(Duty.epoch >= l_epoch, Duty.epoch <= r_epoch).order_by(Duty.epoch)
).all()
present = [int(epoch) for epoch in present_duties]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

present could be set. if epoch not in present is not optimal so much if present is list.

db: DutiesDB = Depends(get_db),
):
await validate_epoch_bounds(from_epoch, to_epoch)
return bool(db.is_range_available(from_epoch, to_epoch))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use async view, your queries to DB must be async as well, or you will block event loop.

Remove async from views, or add async/await to DutiesDB methods.

_db_instance: Optional[DutiesDB] = None


async def get_db() -> DutiesDB:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probability of race condition here. As i understand, the main approach in fastapi for this is using lifespan function.


@app.get("/epochs", response_model=list[Duty])
async def epochs_data(
from_epoch: EpochNumber = Query(..., alias="from"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need limits on from/to + timeouts


uvicorn.run(
app,
host="0.0.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to env?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMv2 CSMv3 wip Work In Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants