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(hardfork): ckb2021 hardfork features #2715

Merged
merged 23 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
33eb0d9
fix: load cell data hash by input
zhangsoledad May 8, 2021
e640236
ci: run ci temporarily for development
yangby-cryptape May 19, 2021
3f35ca8
feat(hardfork): setup the components for hard fork features
yangby-cryptape May 19, 2021
b546065
refactor: let verifiers know the real environment that the transactio…
yangby-cryptape May 20, 2021
92a7256
feat(hardfork): in the "since epoch", the index should be less than l…
yangby-cryptape May 21, 2021
4d75c5c
feat(hardfork): use block timestamp of input cells as relative since …
yangby-cryptape May 21, 2021
d1c0bbe
feat(hardfork): allow unknown block versions and transactions versions
yangby-cryptape May 23, 2021
3cf555e
feat(hardfork): allow script multiple matches on identical data for t…
yangby-cryptape May 25, 2021
5a7efe7
feat(hardfork): reuse the uncles hash in the header as the extra hash
yangby-cryptape May 25, 2021
ba971f1
Merge branch develop (commit: 3ee1712) into branch ckb2021-develop
yangby-cryptape May 26, 2021
40847ca
refactor: remove useless parameter "with_data" because it always be t…
yangby-cryptape May 26, 2021
0a1225c
Merge branch zhangsoledad/fix_load_cell_data_hash (commit: 33eb0d9) i…
yangby-cryptape May 26, 2021
10ffedf
feat(hardfork): allow loading uncommitted cell data hashes from tx pool
yangby-cryptape May 26, 2021
0316e0e
Merge branch 'develop' into ckb2021-develop
yangby-cryptape May 31, 2021
4919ae3
fix(hardfork): a mistake when use block timestamp of input cells as r…
yangby-cryptape Jun 8, 2021
f781872
chore(hardfork): apply review suggestions about the extra hash verifi…
yangby-cryptape Jun 8, 2021
8239d1d
Revert "feat(hardfork): allow unknown block versions and transactions…
yangby-cryptape Jun 10, 2021
bc5c61f
Revert "feat(hardfork): allow loading uncommitted cell data hashes fr…
yangby-cryptape Jun 10, 2021
4e1109e
Revert "Merge branch zhangsoledad/fix_load_cell_data_hash (commit: 33…
yangby-cryptape Jun 10, 2021
56c145e
Revert "refactor: remove useless parameter "with_data" because it alw…
yangby-cryptape Jun 10, 2021
30360a2
chore(hardfork): apply review suggestions about block timestamp in since
yangby-cryptape Jun 11, 2021
6893a07
Merge branch 'develop' into zhangsoledad/ckb2021-develop-confilct-res…
zhangsoledad Jun 11, 2021
c397d22
Merge branch 'develop' into ckb2021-develop
yangby-cryptape Jun 14, 2021
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
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ matrix:
include:
# We don't run tests, linters and quck check in fork branch, since they will be covered in PR.
- name: Tests on macOS
if: 'tag IS NOT present AND (type = pull_request OR branch IN (master, staging, staging2, trying))'
if: 'tag IS NOT present AND (type = pull_request OR branch IN (master, staging, staging2, trying) OR branch =~ /^ckb2021/)'
os: osx
- name: Tests on Linux
if: 'tag IS NOT present AND (type = pull_request OR branch IN (master, staging, staging2, trying) OR repo != nervosnetwork/ckb)'
if: 'tag IS NOT present AND (type = pull_request OR branch IN (master, staging, staging2, trying) OR branch =~ /^ckb2021/ OR repo != nervosnetwork/ckb)'
os: linux
- name: PR Integration
if: 'tag IS NOT present AND branch != develop AND branch !~ /^rc\// AND (type = pull_request OR repo != nervosnetwork/ckb)'
os: linux
script: make CKB_TEST_SEC_COEFFICIENT=5 CKB_TEST_ARGS="-c 4 --no-report" integration
- name: Linters
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR repo != nervosnetwork/ckb)'
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR branch =~ /^ckb2021/ OR repo != nervosnetwork/ckb)'
os: linux
install:
- cargo fmt --version || travis_retry rustup component add rustfmt
Expand All @@ -99,7 +99,7 @@ matrix:
- make clippy
- mv rust-toolchain.bak rust-toolchain
- name: Quick Check
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR repo != nervosnetwork/ckb)'
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR branch =~ /^ckb2021/ OR repo != nervosnetwork/ckb)'
os: linux
cache: false
addons: { apt: { packages: [] } }
Expand All @@ -119,7 +119,7 @@ matrix:
script:
- devtools/ci/check-cyclic-dependencies.py --dev
- name: Security Audit & Licenses
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR repo != nervosnetwork/ckb)'
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR branch =~ /^ckb2021/ OR repo != nervosnetwork/ckb)'
os: linux
install:
- cargo deny --version || travis_retry cargo install cargo-deny --locked
Expand All @@ -129,7 +129,7 @@ matrix:
- make check-licenses

