From 5e0c120298163ac8102a4677140243674f9b3baf Mon Sep 17 00:00:00 2001 From: jolestar Date: Mon, 6 May 2024 09:54:36 +0800 Subject: [PATCH] Rename bitcoin-move light_client.move to bitcoin.move (#1649) * Rename bitcoin-move light_client.move to bitcoin.move * fixup --- crates/rooch-executor/src/actor/executor.rs | 4 +- ...n_light_client_test.rs => bitcoin_test.rs} | 21 +- crates/rooch-framework-tests/src/tests/mod.rs | 2 +- .../src/actor/bitcoin_relayer.rs | 8 +- .../rooch-types/src/bitcoin/light_client.rs | 194 ------------------ crates/rooch-types/src/bitcoin/mod.rs | 193 ++++++++++++++++- frameworks/bitcoin-move/doc/README.md | 2 +- frameworks/bitcoin-move/doc/bitcoin.md | 170 +++++++++++++++ frameworks/bitcoin-move/doc/genesis.md | 2 +- frameworks/bitcoin-move/doc/light_client.md | 170 --------------- .../{light_client.move => bitcoin.move} | 2 +- frameworks/bitcoin-move/sources/genesis.move | 4 +- frameworks/bitcoin-move/sources/ord.move | 2 +- frameworks/bitcoin-move/sources/utxo.move | 2 +- 14 files changed, 380 insertions(+), 396 deletions(-) rename crates/rooch-framework-tests/src/tests/{bitcoin_light_client_test.rs => bitcoin_test.rs} (93%) delete mode 100644 crates/rooch-types/src/bitcoin/light_client.rs create mode 100644 frameworks/bitcoin-move/doc/bitcoin.md delete mode 100644 frameworks/bitcoin-move/doc/light_client.md rename frameworks/bitcoin-move/sources/{light_client.move => bitcoin.move} (99%) diff --git a/crates/rooch-executor/src/actor/executor.rs b/crates/rooch-executor/src/actor/executor.rs index 692895bd0b..9b855de702 100644 --- a/crates/rooch-executor/src/actor/executor.rs +++ b/crates/rooch-executor/src/actor/executor.rs @@ -23,7 +23,7 @@ use moveos_types::transaction::{FunctionCall, MoveOSTransaction, VerifiedMoveAct use rooch_genesis::FrameworksGasParameters; use rooch_store::RoochStore; use rooch_types::address::MultiChainAddress; -use rooch_types::bitcoin::light_client::BitcoinLightClientModule; +use rooch_types::bitcoin::BitcoinModule; use rooch_types::framework::address_mapping::AddressMappingModule; use rooch_types::framework::auth_validator::{AuthValidatorCaller, TxValidateResult}; use rooch_types::framework::ethereum_light_client::EthereumLightClientModule; @@ -130,7 +130,7 @@ impl ExecutorActor { match RoochMultiChainID::try_from(chain_id.id())? { RoochMultiChainID::Bitcoin => { let action = VerifiedMoveAction::Function { - call: BitcoinLightClientModule::create_submit_new_block_call_bytes( + call: BitcoinModule::create_submit_new_block_call_bytes( block_height, block_hash, block_body, diff --git a/crates/rooch-framework-tests/src/tests/bitcoin_light_client_test.rs b/crates/rooch-framework-tests/src/tests/bitcoin_test.rs similarity index 93% rename from crates/rooch-framework-tests/src/tests/bitcoin_light_client_test.rs rename to crates/rooch-framework-tests/src/tests/bitcoin_test.rs index 2ad70cc161..b767dc8a46 100644 --- a/crates/rooch-framework-tests/src/tests/bitcoin_light_client_test.rs +++ b/crates/rooch-framework-tests/src/tests/bitcoin_test.rs @@ -46,29 +46,18 @@ fn test_submit_block() { .unwrap(); // let moveos = binding_test.reader_executor.moveos().read(); - let bitcoin_light_client_module = binding_test - .as_module_binding::( - ); + let bitcoin_module = binding_test.as_module_binding::(); assert_eq!( - bitcoin_light_client_module - .get_block(block_hash) - .unwrap() - .unwrap(), + bitcoin_module.get_block(block_hash).unwrap().unwrap(), block_header ); assert_eq!( - bitcoin_light_client_module - .get_block_by_height(height) - .unwrap() - .unwrap(), + bitcoin_module.get_block_by_height(height).unwrap().unwrap(), block_header ); assert_eq!( - bitcoin_light_client_module - .get_latest_block_height() - .unwrap() - .unwrap(), + bitcoin_module.get_latest_block_height().unwrap().unwrap(), height ); println!("txdata len: {}", bitcoin_txdata.len()); @@ -88,7 +77,7 @@ fn test_submit_block() { } //this test takes too long time in debug mod run it in release mod, use command: -//RUST_LOG=debug cargo test --release --package rooch-framework-tests --lib -- --include-ignored tests::bitcoin_light_client_test::test_utxo_progress +//RUST_LOG=debug cargo test --release --package rooch-framework-tests --lib -- --include-ignored tests::bitcoin_test::test_utxo_progress #[test] fn test_utxo_progress() { let _ = tracing_subscriber::fmt::try_init(); diff --git a/crates/rooch-framework-tests/src/tests/mod.rs b/crates/rooch-framework-tests/src/tests/mod.rs index 74e1e2a2dd..8a1cfd72ab 100644 --- a/crates/rooch-framework-tests/src/tests/mod.rs +++ b/crates/rooch-framework-tests/src/tests/mod.rs @@ -1,7 +1,7 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -mod bitcoin_light_client_test; +mod bitcoin_test; mod brc20_test; mod chain_id_test; mod empty_tests; diff --git a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs index dd8991f155..b1b5a1a677 100644 --- a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs +++ b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs @@ -12,7 +12,7 @@ use moveos_types::module_binding::MoveFunctionCaller; use rooch_config::BitcoinRelayerConfig; use rooch_executor::proxy::ExecutorProxy; use rooch_types::{ - bitcoin::light_client::BitcoinLightClientModule, + bitcoin::BitcoinModule, multichain_id::RoochMultiChainID, transaction::{L1Block, L1BlockWithBody}, }; @@ -67,10 +67,8 @@ impl BitcoinRelayer { return Ok(()); } self.latest_sync_timestamp = chrono::Utc::now().timestamp() as u64; - let bitcoin_light_client = self - .move_caller - .as_module_binding::(); - let latest_block_height_in_rooch = bitcoin_light_client.get_latest_block_height()?; + let bitcoin_module = self.move_caller.as_module_binding::(); + let latest_block_height_in_rooch = bitcoin_module.get_latest_block_height()?; let latest_block_hash_in_bitcoin = self.rpc_client.get_best_block_hash().await?; let latest_block_header_info = self .rpc_client diff --git a/crates/rooch-types/src/bitcoin/light_client.rs b/crates/rooch-types/src/bitcoin/light_client.rs deleted file mode 100644 index a8117957d0..0000000000 --- a/crates/rooch-types/src/bitcoin/light_client.rs +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (c) RoochNetwork -// SPDX-License-Identifier: Apache-2.0 - -use super::types::Header; -use crate::{addresses::BITCOIN_MOVE_ADDRESS, into_address::IntoAddress}; -use anyhow::Result; -use bitcoin::BlockHash; -use move_core_types::{ - account_address::AccountAddress, ident_str, identifier::IdentStr, value::MoveValue, -}; -use moveos_types::{ - module_binding::{ModuleBinding, MoveFunctionCaller}, - move_std::option::MoveOption, - moveos_std::{ - object::{self, ObjectID}, - tx_context::TxContext, - }, - state::MoveStructType, - state::{MoveState, MoveStructState}, - transaction::FunctionCall, -}; -use serde::{Deserialize, Serialize}; - -pub const MODULE_NAME: &IdentStr = ident_str!("light_client"); - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BitcoinBlockStore { - pub latest_block_height: MoveOption, - /// block hash -> block header table id - pub blocks: ObjectID, - /// block height -> block hash table id - pub height_to_hash: ObjectID, - /// block hash -> block height table id - pub hash_to_height: ObjectID, -} - -impl BitcoinBlockStore { - pub fn object_id() -> ObjectID { - object::named_object_id(&Self::struct_tag()) - } -} - -impl MoveStructType for BitcoinBlockStore { - const MODULE_NAME: &'static IdentStr = MODULE_NAME; - const STRUCT_NAME: &'static IdentStr = ident_str!("BitcoinBlockStore"); - const ADDRESS: AccountAddress = BITCOIN_MOVE_ADDRESS; -} - -impl MoveStructState for BitcoinBlockStore { - fn struct_layout() -> move_core_types::value::MoveStructLayout { - move_core_types::value::MoveStructLayout::new(vec![ - MoveOption::::type_layout(), - ObjectID::type_layout(), - ObjectID::type_layout(), - ObjectID::type_layout(), - ]) - } -} - -/// Rust bindings for BitcoinMove light_client module -pub struct BitcoinLightClientModule<'a> { - caller: &'a dyn MoveFunctionCaller, -} - -impl<'a> BitcoinLightClientModule<'a> { - pub const GET_BLOCK_FUNCTION_NAME: &'static IdentStr = ident_str!("get_block"); - pub const GET_BLOCK_BY_HEIGHT_FUNCTION_NAME: &'static IdentStr = - ident_str!("get_block_by_height"); - pub const GET_BLOCK_HEIGHT_FUNCTION_NAME: &'static IdentStr = ident_str!("get_block_height"); - pub const GET_LATEST_BLOCK_HEIGHT_FUNCTION_NAME: &'static IdentStr = - ident_str!("get_latest_block_height"); - pub const GET_UTXO_FUNCTION_NAME: &'static IdentStr = ident_str!("get_utxo"); - pub const SUBMIT_NEW_BLOCK_ENTRY_FUNCTION_NAME: &'static IdentStr = - ident_str!("submit_new_block"); - // pub const PROCESS_UTXOS_ENTRY_FUNCTION_NAME: &'static IdentStr = ident_str!("process_utxos"); - - pub fn get_block(&self, block_hash: BlockHash) -> Result> { - let call = Self::create_function_call( - Self::GET_BLOCK_FUNCTION_NAME, - vec![], - vec![MoveValue::Address(block_hash.into_address())], - ); - let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); - let block_header = - self.caller - .call_function(&ctx, call)? - .into_result() - .map(|mut values| { - let value = values.pop().expect("should have one return value"); - bcs::from_bytes::>(&value.value) - .expect("should be a valid MoveOption") - })?; - Ok(block_header.into()) - } - - pub fn get_block_by_height(&self, block_height: u64) -> Result> { - let call = Self::create_function_call( - Self::GET_BLOCK_BY_HEIGHT_FUNCTION_NAME, - vec![], - vec![MoveValue::U64(block_height)], - ); - let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); - let block_header = - self.caller - .call_function(&ctx, call)? - .into_result() - .map(|mut values| { - let value = values.pop().expect("should have one return value"); - bcs::from_bytes::>(&value.value) - .expect("should be a valid MoveOption") - })?; - Ok(block_header.into()) - } - - pub fn get_block_height(&self, block_hash: BlockHash) -> Result> { - let call = Self::create_function_call( - Self::GET_BLOCK_HEIGHT_FUNCTION_NAME, - vec![], - vec![MoveValue::Address(block_hash.into_address())], - ); - let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); - let height = self - .caller - .call_function(&ctx, call)? - .into_result() - .map(|mut values| { - let value = values.pop().expect("should have one return value"); - bcs::from_bytes::>(&value.value) - .expect("should be a valid MoveOption") - })?; - Ok(height.into()) - } - - pub fn get_latest_block_height(&self) -> Result> { - let call = - Self::create_function_call(Self::GET_LATEST_BLOCK_HEIGHT_FUNCTION_NAME, vec![], vec![]); - let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); - let height = self - .caller - .call_function(&ctx, call)? - .into_result() - .map(|mut values| { - let value = values.pop().expect("should have one return value"); - bcs::from_bytes::>(&value.value) - .expect("should be a valid MoveOption") - })?; - Ok(height.into()) - } - - pub fn create_submit_new_block_call(block_height: u64, block: bitcoin::Block) -> FunctionCall { - let block_hash = block.block_hash(); - let block = crate::bitcoin::types::Block::from(block); - Self::create_function_call( - Self::SUBMIT_NEW_BLOCK_ENTRY_FUNCTION_NAME, - vec![], - vec![ - MoveValue::U64(block_height), - MoveValue::Address(block_hash.into_address()), - MoveValue::vector_u8( - bcs::to_bytes(&block).expect("Serialize BlockHeader should success."), - ), - ], - ) - } - - pub fn create_submit_new_block_call_bytes( - block_height: u64, - block_hash: Vec, - block_body: Vec, - ) -> Result { - let block_hash = AccountAddress::from_bytes(block_hash)?; - Ok(Self::create_function_call( - Self::SUBMIT_NEW_BLOCK_ENTRY_FUNCTION_NAME, - vec![], - vec![ - MoveValue::U64(block_height), - MoveValue::Address(block_hash), - MoveValue::vector_u8(block_body), - ], - )) - } -} - -impl<'a> ModuleBinding<'a> for BitcoinLightClientModule<'a> { - const MODULE_NAME: &'static IdentStr = MODULE_NAME; - const MODULE_ADDRESS: AccountAddress = BITCOIN_MOVE_ADDRESS; - - fn new(caller: &'a impl MoveFunctionCaller) -> Self - where - Self: Sized, - { - Self { caller } - } -} diff --git a/crates/rooch-types/src/bitcoin/mod.rs b/crates/rooch-types/src/bitcoin/mod.rs index 21daee5d2c..3ed514e728 100644 --- a/crates/rooch-types/src/bitcoin/mod.rs +++ b/crates/rooch-types/src/bitcoin/mod.rs @@ -1,12 +1,203 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 +use self::types::Header; +use crate::{addresses::BITCOIN_MOVE_ADDRESS, into_address::IntoAddress}; +use anyhow::Result; +use bitcoin::BlockHash; +use move_core_types::{ + account_address::AccountAddress, ident_str, identifier::IdentStr, value::MoveValue, +}; +use moveos_types::{ + module_binding::{ModuleBinding, MoveFunctionCaller}, + move_std::option::MoveOption, + moveos_std::{ + object::{self, ObjectID}, + tx_context::TxContext, + }, + state::MoveStructType, + state::{MoveState, MoveStructState}, + transaction::FunctionCall, +}; +use serde::{Deserialize, Serialize}; + +pub const MODULE_NAME: &IdentStr = ident_str!("bitcoin"); + /// Types mapping from Bitcoin Move types to Rust types /// Module binding for the Framework pub mod brc20; pub mod genesis; -pub mod light_client; pub mod network; pub mod ord; pub mod types; pub mod utxo; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct BitcoinBlockStore { + pub latest_block_height: MoveOption, + /// block hash -> block header table id + pub blocks: ObjectID, + /// block height -> block hash table id + pub height_to_hash: ObjectID, + /// block hash -> block height table id + pub hash_to_height: ObjectID, +} + +impl BitcoinBlockStore { + pub fn object_id() -> ObjectID { + object::named_object_id(&Self::struct_tag()) + } +} + +impl MoveStructType for BitcoinBlockStore { + const MODULE_NAME: &'static IdentStr = MODULE_NAME; + const STRUCT_NAME: &'static IdentStr = ident_str!("BitcoinBlockStore"); + const ADDRESS: AccountAddress = BITCOIN_MOVE_ADDRESS; +} + +impl MoveStructState for BitcoinBlockStore { + fn struct_layout() -> move_core_types::value::MoveStructLayout { + move_core_types::value::MoveStructLayout::new(vec![ + MoveOption::::type_layout(), + ObjectID::type_layout(), + ObjectID::type_layout(), + ObjectID::type_layout(), + ]) + } +} + +/// Rust bindings for BitcoinMove bitcoin module +pub struct BitcoinModule<'a> { + caller: &'a dyn MoveFunctionCaller, +} + +impl<'a> BitcoinModule<'a> { + pub const GET_BLOCK_FUNCTION_NAME: &'static IdentStr = ident_str!("get_block"); + pub const GET_BLOCK_BY_HEIGHT_FUNCTION_NAME: &'static IdentStr = + ident_str!("get_block_by_height"); + pub const GET_BLOCK_HEIGHT_FUNCTION_NAME: &'static IdentStr = ident_str!("get_block_height"); + pub const GET_LATEST_BLOCK_HEIGHT_FUNCTION_NAME: &'static IdentStr = + ident_str!("get_latest_block_height"); + pub const GET_UTXO_FUNCTION_NAME: &'static IdentStr = ident_str!("get_utxo"); + pub const SUBMIT_NEW_BLOCK_ENTRY_FUNCTION_NAME: &'static IdentStr = + ident_str!("submit_new_block"); + // pub const PROCESS_UTXOS_ENTRY_FUNCTION_NAME: &'static IdentStr = ident_str!("process_utxos"); + + pub fn get_block(&self, block_hash: BlockHash) -> Result> { + let call = Self::create_function_call( + Self::GET_BLOCK_FUNCTION_NAME, + vec![], + vec![MoveValue::Address(block_hash.into_address())], + ); + let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); + let block_header = + self.caller + .call_function(&ctx, call)? + .into_result() + .map(|mut values| { + let value = values.pop().expect("should have one return value"); + bcs::from_bytes::>(&value.value) + .expect("should be a valid MoveOption") + })?; + Ok(block_header.into()) + } + + pub fn get_block_by_height(&self, block_height: u64) -> Result> { + let call = Self::create_function_call( + Self::GET_BLOCK_BY_HEIGHT_FUNCTION_NAME, + vec![], + vec![MoveValue::U64(block_height)], + ); + let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); + let block_header = + self.caller + .call_function(&ctx, call)? + .into_result() + .map(|mut values| { + let value = values.pop().expect("should have one return value"); + bcs::from_bytes::>(&value.value) + .expect("should be a valid MoveOption") + })?; + Ok(block_header.into()) + } + + pub fn get_block_height(&self, block_hash: BlockHash) -> Result> { + let call = Self::create_function_call( + Self::GET_BLOCK_HEIGHT_FUNCTION_NAME, + vec![], + vec![MoveValue::Address(block_hash.into_address())], + ); + let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); + let height = self + .caller + .call_function(&ctx, call)? + .into_result() + .map(|mut values| { + let value = values.pop().expect("should have one return value"); + bcs::from_bytes::>(&value.value) + .expect("should be a valid MoveOption") + })?; + Ok(height.into()) + } + + pub fn get_latest_block_height(&self) -> Result> { + let call = + Self::create_function_call(Self::GET_LATEST_BLOCK_HEIGHT_FUNCTION_NAME, vec![], vec![]); + let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); + let height = self + .caller + .call_function(&ctx, call)? + .into_result() + .map(|mut values| { + let value = values.pop().expect("should have one return value"); + bcs::from_bytes::>(&value.value) + .expect("should be a valid MoveOption") + })?; + Ok(height.into()) + } + + pub fn create_submit_new_block_call(block_height: u64, block: bitcoin::Block) -> FunctionCall { + let block_hash = block.block_hash(); + let block = crate::bitcoin::types::Block::from(block); + Self::create_function_call( + Self::SUBMIT_NEW_BLOCK_ENTRY_FUNCTION_NAME, + vec![], + vec![ + MoveValue::U64(block_height), + MoveValue::Address(block_hash.into_address()), + MoveValue::vector_u8( + bcs::to_bytes(&block).expect("Serialize BlockHeader should success."), + ), + ], + ) + } + + pub fn create_submit_new_block_call_bytes( + block_height: u64, + block_hash: Vec, + block_body: Vec, + ) -> Result { + let block_hash = AccountAddress::from_bytes(block_hash)?; + Ok(Self::create_function_call( + Self::SUBMIT_NEW_BLOCK_ENTRY_FUNCTION_NAME, + vec![], + vec![ + MoveValue::U64(block_height), + MoveValue::Address(block_hash), + MoveValue::vector_u8(block_body), + ], + )) + } +} + +impl<'a> ModuleBinding<'a> for BitcoinModule<'a> { + const MODULE_NAME: &'static IdentStr = MODULE_NAME; + const MODULE_ADDRESS: AccountAddress = BITCOIN_MOVE_ADDRESS; + + fn new(caller: &'a impl MoveFunctionCaller) -> Self + where + Self: Sized, + { + Self { caller } + } +} diff --git a/frameworks/bitcoin-move/doc/README.md b/frameworks/bitcoin-move/doc/README.md index 4135160e4f..691ca1ca29 100644 --- a/frameworks/bitcoin-move/doc/README.md +++ b/frameworks/bitcoin-move/doc/README.md @@ -12,10 +12,10 @@ This is the reference documentation of the Bitcoin Move Framework. ## Index +- [`0x4::bitcoin`](bitcoin.md#0x4_bitcoin) - [`0x4::bitseed`](bitseed.md#0x4_bitseed) - [`0x4::brc20`](brc20.md#0x4_brc20) - [`0x4::genesis`](genesis.md#0x4_genesis) -- [`0x4::light_client`](light_client.md#0x4_light_client) - [`0x4::network`](network.md#0x4_network) - [`0x4::opcode`](opcode.md#0x4_opcode) - [`0x4::ord`](ord.md#0x4_ord) diff --git a/frameworks/bitcoin-move/doc/bitcoin.md b/frameworks/bitcoin-move/doc/bitcoin.md new file mode 100644 index 0000000000..4f751e859e --- /dev/null +++ b/frameworks/bitcoin-move/doc/bitcoin.md @@ -0,0 +1,170 @@ + + + +# Module `0x4::bitcoin` + + + +- [Struct `TxProgressErrorLogEvent`](#0x4_bitcoin_TxProgressErrorLogEvent) +- [Resource `BitcoinBlockStore`](#0x4_bitcoin_BitcoinBlockStore) +- [Constants](#@Constants_0) +- [Function `genesis_init`](#0x4_bitcoin_genesis_init) +- [Function `get_tx`](#0x4_bitcoin_get_tx) +- [Function `get_block`](#0x4_bitcoin_get_block) +- [Function `get_block_height`](#0x4_bitcoin_get_block_height) +- [Function `get_block_by_height`](#0x4_bitcoin_get_block_by_height) +- [Function `get_latest_block_height`](#0x4_bitcoin_get_latest_block_height) +- [Function `need_process_oridinals`](#0x4_bitcoin_need_process_oridinals) + + +
use 0x1::option;
+use 0x1::string;
+use 0x1::vector;
+use 0x2::bcs;
+use 0x2::object;
+use 0x2::signer;
+use 0x2::simple_multimap;
+use 0x2::table;
+use 0x2::table_vec;
+use 0x2::type_info;
+use 0x3::bitcoin_address;
+use 0x3::timestamp;
+use 0x4::network;
+use 0x4::ord;
+use 0x4::types;
+use 0x4::utxo;
+
+ + + + + +## Struct `TxProgressErrorLogEvent` + + + +
struct TxProgressErrorLogEvent has copy, drop
+
+ + + + + +## Resource `BitcoinBlockStore` + + + +
struct BitcoinBlockStore has key
+
+ + + + + +## Constants + + + + + + +
const ErrorBlockNotFound: u64 = 1;
+
+ + + + + + + +
const ErrorBlockAlreadyProcessed: u64 = 2;
+
+ + + + + + + +
const ORDINAL_GENESIS_HEIGHT: u64 = 767430;
+
+ + + + + +## Function `genesis_init` + + + +
public(friend) fun genesis_init(_genesis_account: &signer)
+
+ + + + + +## Function `get_tx` + + + +
public fun get_tx(txid: address): option::Option<types::Transaction>
+
+ + + + + +## Function `get_block` + +Get block via block_hash + + +
public fun get_block(block_hash: address): option::Option<types::Header>
+
+ + + + + +## Function `get_block_height` + + + +
public fun get_block_height(block_hash: address): option::Option<u64>
+
+ + + + + +## Function `get_block_by_height` + +Get block via block_height + + +
public fun get_block_by_height(block_height: u64): option::Option<types::Header>
+
+ + + + + +## Function `get_latest_block_height` + +Get latest block height + + +
public fun get_latest_block_height(): option::Option<u64>
+
+ + + + + +## Function `need_process_oridinals` + + + +
public fun need_process_oridinals(block_height: u64): bool
+
diff --git a/frameworks/bitcoin-move/doc/genesis.md b/frameworks/bitcoin-move/doc/genesis.md index 539158ac6d..3cb3c49ad4 100644 --- a/frameworks/bitcoin-move/doc/genesis.md +++ b/frameworks/bitcoin-move/doc/genesis.md @@ -12,8 +12,8 @@
use 0x1::option;
 use 0x2::signer;
 use 0x2::tx_context;
+use 0x4::bitcoin;
 use 0x4::brc20;
-use 0x4::light_client;
 use 0x4::network;
 use 0x4::ord;
 use 0x4::utxo;
diff --git a/frameworks/bitcoin-move/doc/light_client.md b/frameworks/bitcoin-move/doc/light_client.md
deleted file mode 100644
index 36fc7f96f0..0000000000
--- a/frameworks/bitcoin-move/doc/light_client.md
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
-
-# Module `0x4::light_client`
-
-
-
--  [Struct `TxProgressErrorLogEvent`](#0x4_light_client_TxProgressErrorLogEvent)
--  [Resource `BitcoinBlockStore`](#0x4_light_client_BitcoinBlockStore)
--  [Constants](#@Constants_0)
--  [Function `genesis_init`](#0x4_light_client_genesis_init)
--  [Function `get_tx`](#0x4_light_client_get_tx)
--  [Function `get_block`](#0x4_light_client_get_block)
--  [Function `get_block_height`](#0x4_light_client_get_block_height)
--  [Function `get_block_by_height`](#0x4_light_client_get_block_by_height)
--  [Function `get_latest_block_height`](#0x4_light_client_get_latest_block_height)
--  [Function `need_process_oridinals`](#0x4_light_client_need_process_oridinals)
-
-
-
use 0x1::option;
-use 0x1::string;
-use 0x1::vector;
-use 0x2::bcs;
-use 0x2::object;
-use 0x2::signer;
-use 0x2::simple_multimap;
-use 0x2::table;
-use 0x2::table_vec;
-use 0x2::type_info;
-use 0x3::bitcoin_address;
-use 0x3::timestamp;
-use 0x4::network;
-use 0x4::ord;
-use 0x4::types;
-use 0x4::utxo;
-
- - - - - -## Struct `TxProgressErrorLogEvent` - - - -
struct TxProgressErrorLogEvent has copy, drop
-
- - - - - -## Resource `BitcoinBlockStore` - - - -
struct BitcoinBlockStore has key
-
- - - - - -## Constants - - - - - - -
const ErrorBlockNotFound: u64 = 1;
-
- - - - - - - -
const ErrorBlockAlreadyProcessed: u64 = 2;
-
- - - - - - - -
const ORDINAL_GENESIS_HEIGHT: u64 = 767430;
-
- - - - - -## Function `genesis_init` - - - -
public(friend) fun genesis_init(_genesis_account: &signer)
-
- - - - - -## Function `get_tx` - - - -
public fun get_tx(txid: address): option::Option<types::Transaction>
-
- - - - - -## Function `get_block` - -Get block via block_hash - - -
public fun get_block(block_hash: address): option::Option<types::Header>
-
- - - - - -## Function `get_block_height` - - - -
public fun get_block_height(block_hash: address): option::Option<u64>
-
- - - - - -## Function `get_block_by_height` - -Get block via block_height - - -
public fun get_block_by_height(block_height: u64): option::Option<types::Header>
-
- - - - - -## Function `get_latest_block_height` - -Get latest block height - - -
public fun get_latest_block_height(): option::Option<u64>
-
- - - - - -## Function `need_process_oridinals` - - - -
public fun need_process_oridinals(block_height: u64): bool
-
diff --git a/frameworks/bitcoin-move/sources/light_client.move b/frameworks/bitcoin-move/sources/bitcoin.move similarity index 99% rename from frameworks/bitcoin-move/sources/light_client.move rename to frameworks/bitcoin-move/sources/bitcoin.move index 629cf30d6e..dec3290f9f 100644 --- a/frameworks/bitcoin-move/sources/light_client.move +++ b/frameworks/bitcoin-move/sources/bitcoin.move @@ -1,7 +1,7 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -module bitcoin_move::light_client{ +module bitcoin_move::bitcoin{ use std::option::{Self, Option}; use std::vector; use std::string::{String}; diff --git a/frameworks/bitcoin-move/sources/genesis.move b/frameworks/bitcoin-move/sources/genesis.move index 9bc1965d80..7847b05673 100644 --- a/frameworks/bitcoin-move/sources/genesis.move +++ b/frameworks/bitcoin-move/sources/genesis.move @@ -5,7 +5,7 @@ module bitcoin_move::genesis{ use std::option; use moveos_std::tx_context; use moveos_std::signer; - use bitcoin_move::light_client; + use bitcoin_move::bitcoin; use bitcoin_move::ord; use bitcoin_move::brc20; use bitcoin_move::utxo; @@ -27,7 +27,7 @@ module bitcoin_move::genesis{ utxo::genesis_init(); brc20::genesis_init(&genesis_account); ord::genesis_init(&genesis_account); - light_client::genesis_init(&genesis_account); + bitcoin::genesis_init(&genesis_account); } #[test_only] diff --git a/frameworks/bitcoin-move/sources/ord.move b/frameworks/bitcoin-move/sources/ord.move index 649e929249..d236376e08 100644 --- a/frameworks/bitcoin-move/sources/ord.move +++ b/frameworks/bitcoin-move/sources/ord.move @@ -21,7 +21,7 @@ module bitcoin_move::ord { use bitcoin_move::utxo::{Self, UTXO}; friend bitcoin_move::genesis; - friend bitcoin_move::light_client; + friend bitcoin_move::bitcoin; /// How may blocks between halvings. const SUBSIDY_HALVING_INTERVAL: u32 = 210_000; diff --git a/frameworks/bitcoin-move/sources/utxo.move b/frameworks/bitcoin-move/sources/utxo.move index 3d0a17010b..45c3fdfaeb 100644 --- a/frameworks/bitcoin-move/sources/utxo.move +++ b/frameworks/bitcoin-move/sources/utxo.move @@ -13,7 +13,7 @@ module bitcoin_move::utxo{ friend bitcoin_move::genesis; friend bitcoin_move::ord; - friend bitcoin_move::light_client; + friend bitcoin_move::bitcoin; const TEMPORARY_AREA: vector = b"temporary_area";