Skip to content

Conversation

@guidiaz
Copy link
Contributor

@guidiaz guidiaz commented Dec 9, 2025

No description provided.

@guidiaz guidiaz changed the title feat(chain_manager): cache blocks minted and rewards since last time … feat(chain_manager): improve and protect getSupplyInfo* methods Dec 16, 2025
@guidiaz guidiaz changed the title feat(chain_manager): improve and protect getSupplyInfo* methods feat(json_rpc): improve and protect getSupplyInfo* methods Dec 16, 2025
@guidiaz guidiaz requested review from aesedepece and drcpu-github and removed request for aesedepece December 16, 2025 17:57
@guidiaz guidiaz force-pushed the json_rpc/improve_get_supply_info_2 branch from 8d7e117 to 2744cb3 Compare December 19, 2025 09:40
Copy link
Collaborator

@drcpu-github drcpu-github left a comment

Choose a reason for hiding this comment

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

I have not actually tested this branch, just added some questions based on a quick read through the code.

let mut stream = start_client(addr)?;

let request = r#"{"jsonrpc": "2.0","method": "getSupplyInfo", "id": "1"}"#;
let request = r#"{"jsonrpc": "2.0","method": "getSupplyInfo2", "id": "1"}"#;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for completely replacing getSupplyInfo with getSupplyInfo2 in the CLI (instead of keeping both as functions)? I think it's kind of confusing the get_supply_info function here aliases to getSupplyInfo2 instead of both being present.

Copy link
Contributor Author

@guidiaz guidiaz Dec 21, 2025

Choose a reason for hiding this comment

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

Not really. Both getSupplyInfo and getSupplyInfo2 commands will be supported in the CLI. However the getSupplyInfo will return non-sensitive fields in the new SupplyInfo struct from now on.

let mut stream = start_client(addr)?;

let request = r#"{"jsonrpc": "2.0","method": "getSupplyInfo", "id": "1"}"#;
let request = r#"{"jsonrpc": "2.0","method": "getSupplyInfo2", "id": "1"}"#;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for replacing getSupplyInfo with getSupplyInfo instead of keeping both as separate functions? I think it's kind of confusing that get_supply_info aliases internally to getSupplyInfo2. I suppose getSupplyInfo is still accessible through the raw interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. There will be separated functions for each case.

initial_supply: u64,
/// Populate RAD hashes index
rad_hashes_index: bool,
/// Epoch when getSupplyInfo2 was last resolved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose these variables are not saved to storage (and we do not need storage migrations)? That does imply whenever a node restarts (after a manual intervention or crash), this call will be slow again for the first time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed.

} else {
blocks_missing += 1;
blocks_missing_reward += block_reward;
blocks_minted_reward += if wit2_activated && epoch >= wit2_activation_epoch {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a point to this double check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first time the blocks_minted_reward is computed after a node restart, self.last_supply_info_epoch will certainly be less than wit2_activation_epoch. However, I guess the loop can be optimized depending on whether self.last_supply_info_epoch is already greater than wit2_activation_epoch, or not.

@guidiaz guidiaz mentioned this pull request Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants