Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Empty value of entity after writing with .save() and reading with ::find() #1518

Open
chlenc opened this issue Dec 15, 2023 · 0 comments
Open

Comments

@chlenc
Copy link

chlenc commented Dec 15, 2023

empty value of entity after writing with .save() and reading with ::find()

in that case, AccountBalanceChangeEventsBatch contains only 1 value of 5
We have a very important value in our contracts called open_interest, it is calculated by the formula open_interest = open_interest - abs(old_account_balance.taker_open_notional) + abs(account_balance.taker_open_notional)

image
image

(if account_balance and position are the same thing)

to calculate this value I used OpenInterestEntity::find(OpenInterestEntity::id().eq(open_interest_id.clone())) in account_balance_change_event_handler, but judging by the logs it returned a zero value of OpenInterestEntity when it was not zero, please tell me what can be the matter here.

image

more logs are here
looks like getting the order by ID returns a zero value
because we are saving value 21074050192 and straight after that we see open_interest_entity isn't None, but value 0 after unwrap
image
image

Just for the sake of sanity, could you print
open_interest_entity.save()
info!("{open_interest_entity}");
info!("{}", OpenInterestEntity::find(OpenInterestEntity::id().eq(open_interest_entity.id.clone()).unwrap());
That is, save, print, lookup, print.
This way we’d know if it was saved properly.

image
image
image

The id and market are correct, though. So, it finds a value, but the value has OI zero, just after .save() and even on the next tx handler

My toolchain

Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup

installed toolchains
--------------------
latest-aarch64-apple-darwin (default)
beta-4-aarch64-apple-darwin
latest-2023-11-15-aarch64-apple-darwin
my-custom-toolchain

active toolchain
-----------------
latest-aarch64-apple-darwin (default)
  forc : 0.46.1
    - forc-client
      - forc-deploy : 0.46.1
      - forc-run : 0.46.1
    - forc-doc : 0.46.1
    - forc-explore : 0.28.1
    - forc-fmt : 0.46.1
    - forc-index : 0.24.3
    - forc-lsp : 0.46.1
    - forc-tx : 0.46.1
    - forc-wallet : 0.3.0
  fuel-core : 0.20.5
  fuel-core-keygen : Error getting version string
  fuel-indexer : 0.24.3

fuels versions
---------------
forc : 0.45
forc-wallet : 0.45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant