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

event data is wrong #4256

Closed
showlocked opened this issue Jan 21, 2025 · 15 comments
Closed

event data is wrong #4256

showlocked opened this issue Jan 21, 2025 · 15 comments
Labels
bug Something isn't working external

Comments

@showlocked
Copy link

Summary of Bug

I found a problem, I don't know if it is a bug, in one of our users' unstaking transactions, the balance recipient of the internal event does not correspond to the amount.
https://www.mintscan.io/celestia/tx/4E26D3E23C35125A9C9A9C848C701BF4DF871E9F8CB60D18C2679A921505905B?sector=json

Image

Image
This transaction should be receiving 324489887utia

Image

Image
But the actual amount receiver of the internal event is wrong.
We can think of the transfer event as a transfer transaction, so according to the screenshot I took, the transfer should be:
A transaction of 87 was sent to xxxqc84
A transaction of 324 was sent to xxyw4
This is a problem. The user did not add the balance back correctly after the delegate deducted 324.
This block data is like this:
[ { "key": "recipient", "value": "celestia1s0k4hxn3cuaz72e6qtmzk6xh30t6f7zx97qc84" }, { "key": "sender", "value": "celestia1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8k44vnj" }, { "key": "amount", "value": "87utia" }, { "key": "recipient", "value": "celestia1tygms3xhhs3yv487phx3dw4a95jn7t7ls3yw4w" }, { "key": "sender", "value": "celestia1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3y3clr6" }, { "key": "amount", "value": "324489887utia" } ]
in fact, it should be like this:
[ { "key": "recipient", "value": "celestia1s0k4hxn3cuaz72e6qtmzk6xh30t6f7zx97qc84" }, { "key": "sender", "value": "celestia1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8k44vnj" }, { "key": "amount", "value": "324489887utia" }, { "key": "recipient", "value": "celestia1tygms3xhhs3yv487phx3dw4a95jn7t7ls3yw4w" }, { "key": "sender", "value": "celestia1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3y3clr6" }, { "key": "amount", "value": "87utia" } ]

If the exchange supports this type of deposit and withdrawal event, it may cause asset losses

Version

current

Steps to Reproduce

i dont know

@showlocked showlocked added the bug Something isn't working label Jan 21, 2025
@Bidon15
Copy link
Member

Bidon15 commented Jan 21, 2025

Thanks for the bug report @showlocked - could you please share what products/apps are affected by this? This helps us prioritise the work a lot

@rootulp rootulp changed the title evnet data is wrong event data is wrong Jan 21, 2025
@showlocked
Copy link
Author

this wallet balance is wrong, and another wallet may be

@showlocked
Copy link
Author

Image

@mindstyle85
Copy link

i dont know how mintscan works in terms of showing transactions (ill ping them here as well), but to me it looks all fine except that output, the balances in the end are correct.

see:
https://celenium.io/address/celestia1s0k4hxn3cuaz72e6qtmzk6xh30t6f7zx97qc84?tab=transactions
https://celenium.io/tx/4e26d3e23c35125a9c9a9c848c701bf4df871e9f8cb60d18c2679a921505905b?tab=events

and

https://celestia.explorers.guru/transaction/4E26D3E23C35125A9C9A9C848C701BF4DF871E9F8CB60D18C2679A921505905B?height=2957836

obviously the difference in the balance is that when you undelegate, the rewards get claimed as well but i assume thats not in question here

@showlocked
Copy link
Author

Yes, the balance is correct, but the event data is wrong. This is a serious error for developers who need to parse the event as a transfer transaction.

@mindstyle85
Copy link

hmm i see, i checked on our internal rpc and yeah the attributes seem that are correct, but not in correct order (never checked this on other cosmos networks if this part is always ordered or not)

  • attributes:
    • key: recipient
      value: celestia1s0k4hxn3cuaz72e6qtmzk6xh30t6f7zx97qc84
    • key: sender
      value: celestia1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8k44vnj
    • key: amount
      value: 87utia
    • key: recipient
      value: celestia1tygms3xhhs3yv487phx3dw4a95jn7t7ls3yw4w
    • key: sender
      value: celestia1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3y3clr6
    • key: amount
      value: 324489887utia
      type: transfer

@showlocked
Copy link
Author

Yes, if there is an exchange that supports deposits and withdrawals for this kind of transaction, it will lead to asset losses. Please fix it as soon as possible.

@rootulp
Copy link
Collaborator

rootulp commented Jan 21, 2025

I've re-read this issue a few times but I still don't understand the issue.

But the actual amount receiver of the internal event is wrong.

Can you clarify this?

A transaction of 324 was sent to xxyw4

You meant 324489887 utia not 324. The full address is https://www.mintscan.io/celestia/address/celestia1tygms3xhhs3yv487phx3dw4a95jn7t7ls3yw4w which is the not bonded tokens pool. It is expected behavior for tokens to go there as a result of the undelegate transaction.

A transaction of 87 was sent to xxxqc84

This amount is associated withdrawing rewards.

This is a problem. The user did not add the balance back correctly after the delegate deducted 324.

After a user undelegates, they must wait the unbonding period. After the unbonding period, the tokens will move from the not bonded token pool to the user's account. Ref: https://docs.cosmos.network/v0.45/modules/staking/02_state_transitions.html#complete-unbonding

Yes, if there is an exchange that supports deposits and withdrawals for this kind of transaction, it will lead to asset losses.

Based on the OP, I don't think there's a bug in the event attributes. Exchanges shouldn't treat events as the source of truth and instead should query the state of the blockchain.

If you still think there is a bug, can you clarify where? It would also help if you included minimal steps to repro.

@showlocked
Copy link
Author

Image In this event and the transfer event, shouldn't celestia1s0k4hxn3cuaz72e6qtmzk6xh30t6f7zx97qc84 receive the transfer from 324489887utia?

@showlocked
Copy link
Author

What I mean is that the positions of 87utia and 324489887utia are reversed, which causes the transfer amount to be reversed when we parse it.

@showlocked
Copy link
Author

We can compare it with a normal transfer event, and you will find that the amount of the internal transfer event of this pledge transaction is wrong.

@evan-forbes
Copy link
Member

evan-forbes commented Jan 22, 2025

a normal transfer event

isn't the tx in the op from an undelegation?

when undelegating, the funds don't go back to the user, they go to some module address, which is what is happening in the events

the state machine is "transfering" funds to a module address

@showlocked
Copy link
Author

Shouldn't the transfer event in Cosmos be a standard? The transfer event of the address celestia1s0k4hxn3cuaz72e6qtmzk6xh30t6f7zx97qc84 does not correspond to the balance change.

@evan-forbes
Copy link
Member

Shouldn't the transfer event in Cosmos be a standard?

In this event and the transfer event, shouldn't celestia1s0k4hxn3cuaz72e6qtmzk6xh30t6f7zx97qc84 receive the transfer from 324489887utia?

funds aren't being transfered to that address, cause its an undelegation, which has an unbonding period. undelegation involves the movement of funds in the state machine, but its not how you describe. The entry point is here https://github.com/celestiaorg/cosmos-sdk/blob/d1d32585feeac12f875f569c6d5086f1163c010c/x/staking/keeper/msg_server.go#L336 . It will take some digging to understand it, but ask an llm to walk you through it.

also, we don't touch the staking or bank modules, so if this is a bug, its a bug in every v0.46.x cosmos-sdk chain and the best place to ask is there.

@evan-forbes
Copy link
Member

🙂

thanks for opening an issue @showlocked, but this isn't a bug afaict.

@rootulp rootulp closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external
Projects
None yet
Development

No branches or pull requests

5 participants