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
Architecture: Rename ClientApi -> SystemApi + Move CryptoUtils into VM Layer #1804
Conversation
talekhinezh
commented
May 8, 2024
- Rename ClientApi -> SystemApi
- Move CryptoUtils from System Layer into VM Layer
Docker tags |
Benchmark for 00d71f3Click to view benchmark
|
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.
When removing crypto bls related functions, you also removed trace_resource
macro which was used to calculate costing coefficients. I've added comments to that macros to move them to lower layer functions in case we need to run costing evaluation again.
Also I saw in couple places that KernelNodeApi + ClientApi
was changed to SystemApi
, this is probably intentional but just wanted to point that out.
} | ||
} | ||
|
||
#[trace_resources(log=message.len(), log=public_keys.len())] |
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.
trace_resource
macro should be moved to fast_aggregate_verify_bls12381_v1()
function.
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.
good point!
} | ||
|
||
// Trace average message length and number of public_keys | ||
#[trace_resources(log={pub_keys_and_msgs.iter().flat_map(|(_, msg)| msg).count()/pub_keys_and_msgs.len()},log=pub_keys_and_msgs.len())] |
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.
trace_resource
macro should be moved to aggregate_verify_bls12381_v1()
function.
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.
good point!
Y: KernelApi<System<V>>, | ||
V: SystemCallbackObject, | ||
{ | ||
#[trace_resources(log=message.len())] |
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.
trace_resource
macro should be moved to verify_bls12381_v1()
function.
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.
good point!
} | ||
} | ||
|
||
#[trace_resources(log=signatures.len())] |
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.
trace_resource
macro should be moved to Bls12381G2Signature::aggregate()
function.
} | ||
} | ||
|
||
#[trace_resources(log=data.len())] |
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.
trace_resource
macro should be moved to keccak256_hash()
function.
Ok(result) | ||
if pub_keys_and_msgs.is_empty() { | ||
return Err(InvokeError::SelfError(WasmRuntimeError::InputDataEmpty)); | ||
} |
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.
Is this a breaking change?
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.
No it should be the same logic it just changes the logic into the "Return early" pattern. Unless you mean for something else?
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 don't see where we do this non-empty check before.
If it's not new, the order of the non-empty check and costing also matters? Transaction fails with different costs.
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 check was in the api.bls12381_v1_aggregate_verify()
call, the logic of which has now moved into this function.
Ok(result) | ||
if public_keys.is_empty() { | ||
return Err(InvokeError::SelfError(WasmRuntimeError::InputDataEmpty)); | ||
} |
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.
Ditto
let agg_sig = self.api.bls12381_g2_signature_aggregate(&signatures)?; | ||
if signatures.is_empty() { | ||
return Err(InvokeError::SelfError(WasmRuntimeError::InputDataEmpty)); | ||
} |
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.
Ditto