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

chore: bump dependencies and rust-toolchain #779

Merged
1,624 changes: 646 additions & 978 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 @@ -21,10 +21,10 @@ gw-utils = { path = "../utils" }
gw-ckb-hardfork = { path = "../ckb-hardfork" }
gw-dynamic-config = { path = "../dynamic-config"}
gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" }
ckb-crypto = "0.100.0"
ckb-fixed-hash = "0.100.0"
ckb-types = "0.100.0"
ckb-chain-spec = "0.100.0"
ckb-crypto = "0.104.0"
ckb-fixed-hash = "0.104.0"
ckb-types = "0.104.0"
ckb-chain-spec = "0.104.0"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
async-channel = "1.4.2"
Expand Down
9 changes: 4 additions & 5 deletions crates/block-producer/src/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ pub async fn dump_transaction<P: AsRef<Path>>(

let mut dump_path = PathBuf::new();
dump_path.push(dir);
let json_content;
match build_mock_transaction(rpc_client, tx).await {
let json_content = match build_mock_transaction(rpc_client, tx).await {
Ok(mock_tx) => {
dump_path.push(format!("{}-mock-tx.json", tx_hash));
json_content = serde_json::to_string_pretty(&mock_tx)?;
serde_json::to_string_pretty(&mock_tx)?
}
Err(err) => {
log::error!(
Expand All @@ -47,9 +46,9 @@ pub async fn dump_transaction<P: AsRef<Path>>(
dump_path.push(format!("{}-raw-tx.json", tx_hash));
let json_tx: ckb_jsonrpc_types::Transaction =
{ ckb_types::packed::Transaction::new_unchecked(tx.as_bytes()).into() };
json_content = serde_json::to_string_pretty(&json_tx)?;
serde_json::to_string_pretty(&json_tx)?
}
}
};
log::info!("Dump transaction {} to {:?}", tx_hash, dump_path);
write(dump_path, json_content)?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/block-producer/src/poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl ChainUpdater {
fn extract_rollup_action(&self, tx: &Transaction) -> Result<RollupAction> {
let rollup_type_hash: [u8; 32] = {
let hash = self.rollup_type_script.calc_script_hash();
ckb_types::prelude::Unpack::unpack(&hash)
ckb_types::prelude::Unpack::unpack(&hash).0
};

// find rollup state cell from outputs
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.100.0"
ckb-fixed-hash = "0.104.0"
anyhow = "1.0"
thiserror = "1.0"
lazy_static = "1.4"
Expand Down
11 changes: 5 additions & 6 deletions crates/challenge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-rpc-client = { path = "../rpc-client" }
gw-traits = { path = "../traits" }
gw-utils = { path = "../utils" }
gw-ckb-hardfork = { path = "../ckb-hardfork" }
ckb-fixed-hash = "0.100.0"
ckb-types = "0.100.0"
ckb-script = "0.100.0"
ckb-traits = "0.100.0"
ckb-chain-spec = "0.100.0"
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"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
43 changes: 6 additions & 37 deletions crates/challenge/src/offchain/verify_tx.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
use anyhow::{anyhow, bail, Result};
use ckb_chain_spec::consensus::ConsensusBuilder;
use ckb_fixed_hash::H256;
use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv};
use ckb_script::TransactionScriptsVerifier;
use ckb_traits::{CellDataProvider, HeaderProvider};
use ckb_types::{
bytes::Bytes,
core::{
cell::{CellMeta, CellMetaBuilder, ResolvedTransaction},
hardfork::HardForkSwitch,
DepType, HeaderView,
},
packed::{Byte32, CellDep, CellInput, CellOutput, OutPoint, OutPointVec, Transaction},
prelude::{Builder, Entity, Pack, Unpack},
prelude::{Builder, Entity, Unpack},
};
use gw_ckb_hardfork::{GLOBAL_CURRENT_EPOCH_NUMBER, GLOBAL_HARDFORK_SWITCH};
use gw_jsonrpc_types::{
ckb_jsonrpc_types,
debugger::{ReprMockCellDep, ReprMockInfo, ReprMockInput, ReprMockTransaction},
};
use gw_types::offchain::InputCellInfo;

use std::{
collections::{HashMap, HashSet},
sync::atomic::Ordering,
};
use std::collections::{HashMap, HashSet};
use std::{convert::TryFrom, fs::read, path::PathBuf, sync::Arc};

pub struct TxWithContext {
Expand Down Expand Up @@ -90,34 +84,9 @@ pub fn verify_tx(
data_loader.extend_inputs(tx_with_context.inputs);

let resolved_tx = data_loader.resolve_tx(&tx_with_context.tx)?;

let hardfork_switch = {
let switch = GLOBAL_HARDFORK_SWITCH.load();
HardForkSwitch::new_without_any_enabled()
.as_builder()
.rfc_0028(switch.rfc_0028())
.rfc_0029(switch.rfc_0029())
.rfc_0030(switch.rfc_0030())
.rfc_0031(switch.rfc_0031())
.rfc_0032(switch.rfc_0032())
.rfc_0036(switch.rfc_0036())
.rfc_0038(switch.rfc_0038())
.build()
.map_err(|err| anyhow!(err))?
};
let consensus = ConsensusBuilder::default()
.hardfork_switch(hardfork_switch)
.build();
let current_epoch_number = GLOBAL_CURRENT_EPOCH_NUMBER.load(Ordering::SeqCst);
let tx_verify_env = TxVerifyEnv::new_submit(
&HeaderView::new_advanced_builder()
.epoch(current_epoch_number.pack())
.build(),
);
let cycles =
TransactionScriptsVerifier::new(&resolved_tx, &consensus, &data_loader, &tx_verify_env)
.verify(max_cycles)
.map_err(|err| anyhow!("verify tx failed: {}", err))?;
let cycles = TransactionScriptsVerifier::new(&resolved_tx, &data_loader)
.verify(max_cycles)
.map_err(|err| anyhow!("verify tx failed: {}", err))?;

Ok(cycles)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ckb-hardfork/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ edition = "2018"
[dependencies]
lazy_static = "1.4"
tokio = "1.15"
ckb-types = "0.100.0"
ckb-types = "0.104.0"
arc-swap = "1.5"
12 changes: 11 additions & 1 deletion crates/ckb-hardfork/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ use ckb_types::core::hardfork::HardForkSwitch;

lazy_static::lazy_static! {
pub static ref GLOBAL_VM_VERSION: AtomicU32 = AtomicU32::new(0);
// https://github.com/nervosnetwork/ckb/blob/v0.100.0/util/types/src/core/hardfork.rs#L171-L183
pub static ref GLOBAL_HARDFORK_SWITCH: ArcSwap<HardForkSwitch> = ArcSwap::from_pointee(
HardForkSwitch::new_without_any_enabled()
HardForkSwitch::new_builder()
.disable_rfc_0028()
.disable_rfc_0029()
.disable_rfc_0030()
.disable_rfc_0031()
.disable_rfc_0032()
.disable_rfc_0036()
.disable_rfc_0038()
.build()
.unwrap()
);
pub static ref GLOBAL_CURRENT_EPOCH_NUMBER: AtomicU64 = AtomicU64::new(0);
}
4 changes: 2 additions & 2 deletions crates/common/src/merkle_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ mod tests {

//rebuild proof
let proof = crate::merkle_utils::CBMTMerkleProof::new(
proof.indices().iter().copied().collect(),
proof.lemmas().iter().copied().collect(),
proof.indices().to_vec(),
proof.lemmas().to_vec(),
);

let proof_leaves: Vec<crate::smt::H256> = vec![[0u8; 32].into(), [4u8; 32].into()];
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.100.0"
ckb-fixed-hash = "0.104.0"
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json", "blocking"] }

Expand Down
4 changes: 2 additions & 2 deletions crates/dynamic-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ edition = "2018"
gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-config = { path = "../config" }
gw-tx-filter = { path = "../tx-filter"}
ckb-fixed-hash = "0.100.0"
ckb-fixed-hash = "0.104.0"
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json"] }
toml = "0.5"
anyhow = "1.0"
arc-swap = "1.5"
arc-swap = "1.5"
4 changes: 2 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"]
detect-asm = ["ckb-vm/detect-asm", "ckb-vm/aot"]
enable-always-success-lock = []

[dependencies]
Expand All @@ -21,7 +21,7 @@ gw-ckb-hardfork = { path = "../ckb-hardfork" }
gw-utils = { path = "../utils"}
anyhow = "1.0"
blake2b-rs = "0.2"
ckb-vm = { version = "=0.20.0-rc5", features = ["detect-asm"] }
ckb-vm = { version = "=0.21.3", features = ["detect-asm"] }
thiserror = "1.0"
lazy_static = "1.4"
rlp = "0.5.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/generator/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl Generator {
exit_code = _exit_code;
used_cycles = execution_cycles;
}
Err(ckb_vm::error::Error::InvalidCycles) => {
Err(ckb_vm::error::Error::CyclesExceeded) => {
exit_code = INVALID_CYCLES_EXIT_CODE;
used_cycles = max_cycles;
}
Expand Down
54 changes: 33 additions & 21 deletions crates/generator/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<'a, 'b, S: State, C: ChainView, Mac: SupportMachine> Syscalls<Mac>
if cycles_pool.consume_cycles(syscall_cycles).is_none()
|| execution_and_virtual > cycles_pool.limit()
{
return Err(VMError::LimitReached);
return Err(VMError::Unexpected("cycles pool limit reached".to_owned()));
}
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ impl<'a, 'b, S: State, C: ChainView, Mac: SupportMachine> Syscalls<Mac>
let data_addr = machine.registers()[A0].to_u64();
let len = machine.registers()[A1].to_u64();
if len > MAX_SET_RETURN_DATA_SIZE {
return Err(VMError::Unexpected);
return Err(VMError::Unexpected("exceeded max return data".to_owned()));
}
let data = load_bytes(machine, data_addr, len as usize)?;
self.result.return_data = data.into();
Expand Down Expand Up @@ -327,20 +327,23 @@ impl<'a, 'b, S: State, C: ChainView, Mac: SupportMachine> Syscalls<Mac>
SYS_LOAD_ACCOUNT_SCRIPT => {
let account_id = machine.registers()[A3].to_u32();
let script_hash = self.get_script_hash(account_id).map_err(|err| {
log::error!("syscall error: get script hash by account id: {:?}", err);
VMError::Unexpected
let err_msg =
format!("syscall error: get script hash by account id: {:?}", err);
log::error!("{}", err_msg);
VMError::Unexpected(err_msg)
})?;
// return not found if script_hash is zero, otherwise we search the script from DB
if script_hash.is_zero() {
machine.set_register(A0, Mac::REG::from_i8(GW_ERROR_ACCOUNT_NOT_FOUND));
return Ok(true);
}
let script = self.get_script(&script_hash).ok_or_else(|| {
log::error!(
let err_msg = format!(
"syscall error: script not found by script hash: {:?}",
script_hash
);
VMError::Unexpected
log::error!("{}", err_msg);
VMError::Unexpected(err_msg)
})?;
let data = script.as_slice();
store_data(machine, data)?;
Expand Down Expand Up @@ -391,12 +394,12 @@ impl<'a, 'b, S: State, C: ChainView, Mac: SupportMachine> Syscalls<Mac>

let block_hash_opt =
self.chain.get_block_hash_by_number(number).map_err(|err| {
log::error!(
let err_msg = format!(
"syscall error: get block hash by number: {}, error: {:?}",
number,
err
number, err
);
VMError::Unexpected
log::error!("{}", err_msg);
VMError::Unexpected(err_msg)
})?;
if let Some(hash) = block_hash_opt {
machine
Expand Down Expand Up @@ -494,16 +497,18 @@ impl<'a, 'b, S: State, C: ChainView, Mac: SupportMachine> Syscalls<Mac>
let payer_addr_len = machine.registers()[A1].to_u64();
// addr len: 4 registry id + 4 addr len + 20 addr
if payer_addr_len != 28u64 {
log::error!("unexpected payer address length: {}", payer_addr_len);
return Err(VMError::Unexpected);
let err_msg =
format!("unexpected payer address length: {}", payer_addr_len);
log::error!("{}", err_msg);
return Err(VMError::Unexpected(err_msg));
}
let payer_addr_bytes =
load_bytes(machine, payer_addr, payer_addr_len as usize)?;
match RegistryAddress::from_slice(&payer_addr_bytes) {
Some(addr) => addr,
None => {
log::error!("invalid payer address");
return Err(VMError::Unexpected);
return Err(VMError::Unexpected("invalid payer address".to_owned()));
}
}
};
Expand Down Expand Up @@ -538,7 +543,10 @@ impl<'a, 'b, S: State, C: ChainView> L2Syscalls<'a, 'b, S, C> {
let value = match self.result.write.write_values.get(key) {
Some(value) => *value,
None => {
let tree_value = self.state.get_raw(key).map_err(|_| VMError::Unexpected)?;
let tree_value = self
.state
.get_raw(key)
.map_err(|err| VMError::Unexpected(err.to_string()))?;
self.result.read_values.insert(*key, tree_value);
tree_value
}
Expand All @@ -550,8 +558,9 @@ impl<'a, 'b, S: State, C: ChainView> L2Syscalls<'a, 'b, S, C> {
Ok(id)
} else {
self.state.get_account_count().map_err(|err| {
log::error!("syscall error: get account count : {:?}", err);
VMError::Unexpected
let err_msg = format!("syscall error: get account count : {:?}", err);
log::error!("{}", err_msg);
VMError::Unexpected(err_msg)
})
}
}
Expand Down Expand Up @@ -587,8 +596,9 @@ impl<'a, 'b, S: State, C: ChainView> L2Syscalls<'a, 'b, S, C> {
let value = self
.get_raw(&build_account_field_key(id, GW_ACCOUNT_SCRIPT_HASH_TYPE))
.map_err(|err| {
log::error!("syscall error: get script hash by account id : {:?}", err);
VMError::Unexpected
let err_msg = format!("syscall error: get script hash by account id : {:?}", err);
log::error!("{}", err);
VMError::Unexpected(err_msg)
})?;
Ok(value)
}
Expand All @@ -599,8 +609,9 @@ impl<'a, 'b, S: State, C: ChainView> L2Syscalls<'a, 'b, S, C> {
let value = self
.get_raw(&build_script_hash_to_account_id_key(script_hash.as_slice()))
.map_err(|err| {
log::error!("syscall error: get account id by script hash : {:?}", err);
VMError::Unexpected
let err_msg = format!("syscall error: get account id by script hash : {:?}", err);
log::error!("{}", err_msg);
VMError::Unexpected(err_msg)
})?;
if value.is_zero() {
return Ok(None);
Expand All @@ -624,7 +635,8 @@ impl<'a, 'b, S: State, C: ChainView> L2Syscalls<'a, 'b, S, C> {
buffer.push(byte);
addr += 1;
}
let s = String::from_utf8(buffer).map_err(|_| VMError::ParseError)?;
let s = String::from_utf8(buffer)
.map_err(|_| VMError::Unexpected("invalid utf8 debug string".to_owned()))?;
self.redir_log_handler.append_log(s);
Ok(())
}
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 @@ -75,7 +75,7 @@ impl VMVersion {
}

#[cfg(has_asm)]
pub(crate) use ckb_vm::machine::aot::AotCode;
pub(crate) use ckb_vm::machine::asm::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.100.0"
ckb-types = "0.104.0"
clap = "2.33.3"
indicatif = "0.16"
gw-block-producer = { path = "../block-producer" }
Expand Down
Loading