Conversation
joshuahannan
left a comment
There was a problem hiding this comment.
I assume the purpose here is to have many different fee accounts so that depositing fees to the service account doesn't cause conflicts that would prevent concurrent execution, right? How many accounts do we think we would have and is that configurable based on network load or something?
|
@joshuahannan We can add as little or as many child accounts as we want. The number on child accounts affects how many transactions we can theoretically execute concurrently (if they had no other conflicts). The traffic that is currently on mainnet has small blocks and a significant amount of collisions within blocks. With that in mind I don't think we will not need more than 5 child accounts for a long time. If the blocks become larger, and the transactions more independent, we can add a few child accounts. Without code changes in the FVM the theoretical maximum for now would be 256. |
| let accountIndex = Int(txIndex % UInt32(childFeeAccounts!.length)) | ||
|
|
||
| if let feeAccount = childFeeAccounts![accountIndex].borrow() { | ||
| let receiver = feeAccount.capabilities.borrow<&{FungibleToken.Receiver}>(/public/flowTokenReceiver) ?? panic("Could not borrow a Receiver reference on the fee child account") |
There was a problem hiding this comment.
Should this also fallback to depositing to the main vault if the receiver reference can't be borrowed?
There was a problem hiding this comment.
The child account if it exists it should have a default receiver, otherwise there might be something wrong with the setup. I think we should panic here, but I you recommend we don't, I can change it.
contracts/FlowFees.cdc
Outdated
There was a problem hiding this comment.
This looks like it skips the account at index zero. Is that intentional?
There was a problem hiding this comment.
no. This was a bug, thanks!
|
|
||
| if let feeAccount = childFeeAccounts![accountIndex].borrow() { | ||
|
|
||
| let childVaultRef = feeAccount.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault) ?? panic("Could not borrow child account flowTokenVault") |
There was a problem hiding this comment.
Should we just continue to the next child account if this borrow fails instead of panicing?
There was a problem hiding this comment.
see other comment. The same logic applies here.
|
|
||
| for feeAccountRef in childFeeAccounts! { | ||
| if let feeAccount = feeAccountRef.borrow() { | ||
| totalFees = totalFees + feeAccount.availableBalance |
There was a problem hiding this comment.
I don't remember, does availableBalance include the storage reservation for the data the account stores? I just want to make sure that the balance we're getting doesn't include FLOW that is reserved to pay for storage fees
There was a problem hiding this comment.
availableBalance is the balance after excluding the needed storage reservation. so this should be fine.
f0b80cf to
67ce203
Compare
67ce203 to
503ce90
Compare
This PR enables concurrent fee collection by introducing child fee accounts that can collect transaction fees in parallel, reducing contention on the single FlowFees vault during high-throughput scenarios.
Changes:
Falls back to the original single-vault behavior when no child accounts are configured, ensuring existing deployments continue to work.
Missing: