Assigned: Chainsight BNT-1 - Asset Rating Oracle

@furkan @timk11 @hude
Sorry for the delay in getting back to you. And thank you for your development with Chainsight.
I am one of the development members of Chainsight.

Chainsight is being developed on a daily basis, and there are some major structural changes that we would like to explain.
The latest Snapshot version of the CLI can be downloaded here.
This will be updated each time changes are merged into the main branch.

Currently, the Project package structure via the CLI looks like this sample.
The major change is that the user implementation and automatically generated code are separated into different cargo projects:


- src
  - logics ... User implementation to index/process data (the old `app.rs`)
  - bindings ... Generates interface types to use other canisters that the Component depends on.
  - accessors ... Generates functions for Lens to call other Canisters
  - canisters ... Logic is used to act as a chainsight component casniter on ICP

These directories and codes are automatically generated by the csx generate command based on the contents of chainsight manifest (project.yaml and components/*.yaml).
src/logics generates the implementation template only for the first time, after which the user is responsible for implementation.
The other directories are always regenerated by the csx generate command and synchronized with the manifest definition.

This is the end of the development flow changes. Thereafter, modules are built, deployed, and initialized by csx build, csx deploy, and csx exec as before.
The process for maintaining and running Cycle on IC has also been updated, but we will not go into that here, so please inquire again when you are ready to deploy on IC.

You may be currently facing problems with the old version, please update to the latest, and ask us if you have any questions.

Good luck with your development!

1 Like

Hi @darroze and thanks for the info!

I downloaded the snapshot and saved the extracted csx file in ./.cargo/bin, then installed it using

cargo build --bin csx
chmod a+x csx

Using csx generate I’m now getting this error:

ERRO [tcumul_28x6hr_usdceth_0_3] Failed: Generate interfaces (.did files) by:    Compiling tcumul_28x6hr_usdceth_0_3_canister v0.1.0 (/home/timk/ic/csx/uniswap_edpr/src/canisters/tcumul_28x6hr_usdceth_0_3)
error: proc macro panicked
 --> canisters/tcumul_28x6hr_usdceth_0_3/src/lib.rs:1:66
  |
1 | ... ; def_snapshot_indexer_evm_canister ! ("{\"common\":{\"canister_name\":\"tcumul_28x6hr_usdceth_0_3\"},\"method_identifier\":\"observe(uint32[]):(int56[],uint160[])\",\"method_args\":[[604800,583200,561600,540000,518400,496800,475200,453600,432000,410400,388800,367200,345600,324000,302400,280800,259200,237600,216000,194400,172800,151200,129600,108000,86400,64800,43200,21600,0]],\"abi_file_path\":\"./__interfaces/UniswapV3Pool.json\"}"...
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: Failed to parse method identifier: ic_solidity_bindgen::internal::Unimplemented

error: could not compile `tcumul_28x6hr_usdceth_0_3_canister` (lib test) due to previous error

The relevant part of the component yaml file looks like this:

datasource:
  type: contract
  location:
    id: 88e6a0c2ddd26feeb64f039a2c41296fcb3f5640
    args:
      network_id: 1
      rpc_url: https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}
  method:
    identifier: observe(uint32[]):(int56[],uint160[])
    interface: UniswapV3Pool.json
    args: [[604800, 583200, 561600, 540000, 518400, 496800, 475200, 453600, 432000, 410400, 388800, 367200, 345600, 324000, 302400, 280800, 259200, 237600, 216000, 194400, 172800, 151200, 129600, 108000, 86400, 64800, 43200, 21600, 0]]

UniswapV3Pool.json in my project is copied from the Contract ABI on this page and begins like this:

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"int24","name":"tickLower","type":"int24"},{"indexed":true,"internalType":"int24","name":"tickUpper","type":"int24"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},
...

What could be going wrong here?

1 Like

@timk11 Thank you for the update!
Could you share the entire Chainsight PJ code with us so we can investigate while reproducing it?

Sure! I’ve shared the code to GitHub - timk11/uniswap-edpr.

1 Like

I am getting an error in deploying
chainsight-management-canisters.

make local port=8000

note: port=${8000} is not reflected, so I add port := $(or $(port), $(PORT)) to the makefile and run it

Result:

Failed to invoke the package tool "vessel" "sources"

run:

cargo install vessel
cargo install sources

and add the following to Cargo.toml

[dependencies].
sources = “0.1.0”
Vessel = “0.0.1”

Run make local port=8000 again.
Result:

This virtual manifest specifies a [dependencies] section, which is not allowed.

How can I resolve this error? Please take into account that I am not at all familiar with this and was asking Chat GPT.

Hi @hokosugi, thanks for working on Chainsight!
You can get vessel, package manager of Motoko, from here.

By the way, you can start developing chainsight components without management canisters. Here is getting started.

1 Like

Does this mean that it is possible to skip Management canister deployment and deploy indexer with just csx CLI commands?

Yes, there is no need to care about management canisters when deploying on IC.
Our CLI/SDK uses the management canisters we have prepared.

Developers use management canisters only when they want to deploy and test in a local environment.
If you have already developed components and want to run it in a local environment, we will guide you through the details!

1 Like

Hey there @darroze . Did you get a chance to have a look at the code I linked to?

Hi @timk11 .
Thanks to you, we have identified the problem and are currently working on a fix!

Therer are some EVM types that our SDK not supported yet.
We will get back to you as soon as your manifest is supported!

Command, make local port=8000 with the following error.

Stderr:.
/Users/myname/dfinity/chainsight-management-canisters/src/canisters/registry/Registry.mo:7.1-7.37: import error [M0010], package "candb".

/Users/myname/dfinity/chainsight-management-canisters/src/canisters/registry/Registry.mo:21.1-21.46: import error [M0010], package " stable-buffer" not define

Registry.mo

There are six different ways to import

  • Importing from the Motoko base library
  • Importing local files
  • Importing from another package or directory
  • Importing packages from a package manager
  • Importing actor classes
  • Importing from another canister smart contract

A note like "import CanDB “mo:candb/CanDB” would be considered “Importing from another package or directory”. There is no candb in vessel’s library, and it seems that I need to write to dfx.json. How should I write it?

Hi @timk11 ,
The EVM type issue has been resolved and your Snapshot Indexer EVM code can now be generated in the latest CLI!

However, there is an error when generating the code for Lens, and it seems that your manifest definitions are inconsistent with the latest CLI.

We have added json-schemas for component manifest so that validation will work in the code editor.
To enable json-schema, add a line as follows.

Json-schemas are defined for each component type:

Please update those and then try csx generate!

Thanks @darroze ! Glad to hear this was helpful for the improvements on your side. I’ll have a thorough look at this and push ahead with it today.

1 Like

That all works now. The algorithm lens manifest that ultimately worked looks like this:

# yaml-language-server: $schema=https://raw.githubusercontent.com/horizonx-tech/chainsight-cli/main/resources/schema/algorithm_lens.json
version: v1
metadata:
  label: algorithm_lens_usdceth_0_3
  type: algorithm_lens
  description: ''
  tags:
  - Ethereum
  - Account
datasource:
  methods:
  - id: pool_fees_usdceth_0_3
    label: last_snapshot_value
    identifier: 'get_last_snapshot_value : () -> (text)'
  - id: tcumul_28x6hr_usdceth_0_3
    label: last_snapshot_value
    identifier: 'get_last_snapshot_value : () -> (text)'
  - id: tcumul_30_min_usdceth_0_3
    label: last_snapshot_value
    identifier: 'get_last_snapshot_value : () -> (text)'
  - id: v3pool_usdceth_0_3
    label: last_snapshot_value
    identifier: 'get_last_snapshot_value : () -> (text)'
output:
  name: EDPR
  fields:
    address: String
    current_price: f32
    range_top: f32
    range_bottom: f32
    edpr: f32
  type: struct
  type_name: null

I did csx generate and csx build and this was successful. I take it the next step is to modify the lib.rs’s in ./src/logics and then repeat csx build?

1 Like

@timk11 Great!

I take it the next step is to modify the lib.rs ’s in ./src/logics and then repeat csx build ?

That’s right. Now comes the time to implement your own logic.
We’re looking forward to it!

1 Like

Quick question - If I’ve already run csx build and then edit some of the Rust files, will csx build --only-build replace the existing wasm files with new ones? If not, how is this best done?

This is weird, and not something I’ve seen before today. I don’t know if it’s a csx problem or something to do with the OS or the CLI. I’m using WSL. Here’s what it looks like:

So I’m trying the same command (csx build --only-build abbreviated as !!) every time but each time the output stops somewhere different. In the first example it stopped in the middle of a line in a warning. Lots of camel case warnings, which I’m not too bothered about. The irritating thing is that when the output progresses far enough there are error messages that I’m trying to solve, but most of the time the output doesn’t even get that far. I’ve tried restarting a couple of times - still no different. I can’t find this problem described anywhere online.

Any clues?

You are right.
Your logic will be listed in the logics directory, but to keep it and build again, use build -only-build.
Normally, generate → (write your logic in logics dir) → build will do the trick.

1 Like

This is the first time I saw this too. Also I don’t know as I usually use mac. I will ask the team.
By the way, does csx generate or csx build (without option) work?

Not sure. I didn’t try that because I didn’t want to lose my logics.

1 Like