Skip to content

Commit 6195643

Browse files
mohansonXuJiandong
authored andcommitted
Use CKB 2nd hardfork (#16)
* Change to 1st hardfork
1 parent 1fe80a8 commit 6195643

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ TARGET := riscv64-unknown-linux-gnu
22
CC := $(TARGET)-gcc
33
LD := $(TARGET)-gcc
44
OBJCOPY := $(TARGET)-objcopy
5-
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
5+
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
66
LDFLAGS := -nostdlib -nostartfiles -fno-builtin -Wl,-static -Wl,--gc-sections
77
SECP256K1_SRC_20210801 := deps/secp256k1-20210801/src/ecmult_static_pre_context.h
88

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

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

2727
all: build/omni_lock build/always_success

tests/omni_lock_rust/tests/misc.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn build_script(
254254
let hash_type = if is_type {
255255
ScriptHashType::Type
256256
} else {
257-
ScriptHashType::Data
257+
ScriptHashType::Data1
258258
};
259259

260260
let script = Script::new_builder()
@@ -492,7 +492,7 @@ pub fn build_always_success_script() -> Script {
492492
let data_hash = CellOutput::calc_data_hash(&ALWAYS_SUCCESS);
493493
Script::new_builder()
494494
.code_hash(data_hash.clone())
495-
.hash_type(ScriptHashType::Data.into())
495+
.hash_type(ScriptHashType::Data1.into())
496496
.build()
497497
}
498498

@@ -519,7 +519,7 @@ pub fn build_omni_lock_script(config: &mut TestConfig, args: Bytes) -> Script {
519519
Script::new_builder()
520520
.args(args.pack())
521521
.code_hash(sighash_all_cell_data_hash.clone())
522-
.hash_type(ScriptHashType::Data.into())
522+
.hash_type(ScriptHashType::Data1.into())
523523
.build()
524524
}
525525

@@ -560,7 +560,7 @@ pub fn append_input_lock_script_hash(
560560
let script = Script::new_builder()
561561
.args(Default::default())
562562
.code_hash(hash.clone())
563-
.hash_type(ScriptHashType::Data.into())
563+
.hash_type(ScriptHashType::Data1.into())
564564
.build();
565565
let blake160 = {
566566
let hash = script.calc_script_hash();
@@ -995,7 +995,7 @@ pub fn gen_tx_with_grouped_args(
995995
let script = Script::new_builder()
996996
.args(args.pack())
997997
.code_hash(sighash_all_cell_data_hash.clone())
998-
.hash_type(ScriptHashType::Data.into())
998+
.hash_type(ScriptHashType::Data1.into())
999999
.build();
10001000
config.running_script = script.clone();
10011001
let previous_output_cell = CellOutput::new_builder()
@@ -2124,7 +2124,18 @@ pub fn verify_tx(
21242124
resolved_tx: ResolvedTransaction,
21252125
data_loader: DummyDataLoader,
21262126
) -> TransactionScriptsVerifier<DummyDataLoader> {
2127-
let hard_fork = HardForks::new_mirana();
2127+
let hard_fork = HardForks {
2128+
ckb2021: ckb_types::core::hardfork::CKB2021::new_mirana()
2129+
.as_builder()
2130+
.rfc_0032(5)
2131+
.build()
2132+
.unwrap(),
2133+
ckb2023: ckb_types::core::hardfork::CKB2023::new_mirana()
2134+
.as_builder()
2135+
.rfc_0049(10)
2136+
.build()
2137+
.unwrap(),
2138+
};
21282139
let consensus = ConsensusBuilder::default()
21292140
.hardfork_switch(hard_fork)
21302141
.build();
@@ -2133,7 +2144,9 @@ pub fn verify_tx(
21332144
data_loader.clone(),
21342145
Arc::new(consensus),
21352146
Arc::new(TxVerifyEnv::new_commit(
2136-
&HeaderView::new_advanced_builder().build(),
2147+
&HeaderView::new_advanced_builder()
2148+
.epoch(ckb_types::core::EpochNumberWithFraction::new(5, 0, 1).pack())
2149+
.build(),
21372150
)),
21382151
)
21392152
}

tests/omni_lock_rust/tests/test_omni_lock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ fn test_binary_unchanged() {
680680

681681
let actual_hash = faster_hex::hex_string(&hash);
682682
assert_eq!(
683-
"091cd5995b23f1f1e5041b88f302a1c25bc4aa2a7e223358084d1ae0f990369e",
683+
"a519c447eef1e3d0a22b2e1bec4403eb7d9305849bc2905a49917ff5565c14f0",
684684
&actual_hash
685685
);
686686
}

0 commit comments

Comments
 (0)