-
Notifications
You must be signed in to change notification settings - Fork 133
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
Exchange pallet benchmarks #158
Conversation
50f2268
to
74d04a2
Compare
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.
lgtm! The make_proof
trait is a good way to handle runtime-specific stuff afaict.
74d04a2
to
35939fb
Compare
(rebased on master. will leave it open until monday) |
modules/ethereum/src/test_utils.rs
Outdated
@@ -206,6 +223,20 @@ where | |||
custom_header.sign_by(author) | |||
} | |||
|
|||
/// Insert unverified header into storage. | |||
pub fn insert_header<S: Storage>(storage: &mut S, header: Header) { |
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 made the same move in my PR, lol
@@ -117,9 +117,9 @@ pub struct UnsignedTransaction { | |||
pub gas: U256, | |||
/// Transaction destination address. None if it is contract creation transaction. | |||
pub to: Option<Address>, | |||
/// Transaction value. | |||
/// Value. |
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.
This doesn't really add much value in terms of describing what "value" is. I'd beef up the description a bit
pub value: U256, | ||
/// Transaction payload. | ||
/// Associated data. |
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.
Same here
add_benchmark!(params, batches, b"bridge-eth-poa", BridgeEthPoA); | ||
add_benchmark!(params, batches, b"bridge-currency-exchange", BridgeCurrencyExchangeBench::<Runtime>); |
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.
Not relevant for this PR, but there was recently a change introduced in Substrate that changed the arguments to this macro. We'll need to update that next time we bump Substrate
|
||
const SEED: u32 = 0; | ||
const WORST_TX_SIZE_FACTOR: u32 = 1000; | ||
const WORST_PROOF_SIZE_FACTOR: u32 = 1000; |
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 think 1000 is fine, we just need to see how the time to run the extrinsic scales as this increases anyways
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.
Looks good!
There do seem to be some problems with the CI (it doesn't look like they're caused by this PR). Should we wait until those are addressed to merge this? |
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.
Looks good modulo Hernando's grumbles.
// * Transaction has large size. | ||
// * Recipient account does not exists. | ||
import_peer_transaction_worst_case { | ||
let i in 1..100; |
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.
Can we name the one-letter variables to something more descriptive? The code now is pretty small, but if it grows over time it might get harder to read.
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.
Responded here
* exchange benchmarks: framework * updated comment about tx size Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
* exchange benchmarks: framework * updated comment about tx size Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
WIP: should be rebased on master once #155 is reviewed + merged
part of #78
The main difficulty with benchmarking this pallet is that it is too generic && I was unable to write any runtime specific code there. So there's extended
Trait
andfn Trait::make_proof()
, which asks runtime to prepare environment+proof for executing import extrinsic.There are now 5 benchmarks there:
import_peer_transaction_best_case
- imports minimal proof (transaction itself), transaction has minimal size (see below) and recipient account exists;import_peer_transaction_when_recipient_does_not_exists
- the same as (1), but recipient account is created during import;import_peer_transaction_when_transaction_size_increases
- test runtime only accepts transactions of minimal size (where data field is 32-bytes pub key of Substrate' recipient), so this is the same as (1);import_peer_transaction_when_proof_size_increases
- the same as (1), but proof size changes from 1 to 1000. Proof size here = number of transactions in PoA block. So worst case is 1000 txs/block. If you think we should have another value for that - please share your thoughts;import_peer_transaction_worst_case
- recipient account does not exists, proof size is 1000 transactions, every transaction has maximal size (though in test runtime it it the same minimal size).