Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdaPot implementation #192

Merged
merged 74 commits into from
Nov 4, 2024
Merged

AdaPot implementation #192

merged 74 commits into from
Nov 4, 2024

Conversation

satran004
Copy link
Member

@satran004 satran004 commented Feb 4, 2024

#101

Capture following balances

  • Total deposits
  • Total utxo balance
  • Treasury (Done: Shelley to Babbage)
  • Reserves (Done: Shelley to Babbage)

Related tasks

  • Split reward table to reward (for member, leader, refund) and instant_reward (other rewards)
  • Split adapot table to adapot (to keep adapot at epoch boundary) and adapot_history (for real-time data like deposits, utxos etc)
  • Implement logic to fetch getSharedPoolRewardAddressesWithoutReward method
  • Tests
  • Test setup with Yaci DevKit
  • Verify Conway era specific changes which need to be considered for reward calculation (Drep, gov action deposits)
  • Verify and adjust reward table columns size
  • Refactor incremental fee aggregation per epoch to one-time fee snapshot
  • Refactor current instant_reward impl to instant_reward snapshot during epoch transition
  • Fix incorrect epoch param ([Epoch Store] Decentralization protocol param value in epoch 214 is not correct #307)
  • Add txIndex to all stake store tables (pool_registration, delegation etc). To fix incorrect delegated pool issue when a stake address delegates to two pools in two transactions, but same block. (Exp: stake1u84muf4xp84s2z3kqf3kmjdl430akjml00lts0xpx5mzlksm0xfq7 epoch: 229)
  • Handle PreEpochTransitionEvent when prevEpoch = null
  • Set the correct slots for records created during epoch transition events. (snapshots)
  • Pot transfer ?? reserves <--> treasury
  • Handle testnet stake address in reward account field of few pools (https://cardanoscan.io/pool/ae8ee8f5676a3c3aadefd0ee7adb57ebbd39dd7126c8517e718dc4c1)
  • Handle Pointer address during epoch_stake snapshot ([Reward] Handle the pointer address where the delegation part contains a pointer to the stake registration certificate. #340)
  • Sometime pool status is not updated correctly . Check pool `select * from pool where pool_id = '0f581255fdb8e8e88d3676a3cbede33e1f2456171cbe39266b3db679' epoch 235/237. Registration at epoch 235 is set as "Update".
  • Add jqwik tests
  • Add deposit column in stake_registration

@satran004 satran004 marked this pull request as draft February 4, 2024 15:39
…dded a debug log to output the deregistered stake address query, improving traceability.
Added support for processing transactions without collateral return in UtxoProcessor. Refactored tests to update the handling of spent and unspent UTXOs, including new test cases for scenarios with no collateral return.
Reorganize slot comparison conditions to prioritize `tx_index` over `cert_index` within stake registration queries. This ensures correct ordering and retrieval of stake registration data based on transaction and certificate indices.
Extended the JSON dataset with epochs 496 through 506. This update includes detailed financial data such as treasury, reserves, fees, deposits, and UTXO for each added epoch.
Added instructions to rollback to the last block of an epoch to ensure that stake address balance is calculated correctly. Updated SQL script to truncate and insert into `account_config` table accordingly.
Introduced reward calculation jobs related entities, services, and storage. Updated AdaPotProcessor to handle reward calculation on epoch transition and added SQL migrations for new tables.
…ssing

Removed deprecated SQL scripts related to reward calculation jobs. Refactored `RewardCalcJobEntity` to include detailed timing breakdowns and implemented retry logic in `RewardCalcJobManager`. Added `NetworkConfigService` for fetching network-specific configurations and updated to the latest `cf-rewards-calculation` library version.
Introduced a new configuration property to enable or disable address balance processing. The logic for saving address balances and cleaning up history is now conditionally executed based on this property. Updated the AutoConfiguration classes to support this new property.
Introduced rollback handling for reward and instant reward records with rollback events. Enhanced reward storage by integrating DSLContext for batch insertion to improve performance and maintain consistency. Removed unused methods and services to streamline the codebase, and added a new table `reward_calc_jobs` in database schemas.
Refactored AdaPot management with simplification and cleanup of handling deposits, fees, and UTXOs. Removed obsolete methods and fields from AdaPot-related classes and updated SQL schema accordingly.
Introduced a batching mechanism for updating rewards in the `EpochRewardCalculationService` to improve performance. Added new configuration properties and annotations to relevant classes to support this functionality.
Refactor RewardCalcJob related classes to AdaPotJob to generalize job management. Updated domain, storage, and service layers accordingly. Renamed `deposits` field in `AdaPot` to reflect new stake, drep, and proposal deposits.
This commit removes multiple unused or deprecated classes and cleans up the codebase for better maintainability. Removed classes include DelegatorStake, PoolDelegators, PoolStake, RewardAccount, RewardCalculation, SnapshotService, and others. Comments and temporary code were also cleaned up across various files.
Copy link

sonarcloud bot commented Nov 3, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.3% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@satran004 satran004 marked this pull request as ready for review November 3, 2024 15:00
@satran004 satran004 merged commit 0f82f31 into main Nov 4, 2024
2 of 3 checks passed
@satran004 satran004 deleted the adapot branch November 4, 2024 14:14
@matiwinnetou matiwinnetou changed the title AdaPot implementation (WIP) AdaPot implementation Nov 7, 2024
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