Adding new load test type for constant sized transactions#2816
Conversation
bf107d6 to
4109d7a
Compare
|
It's hard to figure out what really changed when many changes happen all in the same PR. Could you break this PR into smaller / coherent pieces? e.g., refactoring sendAddKeyTx into createAddKeyTx & sendAddKeyTx can be one PR. moving inline cadence templates into files can be one (or multiple) PR. I promise to review the PRs quickly. thx |
| loadType LoadType | ||
| follower TxFollower | ||
| availableAccountsLo int | ||
| maxConstExecTxSizeInByte uint |
There was a problem hiding this comment.
the number of arguments passed into NewContLoadGenerator is getting a bit out of hand. could you group these fields into a sub-struct? e.g.,
type ConstExecTx struct {
maxSizeInByte
authAccNum
argSizeInByte
payerKeyCount
}
| // check and cap params for const-exec mode | ||
| if loadType == ConstExecCostLoadType { | ||
| if maxConstExecTxSizeInByte > flow.DefaultMaxTransactionByteSize { | ||
| log.Warn().Msg( |
There was a problem hiding this comment.
just return error instead of fudging the value? same below
| if err != nil { | ||
| lg.log.Error().Err(err).Msg("failed to setup fav contract") | ||
| return err | ||
| if lg.loadType != ConstExecCostLoadType { |
There was a problem hiding this comment.
not specific to this pr (it's probably something for @AndrewM-SDET to think about). With more and more load types being added to the load generator, we may want to refactor ContLoadGenerator into smaller load type specific units.
There was a problem hiding this comment.
At the moment we are probably ok but this is absolutely worth adding to the backlog. I've created a new issue for it at #2825
4109d7a to
d187893
Compare
|
done at #2817
|
BTW I split original large commit into smaller individual commits but still keeping them into the same PR because these changes can be logically grouped. |
| return nil | ||
| } | ||
|
|
||
| func (lg *ContLoadGenerator) getTxSizeWithoutCommnent() uint { |
There was a problem hiding this comment.
maybe rename to getConstExecCostTxSizeWithoutComment?
| authorizerListStr := generateAuthAccountParamList(lg.constExecParam.AuthAccountNum) | ||
| oneSignatureLen := uint(flow.AddressLength) + flowCrypto.SignatureLenECDSAP256 + 8 /* keyId is uint64 */ | ||
|
|
||
| return lg.constExecParam.ArgSizeInByte + |
There was a problem hiding this comment.
is there a better way to get the size estimate? this seems very brittle.
There was a problem hiding this comment.
Janez and I discussed about this. Basically we want to know the size of binary data that takes actual network resources. Our goal is to reach the network saturation point and then collect some metrics. I will leave it to @janezpodhostnik for more info
There was a problem hiding this comment.
For the required measurements the actual absolute size is not that important. Let me explain what I mean:
If we write the "size" of the transaction as
In general the "size" is a vector of all the different parameters, and we have more than two points, but the point is the accuracy of the constant size of the transaction is not important as we are only interested in the relative size.
However I agree this might be brittle and confusing, so we could instead just not count the constant parts, and only count the dynamic parts:
lg.constExecParam.ArgSizeInByte +
generateAuthAccountParamList(lg.constExecParam.AuthAccountNum) +
lg.constExecParam.AuthAccountNum*oneSignatureLen +
lg.constExecParam.PayerKeyCount*oneSignatureLen
This will make the comparison lg.constExecParam.MaxTxSizeInByte < txSizeWithoutComment inaccurate, but if the constant parts are not that big we can just rewrite it to: lg.constExecParam.MaxTxSizeInByte < txRelativeSizeWithoutComment + TXConstantSizeEstimate.
There was a problem hiding this comment.
thanks for the info. Code refined.
There was a problem hiding this comment.
can we just marshal the payload without sending it, and get the size from that?
There was a problem hiding this comment.
addressed - now tx size is calculated by RLP encoding which is one simple API call away: tx.Encode(). Using protobuf encoding to calculate the size seems to be a little more complex and adds extra assumption that we will be using protobuf for data transfer.
| SetPayer(*lg.accounts[0].address) | ||
| lg.accounts[0].seqNumber += 1 | ||
|
|
||
| txArgStr := generateCadenceCommentWithLen(lg.constExecParam.ArgSizeInByte) |
There was a problem hiding this comment.
using generateCadenceCommentWithLen here is very confusing. maybe create an alias for the function, e.g., generateRandomStringWithLen
There was a problem hiding this comment.
o, better yet, maybe move // from generateCadenceCommentWithLen into the template, and just have generateRandomStringWithLen
d187893 to
9b68f41
Compare
janezpodhostnik
left a comment
There was a problem hiding this comment.
Some minor comments. Looks good otherwise.
| CompHeavyLoadType LoadType = "computation-heavy" | ||
| EventHeavyLoadType LoadType = "event-heavy" | ||
| LedgerHeavyLoadType LoadType = "ledger-heavy" | ||
| ConstExecCostLoadType LoadType = "const-exec" |
There was a problem hiding this comment.
It might be nice to add a short comment of what this load type is supposed to do here. Just so it's easier to understand for the next person.
There was a problem hiding this comment.
done - put a short comment.
| if loadType == ConstExecCostLoadType { | ||
| if constExecParam.MaxTxSizeInByte > flow.DefaultMaxTransactionByteSize { | ||
| errMsg := fmt.Sprintf("MaxTxSizeInByte(%d) is larger than DefaultMaxTransactionByteSize."+ | ||
| "Resetting it back to DefaultMaxTransactionByteSize(%d).", |
There was a problem hiding this comment.
This states Resetting it back to DefaultMaxTransactionByteSize(%d). then returns an error. According to the error text, I expected this to change the input parameter to flow.DefaultMaxTransactionByteSize. Is it expected that the user makes this correction?
The same for the following two errors.
| authorizerListStr := generateAuthAccountParamList(lg.constExecParam.AuthAccountNum) | ||
| oneSignatureLen := uint(flow.AddressLength) + flowCrypto.SignatureLenECDSAP256 + 8 /* keyId is uint64 */ | ||
|
|
||
| return lg.constExecParam.ArgSizeInByte + |
There was a problem hiding this comment.
For the required measurements the actual absolute size is not that important. Let me explain what I mean:
If we write the "size" of the transaction as
In general the "size" is a vector of all the different parameters, and we have more than two points, but the point is the accuracy of the constant size of the transaction is not important as we are only interested in the relative size.
However I agree this might be brittle and confusing, so we could instead just not count the constant parts, and only count the dynamic parts:
lg.constExecParam.ArgSizeInByte +
generateAuthAccountParamList(lg.constExecParam.AuthAccountNum) +
lg.constExecParam.AuthAccountNum*oneSignatureLen +
lg.constExecParam.PayerKeyCount*oneSignatureLen
This will make the comparison lg.constExecParam.MaxTxSizeInByte < txSizeWithoutComment inaccurate, but if the constant parts are not that big we can just rewrite it to: lg.constExecParam.MaxTxSizeInByte < txRelativeSizeWithoutComment + TXConstantSizeEstimate.
925a4e6 to
f6adc62
Compare
f6adc62 to
58ed8a3
Compare
58ed8a3 to
222fd3c
Compare
#2785
Summary
As part of Dynamic Inclusion Fee feature development (more details can be found at https://www.notion.so/dapperlabs/Variable-Transaction-Fees-Inclusion-Effort-I-20c849105a3945879824e386cc9c3ebf by @janezpodhostnik ), we will need to get proper co-efficient values for the new inclusion fee equation that can fit well with our production transactions with different sizes. Before we do that in production, we will need to be able to create tx with given sizes sent to devnet\testnet to get initial metrics.
This PR adds a new loader test type that allows us to create and send tx with given size.
Test Plan