Closed TimmyExogenous closed 2 weeks ago
The changes involve significant updates across multiple files in the Exocore project, addressing both enhancements and refactoring. Specifically, they introduce new message and RPC types for querying operator and AVS financial information, update methods for handling undelegations, and enhance slashing functionality. Additionally, the changes include cleanups and reordering of fields in protos, and various code refactors to improve functionality and maintainability.
Files | Change Summary |
---|---|
proto/.../delegation/v1/query.proto |
Added new messages and RPCs for querying undelegations by staker ID, asset ID, and block height. |
proto/.../operator/v1/query.proto |
Introduced new messages and updated RPCs for querying operator and AVS USD value, and handling slash information. |
proto/.../operator/v1/tx.proto |
New message types for slashing events and execution information. |
x/assets/keeper/operator_asset.go |
Added isUpdate parameter to IteratorAssetsForOperator function. |
x/avs/keeper/avs_test.go |
Cleanups and comment adjustments in test functions. |
x/delegation/client/cli/query.go |
Added functions for querying undelegations in CLI. |
x/delegation/keeper/grpc_query.go |
Added new query functions for undelegations by various criteria. |
x/operator/client/cli/query.go |
Added functions for querying operator and AVS info in CLI. |
x/operator/keeper/abci.go |
Refactored USD value calculation method for operators. |
x/operator/keeper/grpc_query.go |
Introduced functions for querying operator and AVS USD values and slash information. |
x/operator/keeper/keeper.go |
Replaced and added new slashing-related functions and updated imports. |
x/operator/keeper/operator_slash_state.go |
Refactored function for updating operator slash info and added a new function for retrieving all slash info. |
x/operator/keeper/opt.go |
Updated comment about operator rewards. |
x/operator/keeper/opt_test.go |
Added error logging and refactored TestOptOut function. |
x/operator/keeper/slash.go |
Refactored and added functions for various slashing operations, including handling dogfood module. |
x/operator/keeper/slash_test.go |
New test file introduced to test slashing with infraction reasons. |
x/assets/types/keys.go |
Added function to generate joined store key with a trailing slash. |
sequenceDiagram
participant CLI
participant Keeper
participant AssetsModule
participant ABCIModule
participant GrpcServer
CLI ->> GrpcServer: QueryOperatorUSDValue
GrpcServer ->> Keeper: QueryOperatorUSDValue
Keeper ->> AssetsModule: FetchAssetPrices
AssetsModule -->> Keeper: AssetPrices
Keeper ->> GrpcServer: OperatorUSDValueResponse
GrpcServer -->> CLI: USD Value
CLI ->> GrpcServer: QueryAVSUSDValue
GrpcServer ->> Keeper: QueryAVSUSDValue
Keeper ->> AssetsModule: FetchAssetPrices for AVS
AssetsModule -->> Keeper: AssetPrices
Keeper ->> GrpcServer: AVSUSDValueResponse
GrpcServer -->> CLI: AVS USD Value
CLI ->> GrpcServer: QueryOperatorSlashInfo
GrpcServer ->> Keeper: QueryOperatorSlashInfo
Keeper ->> ABCIModule: GetSlashInfo
ABCIModule -->> Keeper: SlashInfo
Keeper ->> GrpcServer: SlashInfoResponse
GrpcServer -->> CLI: Slash Info
In fields and code where rabbits hop, New queries and slashes make the data pop. 🐇 Values of dollars, now clear in sight, Operators, AVS, all set right. Let's cheer for changes, oh so grand, Our code improved, across the land! 🎉
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@TimmyExogenous could you resolve the conflicts?
Test object: https://github.com/ExocoreNetwork/exocore/pull/61/commits/10e1ac976f2f4a9235f98902067f1228e2de3506 Undelegate part of the amount of delegation for the slashed operator seems incorrect.
Steps:
slash_fraction_downtime
as default value 0.010000000000000000
0xdac17f958d2ee523a2206206994597c13d831ec7_0x65:
operator_amount: "0"
operator_share: "0.000000000000000000"
operator_unbonding_amount: "0"
total_amount: "99"
total_share: "100.000000000000000000"
wait_unbonding_amount: "0"
Operator assets
0xdac17f958d2ee523a2206206994597c13d831ec7_0x65:
operator_amount: "0"
operator_share: "0.000000000000000000"
operator_unbonding_amount: "0"
total_amount: "10"
total_share: "9.090909090909090910"
wait_unbonding_amount: "89"
Staker assets:
exocored query assets QueStakerAssetInfos 0xc6E1c84c2Fdc8EF1747512Cda73AaC7d338906ac_0x65
asset_infos:
0xdac17f958d2ee523a2206206994597c13d831ec7_0x65:
total_deposit_amount: "100"
wait_unbonding_amount: "0"
withdrawable_amount: "89"
Test object: 10e1ac9 Undelegate part of the amount of delegation for the slashed operator seems incorrect.
Steps:
- Start a single operator consensus, with
slash_fraction_downtime
as default value0.010000000000000000
- Register a new operator and staker delegate 100 tokens with decimal as 0 ( 0xdac17f958d2ee523a2206206994597c13d831ec7_0x65).
- Turn off the new operator (the operator addr is exo10zkthkjkx7fwknhq90srqrw9mu2j58cz635gxr)and wait for slashing to take effect.
- Check the operator assets, the operator assets is slashed.
0xdac17f958d2ee523a2206206994597c13d831ec7_0x65: operator_amount: "0" operator_share: "0.000000000000000000" operator_unbonding_amount: "0" total_amount: "99" total_share: "100.000000000000000000" wait_unbonding_amount: "0"
- Undelegate 90 tokens from the slashed operator. Check the operator assets and staker assets.
Operator assets
0xdac17f958d2ee523a2206206994597c13d831ec7_0x65: operator_amount: "0" operator_share: "0.000000000000000000" operator_unbonding_amount: "0" total_amount: "10" total_share: "9.090909090909090910" wait_unbonding_amount: "89"
Staker assets:
exocored query assets QueStakerAssetInfos 0xc6E1c84c2Fdc8EF1747512Cda73AaC7d338906ac_0x65 asset_infos: 0xdac17f958d2ee523a2206206994597c13d831ec7_0x65: total_deposit_amount: "100" wait_unbonding_amount: "0" withdrawable_amount: "89"
Even though the wait_unbonding_amount not exactly same with the undelegation amount input, it ends up with the correct amount 99 after several times undelegation. so it is issue here.
All test scenarioes passed.
Test QueryUndelegations
and QueryUndelegationsByHeight
function passed.
exocored query delegation QueryUndelegations 0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x65 0xdAC17F958D2ee523a2206206994597C13D831ec7_0x65
undelegations:
- actual_completed_amount: "10"
amount: "10"
asset_id: 0xdac17f958d2ee523a2206206994597c13d831ec7_0x65
block_number: "1827"
complete_block_number: "1837"
is_pending: true
lz_tx_nonce: "0"
operator_addr: exo1u8yx7e02wr2yvs5zk3zhvehhekh4vzxdr6sv2x
staker_id: 0xa53f68563d22eb0dafaa871b6c08a6852f91d627_0x65
tx_hash: 0x0a54e26e182d10eddf792d9cb9c05770ea8f77d6a8fce2388bb14a9727981b6e
exocored query delegation QueryUndelegationsByHeight 1837
undelegations:
- actual_completed_amount: "10"
amount: "10"
asset_id: 0xdac17f958d2ee523a2206206994597c13d831ec7_0x65
block_number: "1827"
complete_block_number: "1837"
is_pending: true
lz_tx_nonce: "0"
operator_addr: exo1u8yx7e02wr2yvs5zk3zhvehhekh4vzxdr6sv2x
staker_id: 0xa53f68563d22eb0dafaa871b6c08a6852f91d627_0x65
tx_hash: 0x0a54e26e182d10eddf792d9cb9c05770ea8f77d6a8fce2388bb14a9727981b6e
Please resolve all comments from @MaxMustermann2 and me and good to merge
Testing querying capabilities for operator and AVS USD values, please hold on the merge.
Test passed with querying USD value, commit: https://github.com/ExocoreNetwork/exocore/pull/61/commits/be3b8e5322a63dae4a2fdbb20d21b6e4be439f6c
before slash:
exocored q operator QueryOperatorUSDValue exo1u8yx7e02wr2yvs5zk3zhvehhekh4vzxdr6sv2x exocoretestnet_233-2
amount: "1000.000000000000000000"
after slash:
exocored q operator QueryOperatorUSDValue exo1u8yx7e02wr2yvs5zk3zhvehhekh4vzxdr6sv2x exocoretestnet_233-2
amount: "990.000000000000000000"
exocored q operator QueryOperatorSlashInfo exo1u8yx7e02wr2yvs5zk3zhvehhekh4vzxdr6sv2x exocoretestnet_233-2
all_slash_info:
- info:
event_height: "702"
execution_info:
slash_assets_pool:
- amount: "10"
asset_id: 0xdac17f958d2ee523a2206206994597c13d831ec7_0x65
slash_proportion: "0.010000000000000000"
slash_undelegations: []
slash_value: "10.000000000000000000"
is_vetoed: false
slash_contract: ""
slash_proportion: "0.010000000000000000"
slash_type: 2
submitted_height: "704"
slash_id: 0x2/0x2be
pagination:
next_key: null
total: "1"
Description
This PR implements the new slash design except for the voting power snapshot according to the above documentation: slash design
The historical voting power for dogfood is provided by
cometbft
. Additionally, this PR adds the missed RPC and CLI to query the undelegations and USD values.todo
Summary by CodeRabbit
New Features
Refactor
Keeper
struct with additional query methods for detailed operator and AVS data.Tests