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: update ckb deps for the upcoming ckb 2023 hardfork #1081

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
198 changes: 107 additions & 91 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/autorocks/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.68.2
1.72.1
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-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" }
gw-telemetry = { path = "../telemetry" }
gw-metrics = { path = "../metrics" }
ckb-crypto = "0.106"
ckb-fixed-hash = "0.106"
ckb-types = "0.106"
ckb-chain-spec = "0.106"
ckb-crypto = "0.111.0"
ckb-fixed-hash = "0.111.0"
ckb-types = "0.111.0"
ckb-chain-spec = "0.111.0"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
async-channel = "1.4.2"
Expand Down
8 changes: 5 additions & 3 deletions crates/block-producer/src/cleaner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ impl Cleaner {
let rpc_client = &self.rpc_client;
for (idx, tx_hash) in consumed_txs {
let consumed = match tx_hash {
Some(tx_hash) => {
!matches!(rpc_client.ckb.get_transaction_status(tx_hash).await?, None)
}
Some(tx_hash) => rpc_client
.ckb
.get_transaction_status(tx_hash)
.await?
.is_some(),
None => false,
};
if consumed {
Expand Down
2 changes: 1 addition & 1 deletion crates/block-producer/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl BaseInitComponents {
.ok_or_else(|| anyhow!("Eth: No allowed EoA type hashes in the rollup config"))?;
account_lock_manage.register_lock_algorithm(
eth_lock_script_type_hash.hash().unpack(),
Arc::new(Secp256k1Eth::default()),
Arc::new(Secp256k1Eth),
);
let mut gen = Generator::new(
backend_manage,
Expand Down
14 changes: 7 additions & 7 deletions crates/block-producer/src/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ mod test {
let sudt_script = Script::new_builder()
.code_hash(H256::from_u32(2).pack())
.hash_type(ScriptHashType::Type.into())
.args(vec![3u8; 32].pack())
.args([3u8; 32][..].pack())
.build();

let finalized_custodians = CollectedCustodianCells {
Expand All @@ -358,7 +358,7 @@ mod test {

let owner_lock = Script::new_builder()
.code_hash(H256::from_u32(4).pack())
.args(vec![5; 32].pack())
.args([5; 32][..].pack())
.build();

let withdrawal = {
Expand All @@ -374,7 +374,7 @@ mod test {
.build();
WithdrawalRequest::new_builder()
.raw(raw)
.signature(vec![6u8; 65].pack())
.signature([6u8; 65][..].pack())
.build()
};

Expand Down Expand Up @@ -460,7 +460,7 @@ mod test {
let sudt_script = Script::new_builder()
.code_hash(H256::from_u32(3).pack())
.hash_type(ScriptHashType::Type.into())
.args(vec![4u8; 32].pack())
.args([4u8; 32][..].pack())
.build();

let rollup_context = RollupContext {
Expand Down Expand Up @@ -497,7 +497,7 @@ mod test {
let owner_lock = Script::new_builder()
.code_hash(H256::from_u32(8).pack())
.hash_type(ScriptHashType::Type.into())
.args(vec![9u8; 32].pack())
.args([9u8; 32][..].pack())
.build();

let withdrawal_without_owner_lock = {
Expand Down Expand Up @@ -722,7 +722,7 @@ mod test {
let sudt_script = Script::new_builder()
.code_hash(H256::from_u32(3).pack())
.hash_type(ScriptHashType::Type.into())
.args(vec![4u8; 32].pack())
.args([4u8; 32][..].pack())
.build();
let rollup_config = RollupConfig::new_builder()
.l1_sudt_script_type_hash(sudt_script.code_hash())
Expand Down Expand Up @@ -793,7 +793,7 @@ mod test {
let owner_lock_script = Script::new_builder()
.code_hash(H256::from_u32(8).pack())
.hash_type(ScriptHashType::Type.into())
.args(vec![9u8; 32].pack())
.args([9u8; 32][..].pack())
.build();
let withdrawal_lock_args = WithdrawalLockArgs::new_builder()
.owner_lock_hash(owner_lock_script.hash().pack())
Expand Down
2 changes: 1 addition & 1 deletion crates/builtin-binaries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ sha2 = "0.10.6"

[build-dependencies]
includedir_codegen = "0.6.0"
ckb-fixed-hash = "0.106"
ckb-fixed-hash = "0.111.0"
anyhow = "1.0"
sha2 = "0.10.6"
2 changes: 1 addition & 1 deletion crates/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-utils = { path = "../utils" }
gw-telemetry = { path = "../telemetry" }
gw-metrics = { path = "../metrics" }
ckb-fixed-hash = "0.106"
ckb-fixed-hash = "0.111.0"
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.106"
ckb-types = "0.106"
ckb-script = "0.106"
ckb-traits = "0.106"
ckb-chain-spec = "0.106"
ckb-fixed-hash = "0.111.0"
ckb-types = "0.111.0"
ckb-script = "0.111.0"
ckb-traits = "0.111.0"
ckb-chain-spec = "0.111.0"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
41 changes: 33 additions & 8 deletions crates/challenge/src/offchain/verify_tx.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use anyhow::{anyhow, bail, Result};
use ckb_fixed_hash::H256;
use ckb_script::TransactionScriptsVerifier;
use ckb_traits::{CellDataProvider, HeaderProvider};
use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv};
use ckb_traits::{CellDataProvider, ExtensionProvider, HeaderProvider};
use ckb_types::{
bytes::Bytes,
core::{
cell::{CellMeta, CellMetaBuilder, ResolvedTransaction},
DepType, HeaderView,
DepType, EpochNumberWithFraction, HeaderView,
},
packed::{Byte32, CellDep, CellOutput, OutPoint, OutPointVec},
prelude::*,
Expand All @@ -17,8 +17,12 @@ use gw_jsonrpc_types::{
};
use gw_types::offchain::InputCellInfo;

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

pub struct TxWithContext {
pub cell_deps: Vec<InputCellInfo>,
Expand Down Expand Up @@ -84,9 +88,20 @@ pub fn verify_tx(
data_loader.extend_inputs(tx_with_context.inputs);

let resolved_tx = data_loader.resolve_tx(&tx_with_context.tx)?;
let cycles = TransactionScriptsVerifier::new(&resolved_tx, &data_loader)
.verify(max_cycles)
.map_err(|err| anyhow!("verify tx failed: {}", err))?;
let cycles = TransactionScriptsVerifier::new(
Arc::new(resolved_tx),
data_loader,
// Default consensus uses mirana hardfork.
Default::default(),
Arc::new(TxVerifyEnv::new_submit(
&HeaderView::new_advanced_builder()
.number(10000u64.pack())
.epoch(EpochNumberWithFraction::new(100, 0, 100).pack())
.build(),
)),
)
.verify(max_cycles)
.map_err(|err| anyhow!("verify tx failed: {}", err))?;

Ok(cycles)
}
Expand Down Expand Up @@ -147,6 +162,7 @@ pub fn dump_tx(
Ok(mock_tx)
}

#[derive(Clone)]
struct TxDataLoader {
rollup_cell_deps: Arc<HashMap<OutPoint, CellInfo>>,
headers: HashMap<Byte32, HeaderView>,
Expand Down Expand Up @@ -257,6 +273,15 @@ impl HeaderProvider for TxDataLoader {
}
}

impl ExtensionProvider for TxDataLoader {
fn get_block_extension(
&self,
_hash: &ckb_types::packed::Byte32,
) -> Option<ckb_types::packed::Bytes> {
None
}
}

#[derive(Clone)]
struct CellInfo {
output: CellOutput,
Expand Down
2 changes: 1 addition & 1 deletion crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ no-builtin = ["gw-builtin-binaries/no-builtin"]
[dependencies]
gw-jsonrpc-types = { path = "../jsonrpc-types" }
gw-builtin-binaries = { path = "../builtin-binaries" }
ckb-fixed-hash = "0.106"
ckb-fixed-hash = "0.111.0"
serde = { version = "1.0", features = ["derive"] }
hex = "0.4"
lazy_static = "1.4"
Expand Down
8 changes: 4 additions & 4 deletions crates/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"

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

[dependencies]
Expand All @@ -20,11 +20,11 @@ gw-store = { path = "../store" }
gw-traits = { path = "../traits" }
gw-utils = { path = "../utils"}
gw-jsonrpc-types = { path = "../jsonrpc-types" }
ckb-types = "0.106"
ckb-types = "0.111.0"
anyhow = "1.0"
blake2b-rs = "0.2"
ckb-vm = { version = "=0.22.1", default-features = false }
ckb-vm-aot = { version = "=0.22", optional = true }
# Use crates.io version if our changes are merged.
ckb-vm = { git = "https://github.com/nervosnetwork/ckb-vm.git", branch = "release-0.24-l2" }
thiserror = "1.0"
lazy_static = "1.4"
rlp = "0.5.0"
Expand Down
5 changes: 4 additions & 1 deletion crates/generator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ fn main() {
let is_windows = target_family == "windows";
let is_unix = target_family == "unix";
let is_x86_64 = target_arch == "x86_64";
let can_enable_asm = is_x86_64 && (is_windows || is_unix);
let is_aarch64 = target_arch == "aarch64";
let x64_asm = is_x86_64 && (is_windows || is_unix);
let aarch64_asm = is_aarch64 && is_unix;
let can_enable_asm = x64_asm || aarch64_asm;

if cfg!(feature = "asm") && (!can_enable_asm) {
panic!("asm feature can only be enabled on x86_64 Linux, macOS and Windows platforms!");
Expand Down
2 changes: 1 addition & 1 deletion crates/generator/src/account_lock_manage/always_success.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct AlwaysSuccess;
/// Usage
/// register AlwaysSuccess to AccountLockManage
///
/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess::default()));
/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess));
impl LockAlgorithm for AlwaysSuccess {
fn recover(&self, _message: H256, _signature: &[u8]) -> Result<Bytes, LockAlgorithmError> {
Ok(Default::default())
Expand Down
13 changes: 4 additions & 9 deletions crates/generator/src/account_lock_manage/eip712/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl Withdrawal {
{
ScriptHashType::Data => "data",
ScriptHashType::Data1 => "data1",
ScriptHashType::Data2 => "data2",
ScriptHashType::Type => "type",
};
let address = RegistryAddress::from_address(address)?;
Expand Down Expand Up @@ -465,9 +466,7 @@ mod tests {
buf[64] = v;
buf
};
let pubkey_hash = Secp256k1Eth::default()
.recover(message, &signature)
.unwrap();
let pubkey_hash = Secp256k1Eth.recover(message, &signature).unwrap();
assert_eq!(hex::encode(mail.from.wallet), hex::encode(pubkey_hash));
}

Expand Down Expand Up @@ -516,9 +515,7 @@ mod tests {
};
let message = withdrawal.eip712_message(domain_seperator.hash_struct());
let signature: [u8; 65] = hex::decode("22cae59f1bfaf58f423d1a414cbcaefd45a89dd54c9142fccbb2473c74f4741b45f77f1f3680b8c0b6362957c8d79f96a683a859ccbf22a6cfc1ebc311b936d301").unwrap().try_into().unwrap();
let pubkey_hash = Secp256k1Eth::default()
.recover(message, &signature)
.unwrap();
let pubkey_hash = Secp256k1Eth.recover(message, &signature).unwrap();
assert_eq!(
"cc3e7fb0176a0e22a7f675306ceeb61d26eb0dc4".to_string(),
hex::encode(pubkey_hash)
Expand Down Expand Up @@ -554,9 +551,7 @@ mod tests {
};
let message = tx.eip712_message(domain_seperator.hash_struct());
let signature: [u8; 65] = hex::decode("64b164f5303000c283119974d7ba8f050cc7429984af904134d5cda6d3ce045934cc6b6f513ec939c2ae4cfb9cbee249ba8ae86f6274e4035c150f9c8e634a3a1b").unwrap().try_into().unwrap();
let pubkey_hash = Secp256k1Eth::default()
.recover(message, &signature)
.unwrap();
let pubkey_hash = Secp256k1Eth.recover(message, &signature).unwrap();
assert_eq!(
"e8ae579256c3b84efb76bbb69cb6bcbef1375f00".to_string(),
hex::encode(pubkey_hash)
Expand Down
16 changes: 8 additions & 8 deletions crates/generator/src/account_lock_manage/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Secp256k1Eth {
/// Usage
/// register AlwaysSuccess to AccountLockManage
///
/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess::default()));
/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess));
impl LockAlgorithm for Secp256k1Eth {
fn recover(&self, message: H256, signature: &[u8]) -> Result<Bytes, LockAlgorithmError> {
// extract rec_id
Expand Down Expand Up @@ -319,7 +319,7 @@ mod tests {
.raw(raw_tx)
.signature(signature.to_vec().pack())
.build();
let eth = Secp256k1Eth::default();
let eth = Secp256k1Eth;

let rollup_type_hash = vec![0u8; 32];

Expand Down Expand Up @@ -354,7 +354,7 @@ mod tests {
#[test]
fn test_secp256k1_eth_polyjuice_native_token_transfer() {
let chain_id = 42;
let mut polyjuice_args = vec![0u8; 72];
let mut polyjuice_args = [0u8; 72];
polyjuice_args[0..7].copy_from_slice(b"\xFF\xFF\xFFPOLY");
polyjuice_args[7] = 0;
let gas_limit: u64 = 21000;
Expand Down Expand Up @@ -410,7 +410,7 @@ mod tests {
.build(),
..Default::default()
};
let eth = Secp256k1Eth::default();
let eth = Secp256k1Eth;
eth.verify_tx(&ctx, sender_reg_addr, sender_script, receive_script, tx)
.expect("verify signature");
}
Expand Down Expand Up @@ -442,7 +442,7 @@ mod tests {
.raw(raw_tx)
.signature(signature.to_vec().pack())
.build();
let eth = Secp256k1Eth::default();
let eth = Secp256k1Eth;

// This rollup type hash is used, so the receiver script hash is:
// 00002b003de527c1d67f2a2a348683ecc9598647c30884c89c5dcf6da1afbddd,
Expand Down Expand Up @@ -510,7 +510,7 @@ mod tests {
.raw(raw_tx)
.signature(signature.to_vec().pack())
.build();
let eth = Secp256k1Eth::default();
let eth = Secp256k1Eth;

let rollup_type_hash = vec![0u8; 32];

Expand Down Expand Up @@ -555,7 +555,7 @@ mod tests {
.raw(raw_tx)
.signature(signature.to_vec().pack())
.build();
let eth = Secp256k1Eth::default();
let eth = Secp256k1Eth;

let rollup_type_hash = vec![0u8; 32];

Expand Down Expand Up @@ -644,7 +644,7 @@ mod tests {
rollup_config: RollupConfig::new_builder().chain_id(0.pack()).build(),
..Default::default()
};
let eth = Secp256k1Eth::default();
let eth = Secp256k1Eth;
eth.verify_tx(&ctx, sender_address, sender_script, receiver_script, tx)
.expect("verify signature");
}
Expand Down
Loading
Loading