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

Provide indexer store base on SQLite #1088

Merged
merged 8 commits into from
Nov 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add sqlite lib install scripts and store multichain_raw_address as hex
baichuan3 committed Nov 1, 2023
commit d9c15a79a0be4904681e45cd51a2e925ab935155
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
CREATE TABLE transactions (
tx_order BIGINT NOT NULL PRIMARY KEY,
tx_order BIGINT NOT NULL PRIMARY KEY,
tx_hash VARCHAR NOT NULL,
transaction_type VARCHAR NOT NULL,
sequence_number BIGINT NOT NULL,
sequence_number BIGINT NOT NULL,
multichain_id VARCHAR NOT NULL,
multichain_raw_address BLOB NOT NULL,
multichain_raw_address VARCHAR NOT NULL,
sender VARCHAR NOT NULL,
action VARCHAR NOT NULL,
action_type SMALLINT NOT NULL,
action_raw BLOB NOT NULL,
auth_validator_id BIGINT NOT NULL,
auth_validator_id BIGINT NOT NULL,
authenticator_payload BLOB NOT NULL,
tx_accumulator_root VARCHAR NOT NULL,
transaction_raw BLOB NOT NULL,

state_root VARCHAR NOT NULL,
event_root VARCHAR NOT NULL,
gas_used BIGINT NOT NULL,
gas_used BIGINT NOT NULL,
status VARCHAR NOT NULL,

tx_order_auth_validator_id BIGINT NOT NULL,
tx_order_auth_validator_id BIGINT NOT NULL,
tx_order_authenticator_payload BLOB NOT NULL,

created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
UNIQUE (tx_hash)
);

4 changes: 2 additions & 2 deletions crates/rooch-indexer/src/models/transactions.rs
Original file line number Diff line number Diff line change
@@ -32,8 +32,8 @@ pub struct StoredTransaction {
pub sequence_number: i64,
#[diesel(sql_type = diesel::sql_types::Text)]
pub multichain_id: String,
#[diesel(sql_type = diesel::sql_types::Blob)]
pub multichain_raw_address: Vec<u8>,
#[diesel(sql_type = diesel::sql_types::Text)]
pub multichain_raw_address: String,
/// the rooch address of sender who send the transaction
#[diesel(sql_type = diesel::sql_types::Text)]
pub sender: String,
2 changes: 1 addition & 1 deletion crates/rooch-indexer/src/schema.rs
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ diesel::table! {
transaction_type -> Text,
sequence_number -> BigInt,
multichain_id -> Text,
multichain_raw_address -> Binary,
multichain_raw_address -> Text,
sender -> Text,
action -> Text,
action_type -> SmallInt,
3 changes: 2 additions & 1 deletion crates/rooch-indexer/src/types.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,8 @@ pub struct IndexedTransaction {
pub transaction_type: TransactionType,
pub sequence_number: u64,
pub multichain_id: RoochMultiChainID,
pub multichain_raw_address: Vec<u8>,
//TODO transform to hex
pub multichain_raw_address: String,
/// the rooch address of sender who send the transaction
pub sender: RoochAddress,
pub action: MoveAction,
2 changes: 1 addition & 1 deletion crates/rooch-types/src/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ pub enum TransactionType {
}

impl TransactionType {
pub fn transaction_type_name(self) -> String {
pub fn transaction_type_name(&self) -> String {
self.to_string()
}
}
16 changes: 16 additions & 0 deletions scripts/dev_setup.sh
Original file line number Diff line number Diff line change
@@ -585,6 +585,21 @@ function install_postgres {
fi
}

function install_sqlite3 {
if [[ "$PACKAGE_MANAGER" == "apt-get" ]] || [[ "$PACKAGE_MANAGER" == "apk" ]]; then
install_pkg sqlite3 "$PACKAGE_MANAGER"
fi
if [[ "$PACKAGE_MANAGER" == "pacman" ]] || [[ "$PACKAGE_MANAGER" == "yum" ]]; then
install_pkg sqlite3 "$PACKAGE_MANAGER"
fi
if [[ "$PACKAGE_MANAGER" == "dnf" ]]; then
install_pkg sqlite-devel "$PACKAGE_MANAGER"
fi
if [[ "$PACKAGE_MANAGER" == "brew" ]]; then
install_pkg sqlite "$PACKAGE_MANAGER"
fi
}

function install_lld {
# Right now, only install lld for linux
if [[ "$(uname)" == "Linux" ]]; then
@@ -827,6 +842,7 @@ if [[ "$INSTALL_BUILD_TOOLS" == "true" ]]; then
install_cargo_nextest
install_grcov
install_postgres
install_sqlite3
install_pkg git "$PACKAGE_MANAGER"
install_lcov "$PACKAGE_MANAGER"
install_pkg unzip "$PACKAGE_MANAGER"
4 changes: 2 additions & 2 deletions scripts/ubuntu_dev.sh
Original file line number Diff line number Diff line change
@@ -7,10 +7,10 @@

if [ "$(whoami)" != 'root' ]; then
sudo apt update
sudo apt install git curl clang lld pkg-config libssl-dev
sudo apt install git curl clang lld pkg-config libssl-dev libsqlite3-dev
else
apt update
apt install git curl clang lld pkg-config libssl-dev
apt install git curl clang lld pkg-config libssl-dev libsqlite3-dev
fi

cat << EOF