mirror of
https://github.com/tig-pool-nk/tig-monorepo.git
synced 2026-02-24 04:17:22 +08:00
Add fuel per signature argument.
This commit is contained in:
parent
6dd0cda715
commit
bb4eab1daa
@ -30,6 +30,11 @@ fn cli() -> Command {
|
||||
.default_value("2000000000")
|
||||
.value_parser(clap::value_parser!(u64)),
|
||||
)
|
||||
.arg(
|
||||
arg!(--interval [INTERVAL] "Optional amount of fuel between signatures")
|
||||
.default_value("200000000")
|
||||
.value_parser(clap::value_parser!(u64)),
|
||||
)
|
||||
.arg(
|
||||
arg!(--mem [MEM] "Optional maximum memory parameter for WASM VM")
|
||||
.default_value("1000000000")
|
||||
@ -79,6 +84,11 @@ fn cli() -> Command {
|
||||
.default_value("2000000000")
|
||||
.value_parser(clap::value_parser!(u64)),
|
||||
)
|
||||
.arg(
|
||||
arg!(--interval [INTERVAL] "Optional amount of fuel between signatures")
|
||||
.default_value("200000000")
|
||||
.value_parser(clap::value_parser!(u64)),
|
||||
)
|
||||
.arg(
|
||||
arg!(--mem [MEM] "Optional maximum memory parameter for WASM VM")
|
||||
.default_value("1000000000")
|
||||
@ -108,6 +118,7 @@ fn main() {
|
||||
sub_m.get_one::<PathBuf>("WASM").unwrap().clone(),
|
||||
*sub_m.get_one::<u64>("mem").unwrap(),
|
||||
*sub_m.get_one::<u64>("fuel").unwrap(),
|
||||
*sub_m.get_one::<u64>("interval").unwrap(),
|
||||
),
|
||||
Some(("verify_solution", sub_m)) => verify_solution(
|
||||
sub_m.get_one::<String>("SETTINGS").unwrap().clone(),
|
||||
@ -125,6 +136,7 @@ fn main() {
|
||||
sub_m.get_one::<PathBuf>("WASM").unwrap().clone(),
|
||||
*sub_m.get_one::<u64>("mem").unwrap(),
|
||||
*sub_m.get_one::<u64>("fuel").unwrap(),
|
||||
*sub_m.get_one::<u64>("interval").unwrap(),
|
||||
sub_m
|
||||
.get_many::<u64>("sampled")
|
||||
.map(|values| values.cloned().collect())
|
||||
@ -145,6 +157,7 @@ fn compute_solution(
|
||||
wasm_path: PathBuf,
|
||||
max_memory: u64,
|
||||
max_fuel: u64,
|
||||
fuel_per_signature: u64,
|
||||
) -> Result<()> {
|
||||
let settings = load_settings(&settings);
|
||||
let wasm = load_wasm(&wasm_path);
|
||||
@ -156,6 +169,7 @@ fn compute_solution(
|
||||
wasm.as_slice(),
|
||||
max_memory,
|
||||
max_fuel,
|
||||
fuel_per_signature,
|
||||
)?;
|
||||
println!("{}", jsonify(&output_data));
|
||||
if let Some(err_msg) = err_msg {
|
||||
@ -194,6 +208,7 @@ fn compute_batch(
|
||||
wasm_path: PathBuf,
|
||||
max_memory: u64,
|
||||
max_fuel: u64,
|
||||
fuel_per_signature: u64,
|
||||
sampled_nonces: Vec<u64>,
|
||||
num_workers: usize,
|
||||
) -> Result<()> {
|
||||
@ -242,6 +257,7 @@ fn compute_batch(
|
||||
wasm.as_slice(),
|
||||
max_memory,
|
||||
max_fuel,
|
||||
fuel_per_signature,
|
||||
)?;
|
||||
let is_solution = err_msg.is_none()
|
||||
&& worker::verify_solution(
|
||||
|
||||
@ -12,6 +12,7 @@ pub fn compute_solution(
|
||||
wasm: &[u8],
|
||||
max_memory: u64,
|
||||
max_fuel: u64,
|
||||
fuel_per_signature: u64,
|
||||
) -> Result<(OutputData, Option<String>)> {
|
||||
let seed = settings.calc_seed(rand_hash, nonce);
|
||||
let serialized_challenge = match settings.challenge_id.as_str() {
|
||||
@ -55,6 +56,7 @@ pub fn compute_solution(
|
||||
let mut store = Store::new(&engine, limits);
|
||||
store.limiter(|lim| lim);
|
||||
store.set_fuel(max_fuel).unwrap();
|
||||
store.set_fuel_per_signature(fuel_per_signature);
|
||||
store.update_runtime_signature(u64::from_le_bytes(seed[..8].try_into().unwrap()));
|
||||
let linker = Linker::new(&engine);
|
||||
let module = Module::new(store.engine(), wasm).expect("Failed to instantiate module");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user