Skip to content

Commit

Permalink
merge and fixup conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
baichuan3 committed May 28, 2024
2 parents 7a69c9e + 84c3677 commit cb83325
Show file tree
Hide file tree
Showing 66 changed files with 1,104 additions and 380 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,19 @@ module.exports = {
'arrow-body-style': ['error', 'as-needed'],
},
},
{
files: ['sdk/typescript/rooch-create/**/*'],
rules: {
'@typescript-eslint/ban-types': 'off',
'no-restricted-globals': 'off',
},
},
{
files: ['sdk/typescript/templates/**/*'],
rules: {
'header/header': 'off',
'require-extensions/require-extensions': 'off',
},
},
],
}
1 change: 1 addition & 0 deletions .github/workflows/check_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
docker --version
sleep 6
docker images
docker pull bitseed/bitseed:0.1.4
- name: Check code format
run: cargo fmt -- --check
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
build-rooch-docker:
name: build rooch docker
name: Build Rooch Docker
runs-on: self-hosted
steps:
- name: Checkout
Expand All @@ -20,7 +20,6 @@ jobs:
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
# images: rooch/rooch,ghcr.io/rooch-network/rooch
images: ghcr.io/rooch-network/rooch
tag-sha: true # add git short SHA as Docker tag
- name: Set up Docker Buildx
Expand All @@ -39,8 +38,10 @@ jobs:
context: .
file: docker/Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
tags: |
ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}
ghcr.io/rooch-network/rooch:main
build-debug-rooch-docker:
name: Build and Deploy Debug Rooch Docker
runs-on: self-hosted
Expand All @@ -49,11 +50,11 @@ jobs:
uses: actions/checkout@v1
with:
submodules: recursive
- name: Docker meta
id: docker_meta
- name: Docker meta debug
id: docker_meta_debug
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ghcr.io/rooch-network/rooch-debug
images: ghcr.io/rooch-network/rooch
tag-sha: true # add git short SHA as Docker tag
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -65,15 +66,16 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GIT_PACKAGE_TOKEN }}
- name: Build and push
- name: Build and push debug
uses: docker/build-push-action@v2
with:
context: .
file: docker/DockerfileDebug
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Deploy to GCP DEV VM
tags: |
ghcr.io/rooch-network/rooch:${{ steps.docker_meta_debug.outputs.version }}_debug
ghcr.io/rooch-network/rooch:main_debug
- name: Deploy debug to GCP DEV VM
env:
PRIVATE_KEY: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
HOST: ${{ secrets.GCP_VM_HOST }}
Expand All @@ -83,6 +85,5 @@ jobs:
chmod 600 private_key.pem
sudo apt update
sudo apt install -y --no-install-recommends openssh-server
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch-debug:${{ steps.docker_meta.outputs.version }}' && docker run --rm -v /root:/root ghcr.io/rooch-network/rooch-debug:${{ steps.docker_meta.outputs.version }} server clean -n dev && docker run -d -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch-debug:${{ steps.docker_meta.outputs.version }}' server start -n dev --btc-rpc-url '${{secrets.BTC_REGTEST_RPC_URL}}' --btc-rpc-username rooch-regtest --btc-rpc-password '${{secrets.BTC_REGTEST_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"fs\"}}]}}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST "cd /root/rooch && git pull origin main && bash scripts/check_dev_deploy_status.sh ${{ steps.docker_meta.outputs.version }} '${{ secrets.DEV_MNEMONIC_PHRASE }}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep main_debug | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep main_debug | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:main_debug' && docker run --rm -v /root:/root ghcr.io/rooch-network/rooch:main_debug server clean -n dev && docker run -d -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:main_debug' server start -n dev --btc-rpc-url '${{secrets.BTC_REGTEST_RPC_URL}}' --btc-rpc-username rooch-regtest --btc-rpc-password '${{secrets.BTC_REGTEST_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"fs\"}}]}}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST "cd /root/rooch && git pull origin main && bash scripts/check_dev_deploy_status.sh main_debug '${{ secrets.DEV_MNEMONIC_PHRASE }}'"
8 changes: 8 additions & 0 deletions crates/rooch-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ pub struct RoochOpt {
/// The end block height of the Bitcoin chain to stop relaying from, default is none.
pub btc_end_block_height: Option<u64>,

#[serde(skip_serializing_if = "Option::is_none")]
#[clap(long, env = "BTC_SYNC_BLOCK_INTERVAL")]
/// The interval of sync BTC block, default is none.
pub btc_sync_block_interval: Option<u64>,

/// The address of the sequencer account
#[clap(long)]
pub sequencer_account: Option<String>,
Expand Down Expand Up @@ -157,6 +162,7 @@ impl RoochOpt {
btc_rpc_username: None,
btc_rpc_password: None,
btc_end_block_height: None,
btc_sync_block_interval: None,
sequencer_account: None,
proposer_account: None,
da: None,
Expand Down Expand Up @@ -190,6 +196,7 @@ impl RoochOpt {
btc_rpc_user_name: self.btc_rpc_username.clone().unwrap(),
btc_rpc_password: self.btc_rpc_password.clone().unwrap(),
btc_end_block_height: self.btc_end_block_height,
btc_sync_block_interval: self.btc_sync_block_interval,
})
}

