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

0.4.1 update breaks the code #888

Closed
slumber opened this issue Dec 10, 2020 · 0 comments
Closed

0.4.1 update breaks the code #888

slumber opened this issue Dec 10, 2020 · 0 comments

Comments

@slumber
Copy link
Contributor

slumber commented Dec 10, 2020

Hi!
Trying to update sqlx to 0.4.1 somehow breaks the interaction with decimals. The relevant code is here https://github.com/matter-labs/zksync/blob/master/core/lib/storage/src/chain/state/mod.rs#L172
This function basically collects updates and applies them, the problem comes with balances updating, please, take a look at the logs (I queried balances table before the insert and after)

[2020-12-09T20:37:27Z DEBUG zksync_storage::chain::state] Balances before apply_state_update: []
[2020-12-09T20:37:27Z DEBUG zksync_storage::chain::state] Sorted account update list: [
    BalanceUpdate(StorageAccountUpdate { balance_update_id: 1, account_id: 1, block_number: 1, coin_id: 0, old_balance: BigDecimal("0"), new_balance: BigDecimal("2000000000000000000000"), old_nonce: 0, new_nonce: 0, update_order_id: 1 }),
    BalanceUpdate(StorageAccountUpdate { balance_update_id: 2, account_id: 1, block_number: 1, coin_id: 0, old_balance: BigDecimal("2000000000000000000000"), new_balance: BigDecimal("1999999968700000000000"), old_nonce: 1, new_nonce: 1, update_order_id: 3 }),
    BalanceUpdate(StorageAccountUpdate { balance_update_id: 3, account_id: 1, block_number: 1, coin_id: 0, old_balance: BigDecimal("1999999968700000000000"), new_balance: BigDecimal("1989999937400000000000"), old_nonce: 1, new_nonce: 2, update_order_id: 5 }), 
    BalanceUpdate(StorageAccountUpdate { balance_update_id: 4, account_id: 2, block_number: 1, coin_id: 0, old_balance: BigDecimal("0"), new_balance: BigDecimal("10000000000000000000"), old_nonce: 0, new_nonce: 0, update_order_id: 6 }), 
    BalanceUpdate(StorageAccountUpdate { balance_update_id: 5, account_id: 0, block_number: 1, coin_id: 0, old_balance: BigDecimal("0"), new_balance: BigDecimal("31300000000000"), old_nonce: 0, new_nonce: 0, update_order_id: 7 }), 
    BalanceUpdate(StorageAccountUpdate { balance_update_id: 6, account_id: 0, block_number: 1, coin_id: 0, old_balance: BigDecimal("31300000000000"), new_balance: BigDecimal("62600000000000"), old_nonce: 0, new_nonce: 0, update_order_id: 8 })]
[2020-12-09T20:37:27Z DEBUG zksync_storage::chain::state] Balances after apply_state_update: [
    StorageBalance { account_id: 1, coin_id: 0, balance: BigDecimal("19899999374000") }, 
    StorageBalance { account_id: 2, coin_id: 0, balance: BigDecimal("1000") }, 
    StorageBalance { account_id: 0, coin_id: 0, balance: BigDecimal("626000") }]

You can clearly tell that the values got corrupted. Thanks to @mehcode I found the commit causing this mess
a0007b4

UPDATE: I'm sorry, the bug was present, but the PR introduced new one, still trying to figure things out.

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

No branches or pull requests

1 participant