dojoengine / dojo

Dojo is a toolchain for building provable games and autonomous worlds with Cairo
https://dojoengine.org
Apache License 2.0
408 stars 166 forks source link

[torii] ERC721 indexing #2517

Open notV4l opened 3 hours ago

notV4l commented 3 hours ago

Describe the bug

2024-10-10T15:07:46.602207Z  INFO torii_core::engine: Processed block. block_number=789980
2024-10-10T15:08:32.756005Z  INFO torii_core::engine: Processed block. block_number=789994
[crates/torii/core/src/executor.rs:582:17] &balance_diff = I256 {
    value: U256(
        Uint(0x0000000000000000000000000000000000000000000000000000000000000001),
    ),
    is_negative: true,
}
[crates/torii/core/src/executor.rs:582:17] balance = U256(
    Uint(0x0000000000000000000000000000000000000000000000000000000000000000),
)
[crates/torii/core/src/executor.rs:582:17] id = "0x5f5b57c7d6994587df7a39a04ba455ff6405e61809f673aa6e59582b3f2a262/0x7b696af58c967c1b14c9dde0ace001720635a660a8e90c565ea459345318b30:0x00000000000000000000000000000000000000000000000000000000000b68d1"
thread 'tokio-runtime-worker' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/subtle-2.6.1/src/lib.rs:701:9:
assertion `left == right` failed
  left: 0
 right: 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2024-10-10T15:08:33.291308Z ERROR torii_core::engine: Processing fetched data. error=channel closed
2024-10-10T15:08:34.828332Z  INFO torii_core::engine: Syncing reestablished.
2024-10-10T15:08:34.828358Z ERROR torii_core::engine: Processing fetched data. error=channel closed
2024-10-10T15:08:36.392078Z  INFO torii_core::engine: Syncing reestablished.

To Reproduce On mainnet indexing Blobert / LS / Ekubo positions

torii  -w 0x50c46c6f69ea9f12b24fcdd1569a584ae8893db0c70ea7884b605384da78ebc --contracts ERC721:0x00539f522b29ae9251dbf7443c7a950cf260372e69efab3710a11bf17a9599f1,ERC721:0x018108b32cea514a78ef1b0e4a0753e855cdf620bc0565202c02456f618c4dc4,ERC721:0x07b696af58c967c1b14c9dde0ace001720635a660a8e90c565ea459345318b30

Additional context alpha.15

akintewe commented 3 hours ago

Hello can i be assigned this issue

The bug seems to be related to an underflow condition when subtracting from a zero balance. The code is likely trying to prevent negative balances, but the check is failing because it's using a constant-time comparison (from the subtle crate) that's asserting equality when it should be asserting inequality (i.e., ensuring the balance doesn't go below zero).

lambda-0x commented 2 hours ago

i tried indexing just the contract which caused the issue but cannot seem to reproduce it: Screenshot 2024-10-10 at 17 06 28@2x Screenshot 2024-10-10 at 17 08 47@2x

can you please share the DB file of the run that you are seeing this error in so i can debug this further @notV4l