Expand All @@ -209,6 +216,7 @@ pub struct BitcoinRelayerConfig {
pub btc_rpc_user_name: String,
pub btc_rpc_password: String,
pub btc_end_block_height: Option<u64>,
pub btc_sync_block_interval: Option<u64>,
}

#[derive(Clone, Debug, PartialEq)]
Expand Down
8 changes: 4 additions & 4 deletions crates/rooch-faucet/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ use axum::{
};
use clap::Parser;
use http::Method;
use move_core_types::account_address::AccountAddress;

use prometheus::{Registry, TextEncoder};
use rooch_rpc_api::jsonrpc_types::{AccountAddressView, StructTagView};
use rooch_rpc_api::jsonrpc_types::StructTagView;
use rooch_rpc_client::wallet_context::WalletContext;
use tokio::sync::RwLock;

Expand Down Expand Up @@ -99,12 +99,12 @@ impl App {
let context = WalletContext::new(self.wallet_config_dir.clone())
.map_err(|e| FaucetError::Wallet(e.to_string()))?;
let client = context.get_client().await.unwrap();
let faucet_address: AccountAddress = context.client_config.active_address.unwrap().into();
let faucet_address = context.client_config.active_address.unwrap();

let s = client
.rooch
.get_balance(
AccountAddressView::from(faucet_address),
faucet_address.into(),
StructTagView::from_str("0x3::gas_coin::GasCoin").unwrap(),
)
.await
Expand Down
4 changes: 2 additions & 2 deletions crates/rooch-indexer/src/models/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

use crate::schema::events;
use diesel::prelude::*;
use move_core_types::account_address::AccountAddress;
use move_core_types::language_storage::StructTag;
use moveos_types::h256::H256;
use moveos_types::moveos_std::event::EventID;
use moveos_types::moveos_std::object::ObjectID;
use rooch_types::address::RoochAddress;
use rooch_types::indexer::event::{IndexerEvent, IndexerEventID};
use std::str::FromStr;

Expand Down Expand Up @@ -64,7 +64,7 @@ impl From<IndexerEvent> for StoredEvent {
impl StoredEvent {
pub fn try_into_indexer_event(&self) -> Result<IndexerEvent, anyhow::Error> {
let event_handle_id = ObjectID::from_str(self.event_handle_id.as_str())?;
let sender = AccountAddress::from_hex_literal(self.sender.as_str())?;
let sender = RoochAddress::from_str(self.sender.as_str())?;
let tx_hash = H256::from_str(self.tx_hash.as_str())?;
let event_type = StructTag::from_str(self.event_type.as_str())?;

Expand Down
12 changes: 6 additions & 6 deletions crates/rooch-indexer/src/models/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
use crate::schema::field_states;
use crate::schema::object_states;
use diesel::prelude::*;
use move_core_types::account_address::AccountAddress;
use move_core_types::language_storage::{StructTag, TypeTag};
use moveos_types::moveos_std::object::ObjectID;
use rooch_types::address::RoochAddress;
use rooch_types::indexer::state::{IndexerFieldState, IndexerObjectState};
use std::str::FromStr;

Expand Down Expand Up @@ -47,12 +47,13 @@ pub struct StoredObjectState {

impl From<IndexerObjectState> for StoredObjectState {
fn from(state: IndexerObjectState) -> Self {
let state_root = RoochAddress::from(state.state_root).to_hex_literal();
Self {
object_id: state.object_id.to_string(),
owner: state.owner.to_hex_literal(),
flag: state.flag as i16,
object_type: state.object_type.to_string(),
state_root: state.state_root.to_hex_literal(),
state_root,
size: state.size as i64,
tx_order: state.tx_order as i64,
state_index: state.state_index as i64,
Expand All @@ -65,17 +66,16 @@ impl From<IndexerObjectState> for StoredObjectState {
impl StoredObjectState {
pub fn try_into_indexer_global_state(&self) -> Result<IndexerObjectState, anyhow::Error> {
let object_id = ObjectID::from_str(self.object_id.as_str())?;
let owner = AccountAddress::from_hex_literal(self.owner.as_str())?;

let owner = RoochAddress::from_str(self.owner.as_str())?;
let object_type = StructTag::from_str(self.object_type.as_str())?;
let state_root = AccountAddress::from_hex_literal(self.state_root.as_str())?;
let state_root = RoochAddress::from_str(self.state_root.as_str())?;

let state = IndexerObjectState {
object_id,
owner,
flag: self.flag as u8,
object_type,
state_root,
state_root: state_root.0,
size: self.size as u64,
tx_order: self.tx_order as u64,
state_index: self.state_index as u64,
Expand Down
4 changes: 2 additions & 2 deletions crates/rooch-indexer/src/models/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use crate::schema::transactions;
use diesel::prelude::*;
use move_core_types::account_address::AccountAddress;
use moveos_types::h256::H256;
use rooch_types::address::RoochAddress;
use rooch_types::indexer::transaction::IndexerTransaction;
use std::str::FromStr;

Expand Down Expand Up @@ -73,7 +73,7 @@ impl TryFrom<StoredTransaction> for IndexerTransaction {
type Error = anyhow::Error;

fn try_from(transaction: StoredTransaction) -> Result<Self, Self::Error> {
let sender = AccountAddress::from_hex_literal(transaction.sender.as_str())?;
let sender = RoochAddress::from_hex_literal(transaction.sender.as_str())?;
let tx_hash = H256::from_str(transaction.tx_hash.as_str())?;
let tx_accumulator_root = H256::from_str(transaction.tx_accumulator_root.as_str())?;
let state_root = H256::from_str(transaction.state_root.as_str())?;
Expand Down
6 changes: 3 additions & 3 deletions crates/rooch-indexer/src/tests/test_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn test_transaction_store() -> Result<()> {
let transactions = vec![indexer_transaction];
let _ = indexer_store.persist_transactions(transactions)?;

let filter = TransactionFilter::Sender(random_moveos_tx.ctx.sender);
let filter = TransactionFilter::Sender(random_moveos_tx.ctx.sender.into());
let query_transactions =
indexer_reader.query_transactions_with_filter(filter, None, 1, true)?;
assert_eq!(query_transactions.len(), 1);
Expand Down Expand Up @@ -197,7 +197,7 @@ fn test_event_store() -> Result<()> {
let events = vec![indexer_event];
let _ = indexer_store.persist_events(events)?;

let filter = EventFilter::Sender(random_moveos_tx.ctx.sender);
let filter = EventFilter::Sender(random_moveos_tx.ctx.sender.into());
let query_events = indexer_reader.query_events_with_filter(filter, None, 1, true)?;
assert_eq!(query_events.len(), 1);
Ok(())
Expand Down Expand Up @@ -272,7 +272,7 @@ fn test_object_type_query() -> Result<()> {
// filter by object type and owner
let filter = ObjectStateFilter::ObjectTypeWithOwner {
object_type: CoinStore::<GasCoin>::struct_tag(),
owner,
owner: owner.into(),
};
let query_object_states =
indexer_reader.query_object_states_with_filter(filter, None, 1, true)?;
Expand Down
Loading

0 comments on commit cb83325

Please sign in to comment.