joshstevens19 / rindexer

A no-code blazing fast EVM indexer tool built in rust.
https://rindexer.xyz
MIT License
267 stars 24 forks source link

Compile error on `rindexer start all` #54

Closed plotchy closed 1 month ago

plotchy commented 1 month ago
Compiling rindexer v0.1.0 (https://github.com/joshstevens19/rindexer?branch=master#32954964)
error[E0716]: temporary value dropped while borrowed
   --> /Users/plotchy/.cargo/git/checkouts/rindexer-f61b405ecaec220a/3295496/core/src/indexer/fetch_logs.rs:491:24
    |
490 |     let error_data = match &error.data {
    |         ---------- borrow later stored here
491 |         Some(data) => &data.to_string(),
    |                        ^^^^^^^^^^^^^^^-
    |                        |              |
    |                        |              temporary value is freed at the end of this statement
    |                        creates a temporary value which is freed while still in use
    |
help: consider using a `let` binding to create a longer lived value
    |
490 ~     let binding = data.to_string();
491 ~     let error_data = match &error.data {
492 ~         Some(data) => &binding,
    |

error[E0716]: temporary value dropped while borrowed
   --> /Users/plotchy/.cargo/git/checkouts/rindexer-f61b405ecaec220a/3295496/core/src/indexer/fetch_logs.rs:492:18
    |
490 |     let error_data = match &error.data {
    |         ---------- borrow later stored here
491 |         Some(data) => &data.to_string(),
492 |         None => &String::from(""),
    |                  ^^^^^^^^^^^^^^^-
    |                  |              |
    |                  |              temporary value is freed at the end of this statement
    |                  creates a temporary value which is freed while still in use
    |
help: consider using a `let` binding to create a longer lived value
    |
490 ~     let binding = String::from("");
491 ~     let error_data = match &error.data {
492 |         Some(data) => &data.to_string(),
493 ~         None => &binding,
    |

For more information about this error, try `rustc --explain E0716`.
error: could not compile `rindexer` (lib) due to 2 previous errors
=== Start Of Custom rindexer unhandled panic hook - please supply this information on the github issue if it happens ===
Panic occurred in file 'cli/src/commands/start.rs' at line 173
Panic occurred but can't get the panic message...
Backtrace [{ fn: "std::backtrace::Backtrace::create" }, { fn: "rindexer_cli::set_panic_hook::{{closure}}::{{closure}}" }, { fn: "std::panicking::rust_panic_with_hook" }, { fn: "std::panicking::begin_panic_handler::{{closure}}" }, { fn: "std::sys_common::backtrace::__rust_end_short_backtrace" }, { fn: "_rust_begin_unwind" }, { fn: "core::panicking::panic_fmt" }, { fn: "rindexer_cli::main::{{closure}}" }, { fn: "tokio::runtime::park::CachedParkThread::block_on" }, { fn: "tokio::runtime::runtime::Runtime::block_on" }, { fn: "rindexer_cli::main" }, { fn: "std::sys_common::backtrace::__rust_begin_short_backtrace" }, { fn: "std::rt::lang_start::{{closure}}" }, { fn: "std::rt::lang_start_internal" }, { fn: "_main" }]
=== End Of Custom rindexer unhandled panic hook - please supply this information on the github issue if it happens ===
joshstevens19 commented 1 month ago

Is this using no-code or rust project?

plotchy commented 1 month ago

rust project

plotchy commented 1 month ago

to be precise, i did rust project. then i didnt need the rETH things so i reworked the yaml, fixed the chainid u32 thing, and then regenerated typings and indexers for my new contract and event

joshstevens19 commented 1 month ago

Please give me exact steps to recreate and il take a look , please also share your rindexer.yaml

plotchy commented 1 month ago
❯ rindexer new rust
Initializing new rindexer project...
Project Name: kami
Project Description (skip by pressing Enter):
Repository (skip by pressing Enter):
What Storages To Enable? (graphql can only be supported if postgres is enabled) [postgres, csv, both, none]: postgres
Postgres Docker Support Out The Box? [yes, no]: yes
Successfully generated rindexer rust project.
rindexer rust project created with a rETH transfer events YAML template.
 cd ./kami
- use rindexer codegen commands to regenerate the code
- run `rindexer start all` to start rindexer
- run `rindexer add contract` to add new contracts to your project

cd kami

add in World.abi.json to /abis replace rindexer.yaml with provided one delete RocketTokenRETH.abi.json

https://gist.github.com/plotchy/1b9e03bd2c8bc478b38ce1e471baa486

plotchy commented 1 month ago

then i changed Network to take u64 for chain

pub struct Network {
    pub name: String,

    pub chain_id: u64,

    pub rpc: String,

    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub compute_units_per_second: Option<u64>,
}
//handle_add_contract_command
let networks: Vec<(&str, u64)> =
        manifest.networks.iter().map(|network| (network.name.as_str(), network.chain_id)).collect();

rebuilt this with make prod_build and started using new binary

then ran into the issue above, and used this fix

// retry_with_block_range
    let error_data_binding = error.data.as_ref().map(|data| data.to_string());
    let empty_string = String::from("");
    let error_data = match &error_data_binding {
        Some(data) => data,
        None => &empty_string,
    };

changed Cargo.toml to point to the local patch in core

rindexer = { path = "../../../packages/rindexer/core" }

Then deleted /typings and /indexers from kami project. ran rindexer codegen typings and rindexer codegen indexer

run rindexer start all now have an issue with event arg bindings being different. looks like an underscore is added somewhere

❯ rindexer2 start all       
   Compiling kami v0.1.0 (/Users/plotchy/code/projects/kami-rs/kami)
error[E0609]: no field `arg0` on type `ComponentValueSetFilter`
  --> src/rindexer_lib/indexers/kami/world.rs:27:151
   |
27 | ...   let data = vec![EthereumSqlTypeWrapper::Address(result.tx_information.address),EthereumSqlTypeWrapper::U256(result.event_data.arg0),EthereumSqlTypeWrapper::Address(result.event_data.arg1),Eth...
   |                                                                                                                                     ^^^^ unknown field
   |
help: a field with a similar name exists
   |
27 |                         let data = vec![EthereumSqlTypeWrapper::Address(result.tx_information.address),EthereumSqlTypeWrapper::U256(result.event_data.arg_0),EthereumSqlTypeWrapper::Address(result.event_data.arg1),EthereumSqlTypeWrapper::U256(result.event_data.arg2),EthereumSqlTypeWrapper::Bytes(result.event_data.arg3),EthereumSqlTypeWrapper::H256(result.tx_information.transaction_hash),EthereumSqlTypeWrapper::U64(result.tx_information.block_number),EthereumSqlTypeWrapper::H256(result.tx_information.block_hash),EthereumSqlTypeWrapper::String(result.tx_information.network.to_string()),EthereumSqlTypeWrapper::U64(result.tx_information.transaction_index),EthereumSqlTypeWrapper::U256(result.tx_information.log_index)];;
   |                                                                                                                                                       ~~~~~
andrii-kl commented 1 month ago

I have the same issue when I try to build the project.

cargo build

Compiling postgres-native-tls v0.5.0 Compiling rindexer v0.1.0 (/Users/anymac/projects/web3j/rindexer/core) error[E0716]: temporary value dropped while borrowed --> core/src/indexer/fetch_logs.rs:491:24 490 let error_data = match &error.data { ---------- borrow later stored here 491 Some(data) => &data.to_string(), ^^^^^^^^^^^^^^^-
temporary value is freed at the end of this statement
creates a temporary value which is freed while still in use
help: consider using a let binding to create a longer lived value 490 ~ let binding = data.to_string(); 491 ~ let error_data = match &error.data { 492 ~ Some(data) => &binding,
error[E0716]: temporary value dropped while borrowed --> core/src/indexer/fetch_logs.rs:492:18 490 let error_data = match &error.data { ---------- borrow later stored here 491 Some(data) => &data.to_string(), 492 None => &String::from(""), ^^^^^^^^^^^^^^^-
temporary value is freed at the end of this statement
creates a temporary value which is freed while still in use
help: consider using a let binding to create a longer lived value 490 ~ let binding = String::from(""); 491 ~ let error_data = match &error.data { 492 Some(data) => &data.to_string(), 493 ~ None => &binding,

For more information about this error, try rustc --explain E0716. error: could not compile rindexer (lib) due to 2 previous errors

joshstevens19 commented 1 month ago

https://github.com/joshstevens19/rindexer/commit/9d2475fed3f982b1024fcb638c48b5eb3d255787 will deploy these fixes 3 different ones in here

joshstevens19 commented 1 month ago

https://github.com/joshstevens19/rindexer/pull/58 - rindexerup will get the latest one

plotchy commented 1 month ago

Nice! 😊👍