Polish validator 2 --- self readcodes.#34
Conversation
* chore: polish trival by failed action * chore: polish trival
* feat: succeed to mine block * feat: mine block but receive the RecoverECDSAInnerError * remove useless code
| @@ -0,0 +1,33 @@ | |||
| #!/usr/bin/env cargo | |||
| if left_over_ms >= period_ms { | ||
| warn!("Delay invalid argument: left_over_ms={}, period_ms={}", left_over_ms, period_ms); | ||
| } else if left_over_ms >= delay_ms { | ||
| delay_ms = 0; |
There was a problem hiding this comment.
|
|
||
| pub fn seal(self, block: BscBlock) -> Result<SealedBlock<BscBlock>, ConsensusError> { | ||
| pub fn seal(&self, block: BscBlock) -> Result<SealedBlock<BscBlock>, ConsensusError> { | ||
| let header = block.header(); |
There was a problem hiding this comment.
|
|
||
| /// Returns true if `block_number` is the last block of the current turn window. | ||
| /// When turn_length is 1 (pre-Bohr), every block is considered last in turn. | ||
| pub fn last_block_in_one_turn(&self, block_number: u64) -> bool { |
There was a problem hiding this comment.
| + Sync | ||
| + 'static, | ||
| { | ||
| pub fn new( |
| } | ||
|
|
||
| /// Collect transactions from the transaction pool | ||
| async fn collect_transactions( |
| let handle = ImportHandle::new(to_import.clone(), import_outcome); | ||
|
|
||
| // Expose the sender globally so that the miner can submit newly mined blocks | ||
| if crate::shared::set_block_import_sender(to_import.clone()).is_err() { |
There was a problem hiding this comment.
block broadcast channel?
|
|
||
| let expected_hash = block.header.hash_slow(); | ||
| let sealed_block = block.seal_slow(); | ||
| let sealed_block = match &self.sealed_block { |
|
|
||
| ### Transaction Collection | ||
|
|
||
| - Fetches best transactions from the transaction pool |
There was a problem hiding this comment.
是不是需要模拟执行?? --- 看看eth怎么搞的
There was a problem hiding this comment.
ctx.provider().canonical_state_stream() 监听head逻辑?
|
|
||
| - Fetches best transactions from the transaction pool | ||
| - Respects block gas limit constraints | ||
| - Currently simplified - full transaction processing to be implemented |
|
|
||
| ### 1. Transaction Processing | ||
| ```rust | ||
| // TODO: Implement proper transaction cloning based on transaction type |
| 2. Calculate optimal mining time based on turn | ||
| 3. Collect transactions from pool | ||
| 4. Build and seal block using Parlia consensus | ||
| 5. Submit block (when implemented) |
There was a problem hiding this comment.
可能需要交给引擎api,内部有最长链判断等等 --- 将来这部分也需要修改,FF有些判定、reorg等逻辑貌似也在这部分..并且与eth是有差异的.
|
|
||
| ### With reth-bsc Components | ||
|
|
||
| - **Engine API**: Integrates with `BscPayloadServiceBuilder` |
There was a problem hiding this comment.
不一定需要吧 --- 具体看build payload是自己实现,还是依赖engine-api下的payload builder. 貌似大概率,应该自己实现,因为和system tx等等相关???--- 再想想
| ### With reth-bsc Components | ||
|
|
||
| - **Engine API**: Integrates with `BscPayloadServiceBuilder` | ||
| - **Consensus**: Uses existing Parlia consensus logic |
| ## Next Steps | ||
|
|
||
| 1. **Complete Transaction Integration**: Implement proper transaction collection and processing | ||
| 2. **Block Submission**: Connect to engine API or direct chain import |
There was a problem hiding this comment.
对 是个问题;大概率走engine-api. 不然最长链判断、内存状态维护等等,那一坨逻辑是相当多的.
|
|
||
| 🚧 **In Progress**: | ||
| - Configuration file loading | ||
| - Transaction processing |
There was a problem hiding this comment.
主体还是要参考 default_ethereum_payload !!!
| 🚧 **In Progress**: | ||
| - Configuration file loading | ||
| - Transaction processing | ||
| - Block submission to chain |
|
|
||
| ## 🚨 Important Notes | ||
|
|
||
| - **Auto-generated keys are for DEVELOPMENT only** |
|
|
||
| - **Auto-generated keys are for DEVELOPMENT only** | ||
| - **Save the generated keys if you want to reuse the same validator identity** | ||
| - **Mining will work but blocks may not be accepted without proper validator registration** |
|
|
||
| /// Use development chain with auto-generated validators | ||
| #[arg(long = "bsc-dev")] | ||
| pub dev_mode: bool, |
|
|
||
| /// Auto-generate development keys for mining | ||
| #[arg(long = "mining.dev")] | ||
| pub mining_dev: bool, |
| if let Some(ref pk_hex) = args.private_key { | ||
| mining_config.private_key_hex = Some(pk_hex.clone()); | ||
| // Derive validator address from provided key | ||
| if let Ok(sk) = mining_config::keystore::load_private_key_from_hex(pk_hex) { |
| /// Mining Service that handles block production for BSC | ||
| pub struct BscMiner<Pool, Provider> { | ||
| pool: Pool, | ||
| provider: Provider, |
| return Err("No signing key configured".into()); | ||
| }; | ||
|
|
||
| // Derive validator address from the signing key and prefer it |
| } | ||
|
|
||
| // Ensure the genesis block header is cached so that the snapshot provider can create the genesis snapshot | ||
| { |
|
|
||
| info!("Snapshot provider available, starting BSC mining service"); | ||
|
|
||
| match BscMiner::new( |
There was a problem hiding this comment.
放在这里,整体上面感觉不太对头。 临时的,再think think.
| @@ -0,0 +1,90 @@ | |||
| // TODO: tmp mock, and will remove it later. | |||
| mining_config = mining_config.ensure_keys_available(); | ||
|
|
||
| // Best-effort set; ignore error if already set | ||
| if let Err(_boxed_config) = mining_config::set_global_mining_config(mining_config) { |
| + 'static, | ||
| Evm: ConfigureEvm, | ||
| { | ||
| async fn spawn_payload_builder_service( |
| self, | ||
| ctx: &BuilderContext<Node>, | ||
| _pool: Pool, | ||
| pool: Pool, |
Description
add a description of your changes here...
Rationale
tell us why we need these changes...
Example
add an example CLI or API response...
Changes
Notable changes:
Potential Impacts