Remove batch splitting system (#475)
* First pass at removing batch splitting * Refactor to separate module loading from request parsing * Consolidate module functionality * Tidy up comments * Use array of modules instead of HashMap * Formatting * Use module hashes when importing modules
This commit is contained in:
parent
5dab8195b4
commit
acab26e5c1
17 changed files with 1425 additions and 1938 deletions
|
|
@ -1,10 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use hex::ToHex;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::{
|
||||
frontend::{PodRequest, Result},
|
||||
lang::parse,
|
||||
lang::{load_module, parse_request, Module},
|
||||
middleware::{CustomPredicateBatch, Params},
|
||||
};
|
||||
|
||||
|
|
@ -32,11 +30,8 @@ pub fn eth_dos_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
|
|||
eth_dos_ind(src, dst, distance)
|
||||
)
|
||||
"#;
|
||||
let batch = parse(input, params, &[])
|
||||
.expect("lang parse")
|
||||
.first_batch()
|
||||
.expect("Expected batch")
|
||||
.clone();
|
||||
let module = load_module(input, "eth_dos", params, vec![]).expect("lang parse");
|
||||
let batch = module.batch.clone();
|
||||
println!("a.0. {}", batch.predicates()[0]);
|
||||
println!("a.1. {}", batch.predicates()[1]);
|
||||
println!("a.2. {}", batch.predicates()[2]);
|
||||
|
|
@ -45,18 +40,26 @@ pub fn eth_dos_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
|
|||
}
|
||||
|
||||
pub fn eth_dos_request() -> Result<PodRequest> {
|
||||
use hex::ToHex;
|
||||
|
||||
let batch = eth_dos_batch(&Params::default())?;
|
||||
let batch_id = batch.id().encode_hex::<String>();
|
||||
let eth_dos_module = Arc::new(Module::new(batch, HashMap::new()));
|
||||
let module_hash = eth_dos_module.id().encode_hex::<String>();
|
||||
|
||||
let input = format!(
|
||||
r#"
|
||||
use batch _, _, _, eth_dos from 0x{batch_id}
|
||||
use module 0x{} as eth_dos
|
||||
REQUEST(
|
||||
eth_dos(src, dst, distance)
|
||||
eth_dos::eth_dos(src, dst, distance)
|
||||
)
|
||||
"#,
|
||||
module_hash
|
||||
);
|
||||
let parsed = parse(&input, &Params::default(), &[batch])?;
|
||||
Ok(parsed.request)
|
||||
Ok(parse_request(
|
||||
&input,
|
||||
&Params::default(),
|
||||
&[eth_dos_module],
|
||||
)?)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
frontend::{
|
||||
MainPod, MainPodBuilder, Operation, PodRequest, Result, SignedDict, SignedDictBuilder,
|
||||
},
|
||||
lang::parse,
|
||||
lang::parse_request,
|
||||
middleware::{
|
||||
self, containers::Set, hash_values, CustomPredicateRef, Params, Predicate, PublicKey,
|
||||
Signer as _, Statement, StatementArg, TypedValue, VDSet, Value,
|
||||
|
|
@ -90,8 +90,7 @@ pub fn zu_kyc_pod_request(gov_signer: &Value, pay_signer: &Value) -> Result<PodR
|
|||
)
|
||||
"#,
|
||||
);
|
||||
let parsed = parse(&input, &Params::default(), &[])?;
|
||||
Ok(parsed.request)
|
||||
Ok(parse_request(&input, &Params::default(), &[])?)
|
||||
}
|
||||
|
||||
// ETHDoS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue