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

Use CKB 2nd hardfork #16

Merged
merged 2 commits into from
Jan 30, 2024
Merged
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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ TARGET := riscv64-unknown-linux-gnu
CC := $(TARGET)-gcc
LD := $(TARGET)-gcc
OBJCOPY := $(TARGET)-objcopy
CFLAGS := -fPIC -O3 -fno-builtin-printf -fno-builtin-memcmp -nostdinc -nostdlib -nostartfiles -fvisibility=hidden -fdata-sections -ffunction-sections -I deps/secp256k1/src -I deps/secp256k1 -I deps/ckb-c-std-lib -I deps/ckb-c-std-lib/libc -I deps/ckb-c-std-lib/molecule -I c -I build -Wall -Werror -Wno-nonnull -Wno-nonnull-compare -Wno-unused-function -g
CFLAGS := -fPIC -O3 -fno-builtin-printf -fno-builtin-memcmp -nostdinc -nostdlib -nostartfiles -fvisibility=hidden -fdata-sections -ffunction-sections -I deps/secp256k1/src -I deps/secp256k1 -I deps/ckb-c-std-lib -I deps/ckb-c-std-lib/libc -I deps/ckb-c-std-lib/molecule -I c -I build -Wall -Werror -Wno-nonnull -Wno-nonnull-compare -Wno-unused-function -Wno-array-bounds -Wno-stringop-overflow -g
LDFLAGS := -nostdlib -nostartfiles -fno-builtin -Wl,-static -Wl,--gc-sections
SECP256K1_SRC_20210801 := deps/secp256k1-20210801/src/ecmult_static_pre_context.h

Expand All @@ -20,8 +20,8 @@ PROTOCOL_URL := https://raw.githubusercontent.com/nervosnetwork/ckb/${PROTOCOL_V
MOLC := moleculec
MOLC_VERSION := 0.7.0

# docker pull nervos/ckb-riscv-gnu-toolchain:gnu-bionic-20191012
BUILDER_DOCKER := nervos/ckb-riscv-gnu-toolchain@sha256:aae8a3f79705f67d505d1f1d5ddc694a4fd537ed1c7e9622420a470d59ba2ec3
# docker pull nervos/ckb-riscv-gnu-toolchain:gnu-jammy-20230214
BUILDER_DOCKER := nervos/ckb-riscv-gnu-toolchain@sha256:d3f649ef8079395eb25a21ceaeb15674f47eaa2d8cc23adc8bcdae3d5abce6ec
CLANG_FORMAT_DOCKER := kason223/clang-format@sha256:3cce35b0400a7d420ec8504558a02bdfc12fd2d10e40206f140c4545059cd95d

all: build/omni_lock build/always_success
Expand Down
27 changes: 20 additions & 7 deletions tests/omni_lock_rust/tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ fn build_script(
let hash_type = if is_type {
ScriptHashType::Type
} else {
ScriptHashType::Data
ScriptHashType::Data1
};

let script = Script::new_builder()
Expand Down Expand Up @@ -492,7 +492,7 @@ pub fn build_always_success_script() -> Script {
let data_hash = CellOutput::calc_data_hash(&ALWAYS_SUCCESS);
Script::new_builder()
.code_hash(data_hash.clone())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data1.into())
.build()
}

Expand All @@ -519,7 +519,7 @@ pub fn build_omni_lock_script(config: &mut TestConfig, args: Bytes) -> Script {
Script::new_builder()
.args(args.pack())
.code_hash(sighash_all_cell_data_hash.clone())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data1.into())
.build()
}

Expand Down Expand Up @@ -560,7 +560,7 @@ pub fn append_input_lock_script_hash(
let script = Script::new_builder()
.args(Default::default())
.code_hash(hash.clone())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data1.into())
.build();
let blake160 = {
let hash = script.calc_script_hash();
Expand Down Expand Up @@ -995,7 +995,7 @@ pub fn gen_tx_with_grouped_args(
let script = Script::new_builder()
.args(args.pack())
.code_hash(sighash_all_cell_data_hash.clone())
.hash_type(ScriptHashType::Data.into())
.hash_type(ScriptHashType::Data1.into())
.build();
config.running_script = script.clone();
let previous_output_cell = CellOutput::new_builder()
Expand Down Expand Up @@ -2124,7 +2124,18 @@ pub fn verify_tx(
resolved_tx: ResolvedTransaction,
data_loader: DummyDataLoader,
) -> TransactionScriptsVerifier<DummyDataLoader> {
let hard_fork = HardForks::new_mirana();
let hard_fork = HardForks {
ckb2021: ckb_types::core::hardfork::CKB2021::new_mirana()
.as_builder()
.rfc_0032(5)
.build()
.unwrap(),
ckb2023: ckb_types::core::hardfork::CKB2023::new_mirana()
.as_builder()
.rfc_0049(10)
.build()
.unwrap(),
};
let consensus = ConsensusBuilder::default()
.hardfork_switch(hard_fork)
.build();
Expand All @@ -2133,7 +2144,9 @@ pub fn verify_tx(
data_loader.clone(),
Arc::new(consensus),
Arc::new(TxVerifyEnv::new_commit(
&HeaderView::new_advanced_builder().build(),
&HeaderView::new_advanced_builder()
.epoch(ckb_types::core::EpochNumberWithFraction::new(5, 0, 1).pack())
.build(),
)),
)
}
Expand Down
Loading