Skip to content

Commit

Permalink
Merge commit 'e619c845f9b532430c65858ba2e0d2ff1c4b9e86'
Browse files Browse the repository at this point in the history
* commit 'e619c845f9b532430c65858ba2e0d2ff1c4b9e86':
  [VM] Refactor view_function result, return the VMStatus to caller (rooch-network#646)
  add `rooch server clean` to rooch cli (rooch-network#634)
  fix const typo => `EFunctionCallBeyondSessionScope` (rooch-network#645)
  [rooch-networkgh-641] unify coin id to u64 and refactor blockchain scheme. (rooch-network#642)
  [SessionKey] Check the transaction va session scope (rooch-network#640)
  implement accumulator store and proof verification (rooch-network#605)
  refine README.md (rooch-network#639)
  [rooch-networkgh-621] refactor algorithms and validators. (rooch-network#636)
  update `rooch-cli.zh-CN.mdx` and translate it (rooch-network#637)
  [CLI] Support session key in CLI (rooch-network#629)
  Auto test for module publishing in Move (rooch-network#632)
  typescript sdk part of issues/585 (rooch-network#597)
  [types] Migrate module bindings from rooch-framework to rooch-types (rooch-network#623)
  add weekly 2023-08-14 (rooch-network#624)
  Detecting global storage instructions during module publishing. (rooch-network#619)
  [rooch-networkgh-609] refactor validators for other schemes. (rooch-network#610)
  Verify and publish modules in Move (rooch-network#392)
  Feature owen opt client code gen (rooch-network#600)
  Use generic parameter placeholders. (rooch-network#614)
  • Loading branch information
wubuku committed Aug 17, 2023
2 parents d5853ac + e619c84 commit c0ff65e
Show file tree
Hide file tree
Showing 234 changed files with 11,265 additions and 5,455 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:
run: cd sdk/typescript && npm install pnpm -g && pnpm install
- name: Gen SDK dependencie Code
run: cd sdk/typescript && pnpm gen
- name: Lint SDK
run: cd sdk/typescript && pnpm run lint
- name: Build SDK
run: cd sdk/typescript && pnpm run build
- name: Test SDK
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ git clone https://github.com/<GITHUB-USER-NAME>/rooch.git`
**当您要请求一个新特性时**,在当前的 Issues 页面标题栏上填写特性的简介描述作为标题,并在标题前加上 `[Feature Request]` 作为标识。

填写好相关信息后,点击右侧的 `Lables`,打上相应的标签,并点击下方的 `Submit new issue` 按钮。

## 行为准则

请参阅[行为准则](CODE_OF_CONDUCT.md),其中描述了社区内的互动要求。
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ Reporting issues and submitting feature requests is usually done by submitting c
**When you want to request a new feature**, fill in the brief description of the feature on the title bar of the current Issues page as the title, and add `[Feature Request]` as the identifier before the title.

After filling in the relevant information, click on `Lables` on the right, label it accordingly, and click on the `Submit new issue` button below.

## Code of Conduct

Please refer to the [Code of Conduct](CODE_OF_CONDUCT.md), which describes the expectations for interactions within the community.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"moveos/moveos",
"moveos/moveos-commons/moveos-common",
"moveos/moveos-commons/timeout-join-handler",
"moveos/moveos-commons/accumulator",
"moveos/raw-store",
"moveos/metrics",
"moveos/moveos-config",
Expand Down Expand Up @@ -189,6 +190,9 @@ rust_secp256k1 = { version = "0.27.0", package = "secp256k1", features = ["recov
bcs-ext = { path = "moveos/moveos-commons/bcs_ext" }
tower = { version = "0.4.12", features = ["full", "util", "timeout", "load-shed", "limit"] }
tower-http = { version = "0.3.4", features = ["cors", "full", "trace", "set-header", "propagate-header"] }
mirai-annotations = "1.12.0"
lru = "0.11.0"
accumulator = { path = "moveos/moveos-commons/accumulator" }

# Note: the BEGIN and END comments below are required for external tooling. Do not remove.
# BEGIN MOVE DEPENDENCIES
Expand Down
88 changes: 61 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,107 @@
# Rooch

[Rooch](https://rooch.network) is a modular DApp container with the [Move language](https://github.com/move-language/move).

<div align="center">
<br />
<br />
<a href="https://rooch.network"><img alt="Rooch" src="https://rooch.network/logo/rooch_black_combine.svg" width=384></a>
<br />
<h3><a href="https://rooch.network">Rooch</a> is Modular DApp Container, with <a href="https://github.com/move-language/move)">Move.</a></h3>
<br />
</div>

[![Check-Build-Test](https://github.com/rooch-network/rooch/actions/workflows/check_build_test.yml/badge.svg)](https://github.com/rooch-network/rooch/actions/workflows/check_build_test.yml)
[![License](https://img.shields.io/badge/license-Apache-green.svg)](LICENSE)
[![LoC](https://tokei.rs/b1/github/rooch-network/rooch?category=lines)](https://github.com/rooch-network/rooch)

## Usage

1. Rooch Ethereum Layer2: Rooch(Execution) + Layer1s(Settlement) + Ethereum(Arbitration) + DA
2. XChain Modular DApp: Rooch(Execution) + XChain(Settlement + Arbitration) + DA
3. Rooch Layer3 Modular DApp: Rooch(Execution) + Rooch Layer2(Settlement + Arbitration) + DA
4. Sovereign Rollup: Rooch + DA
* **Multi-Chain Layer2**: Rooch(Execution) + Multi-Chain(Settlement) + Ethereum(Arbitration) + DA
* **X-Chain Modular DApp**: Rooch(Execution) + X-Chain(Settlement + Arbitration) + DA
* **Layer3 Modular DApp**: Rooch(Execution) + Rooch Layer2(Settlement + Arbitration) + DA
* **Sovereign Rollup**: Rooch + DA

## Getting Started

1. Build from source
1. Building from source:
```bash
cargo build && cp target/debug/rooch ~/.cargo/bin/
```
2. Create a new Move project

2. initialize Rooch config:
```bash
rooch move new my_move_project
rooch init
```
3. Init Rooch config

3. Creating a new Move project:
```bash
rooch init
rooch move new my_move_project
```
4. Build the Move project
4. Building the Move project:
```bash
cd my_move_project && rooch move build
```
5. Start the server

5. Starting the server
```bash
rooch server start
```
> If you want a more detailed log for debugging, you can use `RUST_LOG=debug rooch server start`
6. Publish the Move project
* *`RUST_LOG=debug rooch server start` for debugging information*

6. Publishing the Move project
```bash
rooch move publish -p my_move_project
```

*Experience Rooch through [examples](examples).*

## Deep Dive into Rooch

### [Storage Abstraction](./docs/website/pages/docs/tech-highlights/storage_abstraction.en-US.mdx)
<details>
<summary>Storage Abstraction</summary>

Storage Abstraction module overview:
- [Docs](./docs/website/pages/docs/tech-highlights/storage_abstraction.en-US.mdx)

- Overview:

![Storage Abstraction](./docs/website/public/docs/rooch-design-storage-abstraction.svg)
</details>

<details>
<summary>State DB</summary>

State DB:
- Overview:

![State DB](./docs/website/public/docs/rooch-design-statedb.svg)

### [Transaction Flow](./docs/website/pages/docs/tech-highlights/transaction_flow.en-US.mdx)
</details>

<details>
<summary>Transaction Flow</summary>

- [Docs](./docs/website/pages/docs/tech-highlights/transaction_flow.en-US.mdx)
- Overview:
![Rooch Transaction Flow](./docs/website/public/docs/rooch-design-transaction-flow-functional-perspective.svg)

</details>

## Components

* [MoveOS](./moveos): MoveOS is a standalone Move runtime environment based on [MoveVM](https://github.com/move-language/move). It provides Move execution environment for rooch.
* [MoveOS](./moveos): MoveOS is a standalone Move runtime environment based on [MoveVM](https://github.com/move-language/move). It provides Move execution environment for Rooch.

## Contributing

Rooch is an open source project, you can help with ideas, code, or documentation, we appreciate any efforts that help us to make the project better!

To get started with contributing:

[The First Good Pull Request](./CONTRIBUTING.md)

## How to Contribute
## Community

You can learn more about contributing to the Rooch project by reading our [Contribution Guide](./CONTRIBUTING.md) and by viewing our [Code of Conduct](./CODE_OF_CONDUCT.md).
* [Discord](https://discord.gg/rooch)
* [Twitter](https://twitter.com/RoochNetwork)
* [GitHub](https://github.com/rooch-network)

Rooch Network Rooch is licensed under [Apache 2.0](./LICENSE).
## License

## Join the Community
Current Rooch code is released under [Apache 2.0](./LICENSE).

To connect with the Rooch Network community, please join our [Discord](https://discord.gg/rooch).
When contributing to a Rooch feature, you can find the relevant license in the comments at the top of each file.
3 changes: 2 additions & 1 deletion crates/rooch-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ rooch-types = { workspace = true }
rooch-framework = { workspace = true }
rooch-genesis = { workspace = true }
rooch-store = { workspace = true }
rooch-config = { workspace = true }
rooch-config = { workspace = true }
accumulator = { workspace = true }
45 changes: 27 additions & 18 deletions crates/rooch-executor/src/actor/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ use crate::actor::messages::{
GetTransactionInfosByTxHashMessage, GetTxSeqMappingByTxOrderMessage,
ListAnnotatedStatesMessage, ListStatesMessage,
};
use accumulator::inmemory::InMemoryAccumulator;
use anyhow::bail;
use anyhow::Result;
use async_trait::async_trait;
use coerce::actor::{context::ActorContext, message::Handler, Actor};
use move_core_types::account_address::AccountAddress;
use move_resource_viewer::MoveValueAnnotator;
use moveos::moveos::MoveOS;
use moveos_common::accumulator::InMemoryAccumulator;
use moveos_store::transaction_store::TransactionStore;
use moveos_store::MoveOSStore;
use moveos_types::event::AnnotatedMoveOSEvent;
use moveos_types::event::EventHandle;
use moveos_types::function_return_value::AnnotatedFunctionResult;
use moveos_types::function_return_value::AnnotatedFunctionReturnValue;
use moveos_types::module_binding::MoveFunctionCaller;
use moveos_types::move_types::as_struct_tag;
Expand All @@ -31,13 +32,13 @@ use moveos_types::transaction::FunctionCall;
use moveos_types::transaction::TransactionExecutionInfo;
use moveos_types::transaction::VerifiedMoveOSTransaction;
use moveos_types::tx_context::TxContext;
use rooch_framework::bindings::address_mapping::AddressMapping;
use rooch_framework::bindings::auth_validator::AuthValidatorCaller;
use rooch_framework::bindings::transaction_validator::TransactionValidator;
use rooch_genesis::RoochGenesis;
use rooch_store::RoochStore;
use rooch_types::address::MultiChainAddress;
use rooch_types::framework::address_mapping::AddressMapping;
use rooch_types::framework::auth_validator::AuthValidatorCaller;
use rooch_types::framework::auth_validator::TxValidateResult;
use rooch_types::framework::transaction_validator::TransactionValidator;
use rooch_types::transaction::AuthenticatorInfo;
use rooch_types::transaction::{AbstractTransaction, TransactionSequenceMapping};

Expand Down Expand Up @@ -65,7 +66,7 @@ impl ExecutorActor {
multi_chain_address_sender: MultiChainAddress,
) -> Result<AccountAddress> {
let resolved_sender = {
let address_mapping = self.moveos.as_module_bundle::<AddressMapping>();
let address_mapping = self.moveos.as_module_binding::<AddressMapping>();
address_mapping.resovle_or_generate(multi_chain_address_sender)?
};

Expand Down Expand Up @@ -115,7 +116,7 @@ impl ExecutorActor {
ctx: &TxContext,
authenticator: AuthenticatorInfo,
) -> Result<(TxValidateResult, Vec<FunctionCall>, Vec<FunctionCall>)> {
let tx_validator = self.moveos.as_module_bundle::<TransactionValidator>();
let tx_validator = self.moveos.as_module_binding::<TransactionValidator>();
let tx_validate_result = tx_validator.validate(ctx, authenticator.clone())?;
let auth_validator_option = tx_validate_result.auth_validator();
match auth_validator_option {
Expand Down Expand Up @@ -222,20 +223,28 @@ impl Handler<ExecuteViewFunctionMessage> for ExecutorActor {
&mut self,
msg: ExecuteViewFunctionMessage,
_ctx: &mut ActorContext,
) -> Result<Vec<AnnotatedFunctionReturnValue>, anyhow::Error> {
) -> Result<AnnotatedFunctionResult, anyhow::Error> {
let resoler = self.moveos.moveos_resolver();

self.moveos
.execute_view_function(msg.call)?
.into_iter()
.map(|v| {
let move_value = resoler.view_value(&v.type_tag, &v.value)?;
Ok(AnnotatedFunctionReturnValue {
value: v,
move_value,
})
})
.collect::<Result<Vec<AnnotatedFunctionReturnValue>, anyhow::Error>>()
let function_result = self.moveos.execute_view_function(msg.call);
Ok(AnnotatedFunctionResult {
vm_status: function_result.vm_status,
return_values: match function_result.return_values {
Some(values) => Some(
values
.into_iter()
.map(|v| {
let move_value = resoler.view_value(&v.type_tag, &v.value)?;
Ok(AnnotatedFunctionReturnValue {
value: v,
move_value,
})
})
.collect::<Result<Vec<AnnotatedFunctionReturnValue>, anyhow::Error>>()?,
),
None => None,
},
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/rooch-executor/src/actor/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use move_core_types::language_storage::StructTag;
use moveos_types::access_path::AccessPath;
use moveos_types::event::AnnotatedMoveOSEvent;
use moveos_types::event_filter::EventFilter;
use moveos_types::function_return_value::AnnotatedFunctionReturnValue;
use moveos_types::function_return_value::AnnotatedFunctionResult;
use moveos_types::h256::H256;
use moveos_types::state::{AnnotatedState, State};
use moveos_types::transaction::FunctionCall;
Expand Down Expand Up @@ -51,7 +51,7 @@ pub struct ExecuteViewFunctionMessage {
}

impl Message for ExecuteViewFunctionMessage {
type Result = Result<Vec<AnnotatedFunctionReturnValue>, anyhow::Error>;
type Result = Result<AnnotatedFunctionResult, anyhow::Error>;
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down
8 changes: 3 additions & 5 deletions crates/rooch-executor/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ use anyhow::Result;
use coerce::actor::ActorRef;
use move_core_types::account_address::AccountAddress;
use move_core_types::language_storage::StructTag;
use moveos_types::function_return_value::AnnotatedFunctionResult;
use moveos_types::h256::H256;
use moveos_types::transaction::FunctionCall;
use moveos_types::transaction::TransactionExecutionInfo;
use moveos_types::transaction::TransactionOutput;
use moveos_types::{
access_path::AccessPath, function_return_value::AnnotatedFunctionReturnValue,
transaction::VerifiedMoveOSTransaction,
};
use moveos_types::{access_path::AccessPath, transaction::VerifiedMoveOSTransaction};
use moveos_types::{
event::AnnotatedMoveOSEvent,
event_filter::EventFilter,
Expand Down Expand Up @@ -64,7 +62,7 @@ impl ExecutorProxy {
pub async fn execute_view_function(
&self,
call: FunctionCall,
) -> Result<Vec<AnnotatedFunctionReturnValue>> {
) -> Result<AnnotatedFunctionResult> {
self.actor.send(ExecuteViewFunctionMessage { call }).await?
}

Expand Down
19 changes: 13 additions & 6 deletions crates/rooch-framework-tests/src/binding_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use anyhow::{bail, Result};
use move_core_types::vm_status::KeptVMStatus;
use moveos_store::MoveOSStore;
use moveos_types::module_binding::{ModuleBundle, MoveFunctionCaller};
use rooch_executor::actor::executor::ExecutorActor;
use moveos_types::module_binding::{ModuleBinding, MoveFunctionCaller};
use rooch_executor::actor::{executor::ExecutorActor, messages::ExecuteTransactionResult};
use rooch_store::RoochStore;
use rooch_types::transaction::AbstractTransaction;

Expand All @@ -21,14 +21,13 @@ impl RustBindingTest {
Ok(Self { executor })
}

pub fn as_module_bundle<'a, M: ModuleBundle<'a>>(&'a self) -> M {
self.executor.moveos().as_module_bundle::<M>()
pub fn as_module_bundle<'a, M: ModuleBinding<'a>>(&'a self) -> M {
self.executor.moveos().as_module_binding::<M>()
}

//TODO let the module bundle to execute the function
pub fn execute<T: AbstractTransaction>(&mut self, tx: T) -> Result<()> {
let verified_tx = self.executor.validate(tx)?;
let execute_result = self.executor.execute(verified_tx)?;
let execute_result = self.execute_as_result(tx)?;
if execute_result.transaction_info.status != KeptVMStatus::Executed {
bail!(
"tx should success, error: {:?}",
Expand All @@ -37,4 +36,12 @@ impl RustBindingTest {
}
Ok(())
}

pub fn execute_as_result<T: AbstractTransaction>(
&mut self,
tx: T,
) -> Result<ExecuteTransactionResult> {
let verified_tx = self.executor.validate(tx)?;
self.executor.execute(verified_tx)
}
}
Loading

0 comments on commit c0ff65e

Please sign in to comment.