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

refactor: separate db from home and consolidate home_db and syncing #878

Closed
wants to merge 13 commits into from

Conversation

luketchang
Copy link
Contributor

@luketchang luketchang commented Oct 6, 2021

Separates home-indexing and db-syncing logic from the concept of a home contract (home interface).

  • creates a new HomeIndexer trait in optics-core, who's sole responsibility is to retrieve updates and messages from home contract events
  • creates SyncingHomeDB in optics-base, which contains a HomeIndexer and a HomeDB and keeps the agent's HomeDB up to date by indexing home contract events and updating the db
  • each agent contains a SyncingHomeDB and will start the indexing task on run
  • agents now store home-related data through their own HomeDB instead of accessing their HomeDB through the home object

Closes #870

@luketchang luketchang added rust 🦀 Rust dev work required refactor redesign or restructure agents Relating to rust agents labels Oct 6, 2021
@luketchang luketchang self-assigned this Oct 6, 2021
@@ -1,7 +1,7 @@
//! Interfaces to the ethereum contracts

#![forbid(unsafe_code)]
#![warn(missing_docs)]
// #![warn(missing_docs)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Struggling to silence the abigen! warnings ugh

Comment on lines 14 to 17
abigen!(
EthereumHomeInternal,
"./chains/optics-ethereum/abis/Home.abi.json"
);
Copy link
Contributor Author

@luketchang luketchang Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting these bizarre errors only when running cargo test (why PR is failing CI). cargo build works fine. @prestwich how to fix these weird abigen path errors?

   Doc-tests optics-ethereum
error: failed to get ABI JSON

Caused by:
    0: failed to read artifact JSON file with path /Users/luketchang/Desktop/optics/optics-monorepo/rust/chains/optics-ethereum/chains/optics-ethereum/abis/Home.abi.json
    1: No such file or directory (os error 2)
  --> /Users/luketchang/Desktop/optics/optics-monorepo/rust/chains/optics-ethereum/src/home_indexer.rs:16:5
   |
16 |     "./chains/optics-ethereum/abis/Home.abi.json"
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: failed to get ABI JSON

Caused by:
    0: failed to read artifact JSON file with path /Users/luketchang/Desktop/optics/optics-monorepo/rust/chains/optics-ethereum/chains/optics-ethereum/abis/Home.abi.json
    1: No such file or directory (os error 2)
  --> /Users/luketchang/Desktop/optics/optics-monorepo/rust/chains/optics-ethereum/src/settings.rs:17:5
   |
17 |     "./chains/optics-ethereum/abis/Home.abi.json"
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved import `crate::EthereumHomeIndexer`
  --> /Users/luketchang/Desktop/optics/optics-monorepo/rust/chains/optics-ethereum/src/settings.rs:12:5
   |
12 | use crate::EthereumHomeIndexer;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `EthereumHomeIndexer` in the root

error[E0412]: cannot find type `EthereumHomeInternal` in this scope
  --> /Users/luketchang/Desktop/optics/optics-monorepo/rust/chains/optics-ethereum/src/home_indexer.rs:25:19
   |
25 |     contract: Arc<EthereumHomeInternal<M>>,
   |                   ^^^^^^^^^^^^^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
1  | use optics_ethereum::EthereumHomeInternal;
   |
1  | use optics_ethereum::settings::EthereumHomeInternal;
   |

error: aborting due to 4 previous errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe we are falling prey to rust-lang/cargo#9427 here

@luketchang luketchang marked this pull request as ready for review October 7, 2021 04:42
@luketchang luketchang force-pushed the luke/db-home-refactor branch from 908c598 to 4e008ce Compare October 12, 2021 15:50
@luketchang
Copy link
Contributor Author

Closing in favor of #902

@luketchang luketchang closed this Oct 15, 2021
@luketchang luketchang deleted the luke/db-home-refactor branch October 18, 2021 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents Relating to rust agents refactor redesign or restructure rust 🦀 Rust dev work required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move db logic from optics-ethereum to optics-core
2 participants