- name: WASM build
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR repo != nervosnetwork/ckb)'
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR branch =~ /^ckb2021/ OR repo != nervosnetwork/ckb)'
os: linux
script:
- export PATH=/usr/lib/llvm-8/bin:$PATH
Expand All @@ -141,11 +141,11 @@ matrix:
os: linux
script: make bench-test
- name: Integration on macOS
if: 'tag IS NOT present AND type != pull_request AND (branch IN (master, staging, staging2, trying) OR branch =~ /^rc\// OR (branch = develop AND commit_message !~ /^Merge #\d+/))'
if: 'tag IS NOT present AND type != pull_request AND (branch IN (master, staging, staging2, trying) OR branch =~ /^ckb2021/ OR branch =~ /^rc\// OR (branch = develop AND commit_message !~ /^Merge #\d+/))'
os: osx
script: make CKB_TEST_ARGS="-c 1 --no-report" integration
- name: Integration on Linux
if: 'tag IS NOT present AND type != pull_request AND (branch IN (master, staging, staging2, trying) OR branch =~ /^rc\// OR (branch = develop AND commit_message !~ /^Merge #\d+/))'
if: 'tag IS NOT present AND type != pull_request AND (branch IN (master, staging, staging2, trying) OR branch =~ /^ckb2021/ OR branch =~ /^rc\// OR (branch = develop AND commit_message !~ /^Merge #\d+/))'
os: linux
script: make CKB_TEST_ARGS="-c 1 --no-report" integration
- name: Code Coverage
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
eq(variables['Build.Reason'], 'PullRequest'),
ne(variables['System.PullRequest.SourceBranch'], 'develop')
),
eq(variables['Build.SourceBranch'], 'refs/heads/master')
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
startsWith(variables['Build.SourceBranch'], 'refs/heads/ckb2021')
)
)
pool:
Expand All @@ -41,7 +42,8 @@ jobs:
ne(variables['Build.Reason'], 'PullRequest'),
or(
startsWith(variables['Build.SourceBranch'], 'refs/heads/rc/'),
in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/develop', 'refs/heads/staging2', 'refs/heads/trying')
in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/develop', 'refs/heads/staging2', 'refs/heads/trying'),
startsWith(variables['Build.SourceBranch'], 'refs/heads/ckb2021')
)
)
pool:
Expand Down
4 changes: 3 additions & 1 deletion db-schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// Column families alias type
pub type Col = &'static str;
/// Total column number
pub const COLUMNS: u32 = 15;
pub const COLUMNS: u32 = 16;
/// Column store chain index
pub const COLUMN_INDEX: Col = "0";
/// Column store block's header
Expand Down Expand Up @@ -36,6 +36,8 @@ pub const COLUMN_CELL_DATA: Col = "12";
pub const COLUMN_NUMBER_HASH: Col = "13";
/// Column store cell data hash
pub const COLUMN_CELL_DATA_HASH: Col = "14";
/// Column store block extension data
pub const COLUMN_BLOCK_EXTENSION: Col = "15";

/// META_TIP_HEADER_KEY tracks the latest known best block header
pub const META_TIP_HEADER_KEY: &[u8] = b"TIP_HEADER";
Expand Down
10 changes: 8 additions & 2 deletions freezer/src/freezer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ impl Freezer {
.retrieve(freezer_number - 1)
.map_err(internal_error)?
.ok_or_else(|| internal_error("freezer inconsistent"))?;
let block = packed::BlockReader::from_slice(&raw_block)
let block = packed::BlockReader::from_compatible_slice(&raw_block)
.map_err(internal_error)?
.to_entity();
if block.count_extra_fields() > 1 {
return Err(internal_error("block has more than one extra fields"));
}
tip = Some(block.header().into_view());
}

Expand Down Expand Up @@ -147,9 +150,12 @@ impl Freezer {
.retrieve(item)
.map_err(internal_error)?
.expect("frozen number sync with files");
let block = packed::BlockReader::from_slice(&raw_block)
let block = packed::BlockReader::from_compatible_slice(&raw_block)
.map_err(internal_error)?
.to_entity();
if block.count_extra_fields() > 1 {
return Err(internal_error("block has more than one extra fields"));
}
inner.tip = Some(block.header().into_view());
}
Ok(())
Expand Down
13 changes: 10 additions & 3 deletions rpc/src/module/experiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use ckb_types::{
prelude::*,
H256,
};
use ckb_verification::ScriptVerifier;
use ckb_verification::{ScriptVerifier, TxVerifyEnv};
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use std::collections::HashSet;
Expand Down Expand Up @@ -248,8 +248,15 @@ impl<'a> DryRunner<'a> {
Ok(resolved) => {
let consensus = snapshot.consensus();
let max_cycles = consensus.max_block_cycles;
match ScriptVerifier::new(&resolved, &snapshot.as_data_provider())
.verify(max_cycles)
let tip_header = snapshot.tip_header();
let tx_env = TxVerifyEnv::new_submit(&tip_header);
match ScriptVerifier::new(
&resolved,
consensus,
&snapshot.as_data_provider(),
&tx_env,
)
.verify(max_cycles)
{
Ok(cycles) => Ok(DryRunResult {
cycles: cycles.into(),
Expand Down
2 changes: 2 additions & 0 deletions script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ mod syscalls;
mod type_id;
mod types;
mod verify;
mod verify_env;

pub use crate::error::{ScriptError, TransactionScriptError};
pub use crate::ill_transaction_checker::IllTransactionChecker;
pub use crate::types::{ScriptGroup, ScriptGroupType};
pub use crate::verify::TransactionScriptsVerifier;
pub use crate::verify_env::TxVerifyEnv;
Loading