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

feat: support non-x86 build #882

Merged
merged 4 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
315 changes: 174 additions & 141 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions crates/block-producer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ gw-rpc-client = { path = "../rpc-client" }
gw-utils = { path = "../utils" }
gw-dynamic-config = { path = "../dynamic-config"}
gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" }
ckb-crypto = "0.104.0"
ckb-fixed-hash = "0.104.0"
ckb-types = "0.104.0"
ckb-chain-spec = "0.104.0"
ckb-crypto = "0.105.1"
ckb-fixed-hash = "0.105.1"
ckb-types = "0.105.1"
ckb-chain-spec = "0.105.1"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
async-channel = "1.4.2"
Expand Down
2 changes: 1 addition & 1 deletion crates/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gw-store = { path = "../store" }
gw-traits = { path = "../traits" }
gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-utils = { path = "../utils" }
ckb-fixed-hash = "0.104.0"
ckb-fixed-hash = "0.105.1"
anyhow = "1.0"
thiserror = "1.0"
lazy_static = "1.4"
Expand Down
10 changes: 5 additions & 5 deletions crates/challenge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-rpc-client = { path = "../rpc-client" }
gw-traits = { path = "../traits" }
gw-utils = { path = "../utils" }
ckb-fixed-hash = "0.104.0"
ckb-types = "0.104.0"
ckb-script = "0.104.0"
ckb-traits = "0.104.0"
ckb-chain-spec = "0.104.0"
ckb-fixed-hash = "0.105.1"
ckb-types = "0.105.1"
ckb-script = "0.105.1"
ckb-traits = "0.105.1"
ckb-chain-spec = "0.105.1"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
cfg-if = "0.1"
sparse-merkle-tree = { version = "0.5.2-rc1", default-features = false }
sparse-merkle-tree = { version = "=0.5.2-rc1", default-features = false }
merkle-cbt = { version = "0.3.0", default-features = false }
gw-hash = { path = "../hash" }
thiserror = { version = "1.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
gw-jsonrpc-types = { path = "../jsonrpc-types" }
ckb-fixed-hash = "0.104.0"
ckb-fixed-hash = "0.105.1"
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json", "blocking"] }

Expand Down
2 changes: 1 addition & 1 deletion crates/dynamic-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2018"
gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-config = { path = "../config" }
gw-tx-filter = { path = "../tx-filter"}
ckb-fixed-hash = "0.104.0"
ckb-fixed-hash = "0.105.1"
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json"] }
toml = "0.5"
Expand Down
5 changes: 3 additions & 2 deletions crates/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[features]
default = ["detect-asm"]
detect-asm = ["ckb-vm/detect-asm", "ckb-vm/aot"]
detect-asm = ["ckb-vm/detect-asm", "ckb-vm-aot"]
enable-always-success-lock = []

[dependencies]
Expand All @@ -20,7 +20,8 @@ gw-traits = { path = "../traits" }
gw-utils = { path = "../utils"}
anyhow = "1.0"
blake2b-rs = "0.2"
ckb-vm = { version = "=0.21.3", features = ["detect-asm"] }
ckb-vm = { version = "=0.22.0", default-features = false }
ckb-vm-aot = { version = "=0.22.0", optional = true }
thiserror = "1.0"
lazy_static = "1.4"
rlp = "0.5.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/generator/src/backend_manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl BackendManage {
#[cfg(has_asm)]
fn aot_compile(&self, code_bytes: &Bytes) -> Result<AotCode, ckb_vm::Error> {
let vm_version = crate::types::vm::VMVersion::V1;
let mut aot_machine = ckb_vm::machine::aot::AotCompilingMachine::load(
let mut aot_machine = ckb_vm_aot::AotCompilingMachine::load(
code_bytes,
Some(Box::new(crate::vm_cost_model::instruction_cycles)),
vm_version.vm_isa(),
Expand Down
4 changes: 2 additions & 2 deletions crates/generator/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Generator {
cycles_pool: &mut cycles_pool,
context: &mut context,
}))
.instruction_cycle_func(Box::new(instruction_cycles));
.instruction_cycle_func(&instruction_cycles);
let default_machine = machine_builder.build();

#[cfg(has_asm)]
Expand All @@ -239,7 +239,7 @@ impl Generator {
}

#[cfg(has_asm)]
let mut machine = ckb_vm::machine::asm::AsmMachine::new(default_machine, aot_code_opt);
let mut machine = ckb_vm_aot::AotMachine::new(default_machine, aot_code_opt);

#[cfg(not(has_asm))]
let mut machine = TraceMachine::new(default_machine);
Expand Down
2 changes: 1 addition & 1 deletion crates/generator/src/types/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl VMVersion {
}

#[cfg(has_asm)]
pub(crate) use ckb_vm::machine::asm::AotCode;
pub(crate) use ckb_vm_aot::AotCode;

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ChallengeContext {
Expand Down
2 changes: 1 addition & 1 deletion crates/godwoken-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"

[dependencies]
anyhow = "1.0"
ckb-types = "0.104.0"
ckb-types = "0.105.1"
clap = { version = "3", features = ["derive"] }
indicatif = "0.16"
gw-block-producer = { path = "../block-producer" }
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonrpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ serde = { version = "1.0", features = ["derive"] }
faster-hex = "0.4"
gw-types = { path = "../types" }
gw-common = { path = "../common" }
ckb-jsonrpc-types = "0.104.0"
ckb-fixed-hash = "0.104.0"
ckb-jsonrpc-types = "0.105.1"
ckb-fixed-hash = "0.105.1"
anyhow = "1.0"
4 changes: 2 additions & 2 deletions crates/replay-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ gw-rpc-client = { path = "../rpc-client" }
gw-utils = { path = "../utils" }
async-jsonrpc-client = { version = "0.3.0", default-features = false, features = ["http-tokio"] }
clap = "3"
ckb-fixed-hash = "0.104.0"
ckb-types = "0.104.0"
ckb-fixed-hash = "0.105.1"
ckb-types = "0.105.1"
anyhow = "1.0"
thiserror = "1.0"
lazy_static = "1.4"
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ gw-config = { path = "../config" }
gw-types = { path = "../types" }
gw-jsonrpc-types = { path = "../jsonrpc-types" }
faster-hex = "0.4"
ckb-crypto = "0.104.0"
ckb-fixed-hash = "0.104.0"
ckb-types = "0.104.0"
ckb-crypto = "0.105.1"
ckb-fixed-hash = "0.105.1"
ckb-types = "0.105.1"
toml = "0.5"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
37 changes: 26 additions & 11 deletions crates/rpc-client/src/ckb_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use crate::{
use anyhow::{anyhow, bail, Context, Result};
use async_jsonrpc_client::{HttpClient, Params as ClientParams, Transport};
use gw_common::H256;
use gw_jsonrpc_types::{blockchain::CellDep, ckb_jsonrpc_types};
use gw_jsonrpc_types::{
blockchain::CellDep,
ckb_jsonrpc_types::{self, Either},
};
use gw_types::{offchain::TxStatus, packed::Transaction, prelude::*};
use serde::de::DeserializeOwned;
use serde_json::json;
Expand Down Expand Up @@ -86,7 +89,7 @@ impl CKBClient {
pub async fn get_transaction_with_status(
&self,
tx_hash: H256,
) -> Result<Option<ckb_jsonrpc_types::TransactionWithStatus>> {
) -> Result<Option<ckb_jsonrpc_types::TransactionWithStatusResponse>> {
self.request(
"get_transaction",
Some(ClientParams::Array(vec![json!(to_jsonh256(tx_hash))])),
Expand All @@ -97,12 +100,17 @@ impl CKBClient {
#[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))]
pub async fn get_transaction(&self, tx_hash: H256) -> Result<Option<Transaction>> {
let tx_with_status = self.get_transaction_with_status(tx_hash).await?;
Ok(tx_with_status
tx_with_status
.and_then(|tx_with_status| tx_with_status.transaction)
.map(|tv| {
let tv: ckb_jsonrpc_types::TransactionView = match tv.inner {
Either::Left(v) => v,
Either::Right(v) => unreachable!(),
};
let tx: ckb_types::packed::Transaction = tv.inner.into();
Transaction::new_unchecked(tx.as_bytes())
}))
Ok(Transaction::new_unchecked(tx.as_bytes()))
})
.transpose()
}

#[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))]
Expand Down Expand Up @@ -178,24 +186,31 @@ impl CKBClient {
contract: &str,
cell_dep: CellDep,
) -> Result<gw_jsonrpc_types::blockchain::Script> {
use ckb_jsonrpc_types::TransactionWithStatus;
use ckb_jsonrpc_types::TransactionWithStatusResponse;

let tx_hash = cell_dep.out_point.tx_hash;
let tx_with_status: Option<TransactionWithStatus> = self
let tx_with_status: Option<TransactionWithStatusResponse> = self
.request(
"get_transaction",
Some(ClientParams::Array(vec![json!(tx_hash)])),
)
.await?;
let tx = match tx_with_status {
Some(TransactionWithStatus {
let tx: ckb_jsonrpc_types::TransactionView = match tx_with_status {
Some(TransactionWithStatusResponse {
transaction: Some(tv),
..
}) => tv.inner,
}) => match tv.inner {
Either::Left(v) => v,
Either::Right(v) => unreachable!(),
},
_ => bail!("{} {} tx not found", contract, tx_hash),
};

match tx.outputs.get(cell_dep.out_point.index.value() as usize) {
match tx
.inner
.outputs
.get(cell_dep.out_point.index.value() as usize)
{
Some(output) => match output.type_.as_ref() {
Some(script) => Ok(script.to_owned().into()),
None => Err(anyhow!("{} {} tx hasn't type script", contract, tx_hash)),
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc-client/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ impl RPCClient {
let tx = ckb_types::packed::Transaction::new_unchecked(tx.as_bytes());
tx.into()
};
let dry_run_result: ckb_jsonrpc_types::DryRunResult = self
let dry_run_result: ckb_jsonrpc_types::EstimateCycles = self
.ckb
.request(
"dry_run_transaction",
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" }
gw-rpc-client = { path = "../rpc-client" }
gw-dynamic-config = { path = "../dynamic-config"}
faster-hex = "0.4"
ckb-crypto = "0.104.0"
ckb-fixed-hash = "0.104.0"
ckb-types = "0.104.0"
ckb-crypto = "0.105.1"
ckb-fixed-hash = "0.105.1"
ckb-types = "0.105.1"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
futures = "0.3.13"
Expand Down
17 changes: 8 additions & 9 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,20 @@ gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" }
godwoken-bin = { path = "../godwoken-bin" }
anyhow = "1.0"
blake2b-rs = "0.2"
ckb-vm = { version = "=0.21.3", features = ["detect-asm", "aot"] }
ckb-vm-definitions = "=0.21.3"
ckb-vm = { version = "=0.22.0", default-features = false }
thiserror = "1.0"
lazy_static = "1.4"
secp256k1 = { version = "0.21", features = ["recovery", "rand-std"] }
async-jsonrpc-client = { version = "0.3.0", default-features = false, features = ["http-tokio"] }
sha3 = "0.9.1"
hex = "0.4.2"
ckb-script = "0.104.0"
ckb-types = "0.104.0"
ckb-error = "0.104.0"
ckb-crypto = "0.104.0"
ckb-hash = "0.104.0"
ckb-traits = "0.104.0"
ckb-fixed-hash = "0.104.0"
ckb-script = "0.105.1"
ckb-types = "0.105.1"
ckb-error = "0.105.1"
ckb-crypto = "0.105.1"
ckb-hash = "0.105.1"
ckb-traits = "0.105.1"
ckb-fixed-hash = "0.105.1"
rand = "0.8"
serde = "1.0"
serde_json = "1.0"
Expand Down
28 changes: 19 additions & 9 deletions crates/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ clap = "3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0"
thiserror = "1.0"
toml = "0.5"
bech32 = "0.6.0"
tempfile = "3.1"
lazy_static = "1.3"
secp256k1 = "0.20"
secp256k1 = "0.24"
sha3 = "0.9.1"
reqwest = { version = "0.11", features = ["json"] }
ckb-jsonrpc-types = "0.104.0"
ckb-types = "0.104.0"
ckb-resource = "0.104.0"
ckb-hash = "0.104.0"
ckb-fixed-hash = "0.104.0"
ckb-sdk = "1.1"
ckb-crypto = "0.104.0"
ckb-jsonrpc-types = "0.105.1"
ckb-types = "0.105.1"
ckb-resource = "0.105.1"
ckb-hash = "0.105.1"
ckb-fixed-hash = "0.105.1"
ckb-crypto = "0.105.1"
ckb-traits = "0.105.1"
ckb-dao-utils = "0.105.1"
gw-db = { path = "../db" }
gw-types = { path = "../types" }
gw-config = { path = "../config" }
Expand All @@ -42,4 +43,13 @@ hex = "0.4"
tokio = { version = "1.15", features = ["full"] }
jsonrpc-core = "17"
csv = "1.1.6"
bech32 = "0.8.1"
tracing-subscriber = { version = "0.3.11", default-features = false, features = ["tracing-log"] }
parking_lot = "0.12"
lru = "0.8"
dashmap = "5.4"

[dev-dependencies]
ckb-chain-spec = "0.105.1"
ckb-script = "0.105.1"
ckb-mock-tx-types = "0.105.1"
2 changes: 1 addition & 1 deletion crates/tools/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::hasher::CkbHasher;
use crate::types::ScriptsDeploymentResult;
use anyhow::{anyhow, Result};
use ckb_crypto::secp::Privkey;
use ckb_crypto::secp::SECP256K1;
use ckb_fixed_hash::H256;
use ckb_sdk::SECP256K1;
use ckb_types::{
bytes::Bytes as CKBBytes, core::ScriptHashType, prelude::Builder as CKBBuilder,
prelude::Entity as CKBEntity,
Expand Down
10 changes: 5 additions & 5 deletions crates/tools/src/deploy_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ use ckb_types::bytes::{BufMut, BytesMut};
use gw_rpc_client::ckb_client::CKBClient;
use tempfile::NamedTempFile;

use ckb_fixed_hash::H256;
use ckb_hash::new_blake2b;
use ckb_jsonrpc_types as rpc_types;
use ckb_resource::CODE_HASH_SECP256K1_DATA;
use ckb_sdk::{
use crate::utils::sdk::{
constants::{MIN_SECP_CELL_CAPACITY, ONE_CKB},
traits::DefaultCellDepResolver,
util::get_max_mature_number,
Address, AddressPayload, CkbRpcClient, HumanCapacity,
};
use ckb_fixed_hash::H256;
use ckb_hash::new_blake2b;
use ckb_jsonrpc_types as rpc_types;
use ckb_resource::CODE_HASH_SECP256K1_DATA;
use ckb_types::{
bytes::Bytes,
core::{BlockView, Capacity, DepType, ScriptHashType, TransactionBuilder, TransactionView},
Expand Down
2 changes: 1 addition & 1 deletion crates/tools/src/deploy_scripts.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::utils::sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity};
use crate::{
types::{BuildScriptsResult, DeployItem, Programs, ScriptsDeploymentResult},
utils::transaction::{get_network_type, run_cmd, TYPE_ID_CODE_HASH},
};
use anyhow::{anyhow, Result};
use ckb_fixed_hash::H256;
use ckb_jsonrpc_types::{CellDep, DepType, OutPoint, Script};
use ckb_sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity};
use ckb_types::{
bytes::Bytes,
core::{Capacity, ScriptHashType},
Expand Down
2 changes: 1 addition & 1 deletion crates/tools/src/deposit_ckb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::account::{privkey_to_eth_address, read_privkey};
use crate::godwoken_rpc::GodwokenRpcClient;
use crate::hasher::CkbHasher;
use crate::types::ScriptsDeploymentResult;
use crate::utils::sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity, SECP256K1};
use crate::utils::transaction::{get_network_type, read_config, run_cmd};
use anyhow::{anyhow, Result};
use ckb_fixed_hash::H256;
use ckb_sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity, SECP256K1};
use ckb_types::{
bytes::Bytes as CKBBytes, core::ScriptHashType, packed::Script as CKBScript,
prelude::Builder as CKBBuilder, prelude::Entity as CKBEntity, prelude::Pack as CKBPack,
Expand Down
Loading