-
Notifications
You must be signed in to change notification settings - Fork 289
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
Dag sync test case use 0 as fork number #4130
Dag sync test case use 0 as fork number #4130
Conversation
@@ -832,7 +873,9 @@ impl BlockChain { | |||
&tips_hash, blues | |||
); | |||
let mut blue_blocks = vec![]; | |||
let _selected_parent = blues.remove(0); | |||
let selected_parent = blues.remove(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.remove
Removes and returns the element at position index within the vector, shifting all elements after it to the left.
Note: Because this shifts over the remaining elements, it has a worst-case performance of O(n). If you don’t need the order of elements to be preserved, use [swap_remove](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.swap_remove) instead. If you’d like to remove elements from the beginning of the Vec, consider using [VecDeque::pop_front](https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.pop_front) instead.
Is this place we need check blue_blocks length greater than 1. I noticed there is another place have the same code.
let __selected_parent = blues.remove(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me think about it. Maybe it's better to do it.
.
@@ -362,7 +387,9 @@ where | |||
); | |||
let mut blue_blocks = vec![]; | |||
|
|||
let __selected_parent = blues.remove(0); | |||
let selected_parent = blues.remove(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same issue
let __selected_parent = blues.remove(0); | ||
let selected_parent = blues.remove(0); | ||
previous_header = | ||
self.get_dag_previous_header(previous_header, selected_parent)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of updating previous_header here? Do we need to update the miner
's block forging process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe he wants to solve header not update but blockdag tips update. @jackzhhuang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two questions, the second one? Is there a issue tracking on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is necessary to update the chain object in miner service.
This is the case caused by the 0 dag fork height, see test_block_chain_reset.
config/src/genesis_config.rs
Outdated
@@ -718,7 +718,7 @@ static G_EMPTY_BOOT_NODES: Lazy<Vec<MultiaddrWithPeerId>> = Lazy::new(Vec::new); | |||
const ONE_DAY: u64 = 86400; | |||
|
|||
// for test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this constant and use genesis config to set dag height. See G_DEV_CONFIG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically, this constant is used for transaction timeout and if you make sure that it is should be removed, you remove in your branch.
There are two logic in test case: one for the single chain and other for the dag chain. Both need running in the test net and 0 as fork number. But I saw the fork height in Genesis Config is u64::MAX which is not suitable for those two cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And some test case, such as test_multiple_node_sync, the miner service is a must to mint blocks automatically. But in dev net, because the config set, the block will not be minted leading to failure or timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you said, there's still lots of failed cases which need to a fix if we set dag-fork-height
as ZERO in genesis config, right? I don't think this PR has done the work as it's title says, right? Please do the job like what you said.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And some test case, such as test_multiple_node_sync, the miner service is a must to mint blocks automatically. But in dev net, because the config set, the block will not be minted leading to failure or timeout.
So change it to right value, run the tests and fix it. THX.
I really did not understand what you want. But this time, you mean I have to do the job that let the starcoin run in fork height 0 by using the config you defined? If it is, that is fine I am happy to do that. But you can say your requirement directly next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no checking the dag or not ? This is the branch sync test cases using dag fork height 0 run successfully. Any other big feature or improvement should be in other branches.
Yes. No need to check it, The genesis configuration make sure it always be a DAG, every blocks, headers are constructed for DAG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And some test case, such as test_multiple_node_sync, the miner service is a must to mint blocks automatically. But in dev net, because the config set, the block will not be minted leading to failure or timeout.
So change it to right value, run the tests and fix it. THX.
I really did not understand what you want. But this time, you mean I have to do the job that let the starcoin run in fork height 0 by using the config you defined? If it is, that is fine I am happy to do that. But you can say your requirement directly next time.
If you donot want it, don't do it. This is a small team, everyone should do his best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the pr title shows and at the meeting I was assigned to let the test cases ci run successfullly at fork height 0 and the rest will be done in your branch, now you ask me to do the rest? Ensure this or I am afraid of the code conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the pr title shows and at the meeting I was assigned to let the test cases ci run successfullly at fork height 0 and the rest will be done in your branch, now you ask me to do the rest? Ensure this or I am afraid of the code conflict.
Suit yourself.
@@ -233,7 +233,7 @@ impl SyncService { | |||
storage.get_block_info(current_block_id)?.ok_or_else(|| { | |||
format_err!("Can not find block info by id: {}", current_block_id) | |||
})?; | |||
let dag_fork_height = chain_service.dag_fork_height().await?; | |||
let dag_fork_height = Some(config.net().genesis_config().dag_effective_height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For safety, we need get to it from statedb, technically, the pre-set value is only used when executing genesis block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it means this value can be changed through somewhere, such as framework?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it means this value can be changed through somewhere, such as framework?
Yes. DAO is one way to reset it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still need dag_fork_height ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the code maintains synchronization logic of the sing chain and dag and it is flexible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember that sanlee42 suggests that we use some cfg macros @sanlee42 .
@@ -48,18 +48,15 @@ fn test_transaction_info_and_proof_1() -> Result<()> { | |||
let config = Arc::new(NodeConfig::random_for_test()); | |||
let mut block_chain = test_helper::gen_blockchain_for_test(config.net())?; | |||
|
|||
// set the flexidag fork height to G_TEST_DAG_FORK_HEIGHT | |||
block_chain | |||
.dag() | |||
.save_dag_state(*G_TEST_DAG_FORK_STATE_KEY, DagState { tips: vec![] })?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we still need G_TEST_DAG_FORK_STATE_KEY?
use starcoin_config::genesis_config::G_TEST_DAG_FORK_STATE_KEY; | ||
use starcoin_dag::consensusdb::consenses_state::DagState; | ||
|
||
dag.save_dag_state(*G_TEST_DAG_FORK_STATE_KEY, DagState { tips: vec![] })?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider remove it?
@@ -233,7 +233,7 @@ impl SyncService { | |||
storage.get_block_info(current_block_id)?.ok_or_else(|| { | |||
format_err!("Can not find block info by id: {}", current_block_id) | |||
})?; | |||
let dag_fork_height = chain_service.dag_fork_height().await?; | |||
let dag_fork_height = Some(config.net().genesis_config().dag_effective_height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it means this value can be changed through somewhere, such as framework?
I am still working on the code. I will periodically save and stage the changes. |
You can draft it until it finish. |
@@ -105,6 +105,9 @@ pub async fn test_sync_invalid_target() -> Result<()> { | |||
Ok(()) | |||
} | |||
|
|||
#[ignore = "This test is for the scenario that a block failed to connect to the main will be stored in the \ | |||
failure storage and the sync will return failure instantly the next time the block shows up again, \ | |||
which is no longer suitable for the dag"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the networkid to network with u64::max dag fork height, such as Test. This test can be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cannot be fixed as you said. You try and will know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emm... It did fail. This is a case for the single chain, and should be fixed by this walkaround solution. Could some updates break the procedures? But anyway, it's your call.
f4c705a
to
903bf14
Compare
2, return test message in apply failed function
2, return test message in apply failed function
2, remove dag genesisi enum in chain type
f7c4571
to
2a7bf8c
Compare
…arcoin into dag-master-sync-testcase0
* use 0 as fork number * fix some test case that uses 0 as fork number * check the blues returned by the ghostdata whether it is empty * use genesis config to get the dag fork number * fix clippy * basic sync dag test case pass * fix all sync test case running in the dag using the genesis config * 1, use match to determine the way of the execution and verification 2, return test message in apply failed function * fix test_flexidag_config_get_for_halley * add dag test genesis * add is dag test in test_example_config_compact * remove the used files and codes * fix test_custom_genesis * add is dag test beside the is test * fix test_generated_schema_are_up_to_date_in_git * fix fmt * add dag test in node.json * add check genesis identical between two nodes in test_sync_dag_blocks * return error if no blue uncle found, no expect no panic * add test case test_dag_uncles * fix genesis generating problem * renew halley genesis * renew halley genesis * renew halley genesis * remove the dag init in dag block execution process * 1, change dag type to chain type 2, remove dag genesisi enum in chain type * use 0 as fork number * fix some test case that uses 0 as fork number * check the blues returned by the ghostdata whether it is empty * use genesis config to get the dag fork number * fix clippy * basic sync dag test case pass * fix all sync test case running in the dag using the genesis config * 1, use match to determine the way of the execution and verification 2, return test message in apply failed function * fix test_flexidag_config_get_for_halley * add dag test genesis * add is dag test in test_example_config_compact * remove the used files and codes * fix test_custom_genesis * add is dag test beside the is test * fix test_generated_schema_are_up_to_date_in_git * fix fmt * add dag test in node.json * add check genesis identical between two nodes in test_sync_dag_blocks * return error if no blue uncle found, no expect no panic * add test case test_dag_uncles * fix genesis generating problem * renew halley genesis * renew halley genesis * renew halley genesis * remove the dag init in dag block execution process * 1, change dag type to chain type 2, remove dag genesisi enum in chain type * Fix clippy * rebase dag master * add new dag block subscribe --------- Co-authored-by: 0xa <[email protected]>
* use 0 as fork number * fix some test case that uses 0 as fork number * check the blues returned by the ghostdata whether it is empty * use genesis config to get the dag fork number * fix clippy * basic sync dag test case pass * fix all sync test case running in the dag using the genesis config * 1, use match to determine the way of the execution and verification 2, return test message in apply failed function * fix test_flexidag_config_get_for_halley * add dag test genesis * add is dag test in test_example_config_compact * remove the used files and codes * fix test_custom_genesis * add is dag test beside the is test * fix test_generated_schema_are_up_to_date_in_git * fix fmt * add dag test in node.json * add check genesis identical between two nodes in test_sync_dag_blocks * return error if no blue uncle found, no expect no panic * add test case test_dag_uncles * fix genesis generating problem * renew halley genesis * renew halley genesis * renew halley genesis * remove the dag init in dag block execution process * 1, change dag type to chain type 2, remove dag genesisi enum in chain type * use 0 as fork number * fix some test case that uses 0 as fork number * check the blues returned by the ghostdata whether it is empty * use genesis config to get the dag fork number * fix clippy * basic sync dag test case pass * fix all sync test case running in the dag using the genesis config * 1, use match to determine the way of the execution and verification 2, return test message in apply failed function * fix test_flexidag_config_get_for_halley * add dag test genesis * add is dag test in test_example_config_compact * remove the used files and codes * fix test_custom_genesis * add is dag test beside the is test * fix test_generated_schema_are_up_to_date_in_git * fix fmt * add dag test in node.json * add check genesis identical between two nodes in test_sync_dag_blocks * return error if no blue uncle found, no expect no panic * add test case test_dag_uncles * fix genesis generating problem * renew halley genesis * renew halley genesis * renew halley genesis * remove the dag init in dag block execution process * 1, change dag type to chain type 2, remove dag genesisi enum in chain type * Fix clippy * rebase dag master * add new dag block subscribe --------- Co-authored-by: 0xa <[email protected]>
* use 0 as fork number * fix some test case that uses 0 as fork number * check the blues returned by the ghostdata whether it is empty * use genesis config to get the dag fork number * fix clippy * basic sync dag test case pass * fix all sync test case running in the dag using the genesis config * 1, use match to determine the way of the execution and verification 2, return test message in apply failed function * fix test_flexidag_config_get_for_halley * add dag test genesis * add is dag test in test_example_config_compact * remove the used files and codes * fix test_custom_genesis * add is dag test beside the is test * fix test_generated_schema_are_up_to_date_in_git * fix fmt * add dag test in node.json * add check genesis identical between two nodes in test_sync_dag_blocks * return error if no blue uncle found, no expect no panic * add test case test_dag_uncles * fix genesis generating problem * renew halley genesis * renew halley genesis * renew halley genesis * remove the dag init in dag block execution process * 1, change dag type to chain type 2, remove dag genesisi enum in chain type * use 0 as fork number * fix some test case that uses 0 as fork number * check the blues returned by the ghostdata whether it is empty * use genesis config to get the dag fork number * fix clippy * basic sync dag test case pass * fix all sync test case running in the dag using the genesis config * 1, use match to determine the way of the execution and verification 2, return test message in apply failed function * fix test_flexidag_config_get_for_halley * add dag test genesis * add is dag test in test_example_config_compact * remove the used files and codes * fix test_custom_genesis * add is dag test beside the is test * fix test_generated_schema_are_up_to_date_in_git * fix fmt * add dag test in node.json * add check genesis identical between two nodes in test_sync_dag_blocks * return error if no blue uncle found, no expect no panic * add test case test_dag_uncles * fix genesis generating problem * renew halley genesis * renew halley genesis * renew halley genesis * remove the dag init in dag block execution process * 1, change dag type to chain type 2, remove dag genesisi enum in chain type * Fix clippy * rebase dag master * add new dag block subscribe --------- Co-authored-by: 0xa <[email protected]>
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Other information