Replace COA.call with COA.callWithSigAndArgs for reduced computation cost#207
Conversation
0480739 to
c058e91
Compare
0b195c1 to
6dc3a89
Compare
6dc3a89 to
ae1fbc4
Compare
|
Nice! Thank you for optimizing this 👍 It looks like some of the function signatures changed. We should probably make sure this doesn't break existing contracts and transactions. From what I could see doing a quick search for |
@turbolent I have already checked that the function signature changes affect only "internal" functions. Their access modifiers are either |
| let decodedSymbolData = EVM.decodeABI(types: [Type<String>()], data: symbolRes.data) | ||
| assert(decodedNameData.length == 1, message: "Unexpected name() return length of ".concat(decodedNameData.length.toString())) | ||
| assert(decodedSymbolData.length == 1, message: "Unexpected symbol() return length of ".concat(decodedSymbolData.length.toString())) | ||
| assert(nameRes.results.length == 1, message: "Unexpected name() return length of ".concat(nameRes.results.length.toString())) |
There was a problem hiding this comment.
Can you use string interpolation everywhere instead of concat?
| assert(nameRes.results.length == 1, message: "Unexpected name() return length of ".concat(nameRes.results.length.toString())) | |
| assert(nameRes.results.length == 1, message: "Unexpected name() return length of \(nameRes.results.length.toString())) |
There was a problem hiding this comment.
Updated all such occurrences in f931ba9 .
| let valueBalance = EVM.Balance(attoflow: 0) | ||
| valueBalance.setFLOW(flow: value) |
There was a problem hiding this comment.
These lines are not modified by PR.
Maybe we can special case value 0.0 to avoid creating EVM.Balance.
| let valueBalance = EVM.Balance(attoflow: 0) | ||
| valueBalance.setFLOW(flow: value) |
There was a problem hiding this comment.
Same as above. Maybe we can special case value 0.0 to avoid creating EVM.Balance.
| let valueBalance = EVM.Balance(attoflow: 0) | ||
| valueBalance.setFLOW(flow: value) |
There was a problem hiding this comment.
Same as above. Maybe we can special case value 0.0 to avoid creating EVM.Balance.
| resultTypes: [Type]? | ||
| ): EVM.ResultDecoded { | ||
| let valueBalance = EVM.Balance(attoflow: 0) | ||
| valueBalance.setFLOW(flow: value) |
There was a problem hiding this comment.
Same as above. Maybe we can special case value 0.0 to avoid creating EVM.Balance.
|
@m-Peter I'd like to start upgrading these contracts on testnet soon. Are the tests not passing because this function is not available in the emulator yet? |
|
@joshuahannan The tests are not passing, because the |
|
good to know! I'll schedule a multisig to upgrade the EVM contract on mainnet |
@joshuahannan It would be good to first upgrade the EVM contract on testnet, and see that everything's working well. |
|
Yes, that was the plan, just trying to get this update to the EVM contract merged first: onflow/flow-go#8529 |
Switches the EVM contract dependency from mainnet://e467b9dd11fa00df.EVM to testnet://8c5303eaa26202d6.EVM and updates the hash and block height to match the testnet version. All tests pass.
|
@m-Peter I just updated the dependency to use testnet instead of mainnet for EVM so we could make sure these tests pass and merge it. Is that okay? |
@joshuahannan That's awesome 🎉 I wasn't sure if that was possible, I thought it had to be from |
Related: onflow/flow-go#8401
Closes: #206
Description
Previously, to perform contract calls using a COA, it was necessary to produce the
callDataon Cadence side:To be able to ABI-decode the returned data from the COA call, another step was needed:
After doing some profiling on Cadence transactions, the computation cost of ABI encoding/decoding, amounted to about 15%-20% of the total computation, which is not trivial.
To optimize this case, we have a new wrapper function,
callWithSigAndArgs, which does all this more efficiently:We do the same for
dryCall, by replacing it withdryCallWithSigAndArgs.NOTE: CI is failing because we still need to deploy the
EVMsystem contract on testnet/mainnet, for these new functions to be available.For contributor use:
mainbranchFiles changedin the Github PR explorer