Config query context interval & Add config comments

This commit is contained in:
Bruno Valente 2024-08-09 22:48:54 +08:00
parent 53449e1faa
commit b811069a66
16 changed files with 63 additions and 22 deletions

View File

@ -1,3 +1,5 @@
use std::time::Duration;
use ethereum_types::{Address, H256, U256};
use ethers::core::k256::SecretKey;
use ethers::middleware::SignerMiddleware;
@ -18,6 +20,7 @@ pub struct MinerConfig {
pub(crate) cpu_percentage: u64,
pub(crate) iter_batch: usize,
pub(crate) shard_config: ShardConfig,
pub(crate) context_query_interval: Duration,
}
pub type MineServiceMiddleware = SignerMiddleware<Provider<Http>, LocalWallet>;
@ -33,6 +36,7 @@ impl MinerConfig {
submission_gas: Option<U256>,
cpu_percentage: u64,
iter_batch: usize,
context_query_seconds: u64,
shard_config: ShardConfig,
) -> Option<MinerConfig> {
miner_key.map(|miner_key| MinerConfig {
@ -45,6 +49,7 @@ impl MinerConfig {
cpu_percentage,
iter_batch,
shard_config,
context_query_interval: Duration::from_secs(context_query_seconds),
})
}

View File

@ -35,6 +35,7 @@ pub struct MineContextWatcher {
mine_context_sender: broadcast::Sender<MineContextMessage>,
last_report: MineContextMessage,
query_interval: Duration,
msg_recv: broadcast::Receiver<MinerMessage>,
}
@ -60,6 +61,7 @@ impl MineContextWatcher {
mine_context_sender,
msg_recv,
last_report: None,
query_interval: config.context_query_interval,
};
executor.spawn(
async move { Box::pin(watcher.start()).await },
@ -95,7 +97,7 @@ impl MineContextWatcher {
}
_ = async {}, if mining_enabled && mining_throttle.is_elapsed() => {
mining_throttle.as_mut().reset(Instant::now() + Duration::from_secs(1));
mining_throttle.as_mut().reset(Instant::now() + self.query_interval);
if let Err(err) = self.query_recent_context().await {
warn!(err);
}

View File

@ -168,6 +168,7 @@ impl ZgsConfig {
let submission_gas = self.miner_submission_gas.map(U256::from);
let cpu_percentage = self.miner_cpu_percentage;
let iter_batch = self.mine_iter_batch_size;
let context_query_seconds = self.mine_context_query_seconds;
let shard_config = self.shard_config()?;
@ -180,6 +181,7 @@ impl ZgsConfig {
submission_gas,
cpu_percentage,
iter_batch,
context_query_seconds,
shard_config,
))
}

View File

@ -81,6 +81,8 @@ build_config! {
(mine_iter_batch_size, (usize), 100)
(reward_contract_address, (String), "".to_string())
(shard_position, (Option<String>), None)
(mine_context_query_seconds, (u64), 5)
}
#[derive(Debug, Default, Deserialize)]

View File

@ -179,8 +179,11 @@ log_sync_start_block_number = 802
### Mine Config Options ###
#######################################################################
# Mine contract address for incentive.
mine_contract_address = "0x85F6722319538A805ED5733c5F4882d96F1C7384"
# Mine contract address for PoRA.
mine_contract_address = "0x6176AA095C47A7F79deE2ea473B77ebf50035421"
# Reward contract address for incentive.
reward_contract_address = "0x4a62e08198b8B2a791532280bEA976EE3b024d79"
# Miner key is used to sign blockchain transaction for incentive.
# The value should be a hex string of length 64 without 0x prefix.
@ -189,6 +192,18 @@ mine_contract_address = "0x85F6722319538A805ED5733c5F4882d96F1C7384"
# transaction gas fee.
# miner_key = ""
# Period for querying mine context on chain (in seconds)
#
# Note: During each query period, nodes will issue 3 `eth_call` requests.
# If your blockchain RPC endpoint is a public or priced node, please be
# cautious not to set the period too short.
#
# mine_context_query_seconds = 5
# CPU Usage percentage for PoRA mining. 100 means one CPU core is fully loaded.
#
# miner_cpu_percentage = 100
#######################################################################
### Sharding Config Options ###
#######################################################################

View File

@ -179,9 +179,12 @@
### Mine Config Options ###
#######################################################################
# Mine contract address for incentive.
# Mine contract address for PoRA.
# mine_contract_address = ""
# Reward contract address for incentive.
# reward_contract_address = ""
# Miner key is used to sign blockchain transaction for incentive.
# The value should be a hex string of length 64 without 0x prefix.
#
@ -189,6 +192,18 @@
# transaction gas fee.
# miner_key = ""
# Period for querying mine context on chain (in seconds)
#
# Note: During each query period, nodes will issue 3 `eth_call` requests.
# If your blockchain RPC endpoint is a public or priced node, please be
# cautious not to set the period too short.
#
# mine_context_query_seconds = 5
# CPU Usage percentage for PoRA mining. 100 means one CPU core is fully loaded.
#
# miner_cpu_percentage = 100
#######################################################################
### Sharding Config Options ###
#######################################################################

View File

@ -1 +1 @@
debug,hyper=info,h2=info
debug,hyper=info,h2=info,rpc=info,discv5=info,router=info,jsonrpsee_http_server=info

View File

@ -1 +1 @@
dbeff538b949599c203e43be6ecc05e9e997d09d
a0b536c6acff24b5d4bf20d9db4e95c399e61196

File diff suppressed because one or more lines are too long

View File

@ -27,8 +27,8 @@
"type": "function"
}
],
"bytecode": "0x6080604052348015600f57600080fd5b5060a08061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063da6eb36a14602d575b600080fd5b603d6038366004603f565b505050565b005b600080600060608486031215605357600080fd5b50508135936020830135935060409092013591905056fea264697066735822122054eb84b374e7eb5c57b284f82f977fe19500436ef4128d3e147969cefdd4cbcd64736f6c63430008100033",
"deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063da6eb36a14602d575b600080fd5b603d6038366004603f565b505050565b005b600080600060608486031215605357600080fd5b50508135936020830135935060409092013591905056fea264697066735822122054eb84b374e7eb5c57b284f82f977fe19500436ef4128d3e147969cefdd4cbcd64736f6c63430008100033",
"bytecode": "0x6080604052348015600f57600080fd5b5060a08061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063da6eb36a14602d575b600080fd5b603d6038366004603f565b505050565b005b600080600060608486031215605357600080fd5b50508135936020830135935060409092013591905056fea2646970667358221220fba54ab16c6496385cdd933e87b05b9e545a857b82ffa918f0d0e4a34ae41d7164736f6c63430008100033",
"deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063da6eb36a14602d575b600080fd5b603d6038366004603f565b505050565b005b600080600060608486031215605357600080fd5b50508135936020830135935060409092013591905056fea2646970667358221220fba54ab16c6496385cdd933e87b05b9e545a857b82ffa918f0d0e4a34ae41d7164736f6c63430008100033",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@ -70,8 +70,8 @@
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5060f18061001f6000396000f3fe60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea264697066735822122031a993c3def9ed899c5b5a53bab495d498047e1a8ce262b61e700511cfb9adf164736f6c63430008100033",
"deployedBytecode": "0x60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea264697066735822122031a993c3def9ed899c5b5a53bab495d498047e1a8ce262b61e700511cfb9adf164736f6c63430008100033",
"bytecode": "0x608060405234801561001057600080fd5b5060f18061001f6000396000f3fe60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea2646970667358221220ebb4f7274983bea96e7fd68a63e91f4ad67260ff76111312d8c8559b9b5b621064736f6c63430008100033",
"deployedBytecode": "0x60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea2646970667358221220ebb4f7274983bea96e7fd68a63e91f4ad67260ff76111312d8c8559b9b5b621064736f6c63430008100033",
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long