diff --git a/.gitignore b/.gitignore index 3ae41ab9..40be2daa 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ sequencer_runner/data/ storage.json result wallet-ffi/wallet_ffi.h +bedrock_signing_key diff --git a/Cargo.lock b/Cargo.lock index 157d25ab..ab904921 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2484,7 +2484,6 @@ dependencies = [ "console_error_panic_hook", "console_log", "env_logger", - "hex", "indexer_service_protocol", "indexer_service_rpc", "jsonrpsee", @@ -3427,12 +3426,16 @@ dependencies = [ name = "indexer_service_protocol" version = "0.1.0" dependencies = [ + "anyhow", + "base58", "base64 0.22.1", "common", + "hex", "nssa", "nssa_core", "schemars 1.2.0", "serde", + "serde_with", ] [[package]] @@ -3856,9 +3859,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" dependencies = [ "cpufeatures", ] @@ -8257,7 +8260,6 @@ dependencies = [ "amm_core", "anyhow", "async-stream", - "base58", "base64 0.22.1", "borsh", "bytemuck", diff --git a/README.md b/README.md index 07b883a8..364ee2a5 100644 --- a/README.md +++ b/README.md @@ -135,10 +135,10 @@ The sequencer and node can be run locally: 1. On one terminal go to the `logos-blockchain/logos-blockchain` repo and run a local logos blockchain node: - `git checkout master; git pull` - `cargo clean` - - `rm ~/.logos-blockchain-circuits` + - `rm -r ~/.logos-blockchain-circuits` - `./scripts/setup-logos-blockchain-circuits.sh` - `cargo build --all-features` - - `./target/debug/logos-blockchain-node nodes/node/config-one-node.yaml` + - `./target/debug/logos-blockchain-node --deployment nodes/node/standalone-deployment-config.yaml nodes/node/standalone-node-config.yaml` 2. On another terminal go to the `logos-blockchain/lssa` repo and run indexer service: - `RUST_LOG=info cargo run --release -p indexer_service indexer/service/configs/indexer_config.json` diff --git a/artifacts/program_methods/amm.bin b/artifacts/program_methods/amm.bin index df4c0b07..3dd89048 100644 Binary files a/artifacts/program_methods/amm.bin and b/artifacts/program_methods/amm.bin differ diff --git a/artifacts/program_methods/authenticated_transfer.bin b/artifacts/program_methods/authenticated_transfer.bin index 9a9942ba..8a506394 100644 Binary files a/artifacts/program_methods/authenticated_transfer.bin and b/artifacts/program_methods/authenticated_transfer.bin differ diff --git a/artifacts/program_methods/pinata.bin b/artifacts/program_methods/pinata.bin index e6ea7b00..741d2848 100644 Binary files a/artifacts/program_methods/pinata.bin and b/artifacts/program_methods/pinata.bin differ diff --git a/artifacts/program_methods/pinata_token.bin b/artifacts/program_methods/pinata_token.bin index 8a489d81..d48a764d 100644 Binary files a/artifacts/program_methods/pinata_token.bin and b/artifacts/program_methods/pinata_token.bin differ diff --git a/artifacts/program_methods/privacy_preserving_circuit.bin b/artifacts/program_methods/privacy_preserving_circuit.bin index fc26fc19..24396d4d 100644 Binary files a/artifacts/program_methods/privacy_preserving_circuit.bin and b/artifacts/program_methods/privacy_preserving_circuit.bin differ diff --git a/artifacts/program_methods/token.bin b/artifacts/program_methods/token.bin index 407364be..f67348f4 100644 Binary files a/artifacts/program_methods/token.bin and b/artifacts/program_methods/token.bin differ diff --git a/artifacts/test_program_methods/burner.bin b/artifacts/test_program_methods/burner.bin index 7e48c896..bbff49aa 100644 Binary files a/artifacts/test_program_methods/burner.bin and b/artifacts/test_program_methods/burner.bin differ diff --git a/artifacts/test_program_methods/chain_caller.bin b/artifacts/test_program_methods/chain_caller.bin index faaedb76..3495435a 100644 Binary files a/artifacts/test_program_methods/chain_caller.bin and b/artifacts/test_program_methods/chain_caller.bin differ diff --git a/artifacts/test_program_methods/changer_claimer.bin b/artifacts/test_program_methods/changer_claimer.bin index e0ebbadb..7c1cfb5b 100644 Binary files a/artifacts/test_program_methods/changer_claimer.bin and b/artifacts/test_program_methods/changer_claimer.bin differ diff --git a/artifacts/test_program_methods/claimer.bin b/artifacts/test_program_methods/claimer.bin index 41dc3904..dc622f89 100644 Binary files a/artifacts/test_program_methods/claimer.bin and b/artifacts/test_program_methods/claimer.bin differ diff --git a/artifacts/test_program_methods/data_changer.bin b/artifacts/test_program_methods/data_changer.bin index ada0f52c..38ec9d78 100644 Binary files a/artifacts/test_program_methods/data_changer.bin and b/artifacts/test_program_methods/data_changer.bin differ diff --git a/artifacts/test_program_methods/extra_output.bin b/artifacts/test_program_methods/extra_output.bin index b1eade33..3f36d446 100644 Binary files a/artifacts/test_program_methods/extra_output.bin and b/artifacts/test_program_methods/extra_output.bin differ diff --git a/artifacts/test_program_methods/malicious_authorization_changer.bin b/artifacts/test_program_methods/malicious_authorization_changer.bin index 95ed2291..4ccb216c 100644 Binary files a/artifacts/test_program_methods/malicious_authorization_changer.bin and b/artifacts/test_program_methods/malicious_authorization_changer.bin differ diff --git a/artifacts/test_program_methods/minter.bin b/artifacts/test_program_methods/minter.bin index eaf47a3d..040a9dbf 100644 Binary files a/artifacts/test_program_methods/minter.bin and b/artifacts/test_program_methods/minter.bin differ diff --git a/artifacts/test_program_methods/missing_output.bin b/artifacts/test_program_methods/missing_output.bin index 062b83c3..e04ab41d 100644 Binary files a/artifacts/test_program_methods/missing_output.bin and b/artifacts/test_program_methods/missing_output.bin differ diff --git a/artifacts/test_program_methods/modified_transfer.bin b/artifacts/test_program_methods/modified_transfer.bin index ff682982..7871d07c 100644 Binary files a/artifacts/test_program_methods/modified_transfer.bin and b/artifacts/test_program_methods/modified_transfer.bin differ diff --git a/artifacts/test_program_methods/nonce_changer.bin b/artifacts/test_program_methods/nonce_changer.bin index c45613c6..bf10cc24 100644 Binary files a/artifacts/test_program_methods/nonce_changer.bin and b/artifacts/test_program_methods/nonce_changer.bin differ diff --git a/artifacts/test_program_methods/noop.bin b/artifacts/test_program_methods/noop.bin index 2dc0d49e..71080ca3 100644 Binary files a/artifacts/test_program_methods/noop.bin and b/artifacts/test_program_methods/noop.bin differ diff --git a/artifacts/test_program_methods/program_owner_changer.bin b/artifacts/test_program_methods/program_owner_changer.bin index 68fcec96..3d3f528a 100644 Binary files a/artifacts/test_program_methods/program_owner_changer.bin and b/artifacts/test_program_methods/program_owner_changer.bin differ diff --git a/artifacts/test_program_methods/simple_balance_transfer.bin b/artifacts/test_program_methods/simple_balance_transfer.bin index e2145ac7..74f82078 100644 Binary files a/artifacts/test_program_methods/simple_balance_transfer.bin and b/artifacts/test_program_methods/simple_balance_transfer.bin differ diff --git a/bedrock_client/src/lib.rs b/bedrock_client/src/lib.rs index 91687545..7655a31c 100644 --- a/bedrock_client/src/lib.rs +++ b/bedrock_client/src/lib.rs @@ -62,7 +62,6 @@ impl BedrockClient { Retry::spawn(self.backoff_strategy(), || { self.http_client .post_transaction(self.node_url.clone(), tx.clone()) - .inspect_err(|err| warn!("Transaction posting failed with error: {err:#}")) }) .await } diff --git a/common/src/block.rs b/common/src/block.rs index a5fc9218..90bbe357 100644 --- a/common/src/block.rs +++ b/common/src/block.rs @@ -4,6 +4,16 @@ use sha2::{Digest, Sha256, digest::FixedOutput}; use crate::{HashType, transaction::NSSATransaction}; pub type MantleMsgId = [u8; 32]; +pub type BlockHash = HashType; +pub type BlockId = u64; +pub type TimeStamp = u64; + +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] +pub struct BlockMeta { + pub id: BlockId, + pub hash: BlockHash, + pub msg_id: MantleMsgId, +} #[derive(Debug, Clone)] /// Our own hasher. @@ -19,10 +29,6 @@ impl OwnHasher { } } -pub type BlockHash = HashType; -pub type BlockId = u64; -pub type TimeStamp = u64; - #[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] pub struct BlockHeader { pub block_id: BlockId, diff --git a/common/src/error.rs b/common/src/error.rs index 5c81a106..3301bc87 100644 --- a/common/src/error.rs +++ b/common/src/error.rs @@ -13,25 +13,13 @@ pub struct SequencerRpcError { #[derive(thiserror::Error, Debug)] pub enum SequencerClientError { #[error("HTTP error")] - HTTPError(reqwest::Error), + HTTPError(#[from] reqwest::Error), #[error("Serde error")] - SerdeError(serde_json::Error), - #[error("Internal error")] + SerdeError(#[from] serde_json::Error), + #[error("Internal error: {0:?}")] InternalError(SequencerRpcError), } -impl From for SequencerClientError { - fn from(value: reqwest::Error) -> Self { - SequencerClientError::HTTPError(value) - } -} - -impl From for SequencerClientError { - fn from(value: serde_json::Error) -> Self { - SequencerClientError::SerdeError(value) - } -} - impl From for SequencerClientError { fn from(value: SequencerRpcError) -> Self { SequencerClientError::InternalError(value) diff --git a/explorer_service/Cargo.toml b/explorer_service/Cargo.toml index 49d1ddce..219f2bc0 100644 --- a/explorer_service/Cargo.toml +++ b/explorer_service/Cargo.toml @@ -26,9 +26,6 @@ console_log = "1.0" # Date/Time chrono.workspace = true -# Hex encoding/decoding -hex.workspace = true - # URL encoding urlencoding = "2.1" diff --git a/explorer_service/src/api.rs b/explorer_service/src/api.rs index c3360c01..c489c827 100644 --- a/explorer_service/src/api.rs +++ b/explorer_service/src/api.rs @@ -1,3 +1,5 @@ +use std::str::FromStr as _; + use indexer_service_protocol::{Account, AccountId, Block, BlockId, HashType, Transaction}; use leptos::prelude::*; use serde::{Deserialize, Serialize}; @@ -25,13 +27,6 @@ pub async fn get_account(account_id: AccountId) -> Result Option> { - let s = s.trim().trim_start_matches("0x"); - hex::decode(s).ok() -} - /// Search for a block, transaction, or account by query string #[server] pub async fn search(query: String) -> Result { @@ -42,12 +37,8 @@ pub async fn search(query: String) -> Result { let mut transactions = Vec::new(); let mut accounts = Vec::new(); - // Try to parse as hash (32 bytes) - if let Some(bytes) = parse_hex(&query) - && let Ok(hash_array) = <[u8; 32]>::try_from(bytes) - { - let hash = HashType(hash_array); - + // Try as hash + if let Ok(hash) = HashType::from_str(&query) { // Try as block hash if let Ok(block) = client.get_block_by_hash(hash).await { blocks.push(block); @@ -57,12 +48,13 @@ pub async fn search(query: String) -> Result { if let Ok(tx) = client.get_transaction(hash).await { transactions.push(tx); } + } - // Try as account ID - let account_id = AccountId { value: hash_array }; - if let Ok(account) = client.get_account(account_id).await { - accounts.push((account_id, account)); - } + // Try as account ID + if let Ok(account_id) = AccountId::from_str(&query) + && let Ok(account) = client.get_account(account_id).await + { + accounts.push((account_id, account)); } // Try as block ID diff --git a/explorer_service/src/components/account_preview.rs b/explorer_service/src/components/account_preview.rs index 3a99eeb8..bbe59c0f 100644 --- a/explorer_service/src/components/account_preview.rs +++ b/explorer_service/src/components/account_preview.rs @@ -2,12 +2,10 @@ use indexer_service_protocol::{Account, AccountId}; use leptos::prelude::*; use leptos_router::components::A; -use crate::format_utils; - /// Account preview component #[component] pub fn AccountPreview(account_id: AccountId, account: Account) -> impl IntoView { - let account_id_str = format_utils::format_account_id(&account_id); + let account_id_str = account_id.to_string(); view! { {move || { let Account { program_owner, balance, data, nonce } = &account; - let program_id = format_utils::format_program_id(program_owner); + let program_id = program_owner.to_string(); view! {