You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the EVM reverts it returns an arbitrary length array of bytes. When using Solidity this follows the convention of ABI encoding it with the signature Error(string). However, other custom errors can be returned, or a contract may decide to return arbitrary non ABI-encoded data for some reason.
Custom error example in Solidity:
error Blah(uint);
function testRevert () externalview {
revertBlah(123);
}
The problem is the following code intercepts Error(string) encoded reverts and returns just the string. Otherwise it returns up to 1024 bytes of the revert data, as a base64 encoded string. This means it's not possible to know if the data returned is the raw revert data but base64 encoded, or a string extracted from the raw revert data.
The web3 gateway then tries to re-encode the error into the raw format returned from the EVM so it can be used by Ethereum clients which follow the ABI encoded error spec. This means, instead of getting a nice custom ABI encoded error type, you get Error(string) with a bunch of base64 encoded data - making custom errors difficult / annoying to use with Sapphire.
While we can handle this entirely in web3-gateway in a clunky fashion, by detecting if the revert string is a valid base64 encoding and then return the custom error instead of wrapping it again in Error(string) encoding, there is overlap with valid revert strings and base64 data.
I suggest returning the raw revert data, base64 encoded, without doing custom parsing. Which removes the special case from both runtime-sdk/evm & oasis-web3-gateway. Existing reverts with string messages will continue to work as expected, and custom reverts will start working. But - this will cause a small amount of time when errors are broken until all the web3 gateways are upgraded after runtime-sdk.
Alternatively, we can do the clunky workaround, and add a workaround to a workaround (presumably the workaround was 'I want simple strings returned in error messages')
The text was updated successfully, but these errors were encountered:
Via: oasisprotocol/oasis-web3-gateway#429
When the EVM reverts it returns an arbitrary length array of bytes. When using Solidity this follows the convention of ABI encoding it with the signature
Error(string)
. However, other custom errors can be returned, or a contract may decide to return arbitrary non ABI-encoded data for some reason.Custom error example in Solidity:
The problem is the following code intercepts
Error(string)
encoded reverts and returns just the string. Otherwise it returns up to 1024 bytes of the revert data, as a base64 encoded string. This means it's not possible to know if the data returned is the raw revert data but base64 encoded, or a string extracted from the raw revert data.The web3 gateway then tries to re-encode the error into the raw format returned from the EVM so it can be used by Ethereum clients which follow the ABI encoded error spec. This means, instead of getting a nice custom ABI encoded error type, you get Error(string) with a bunch of base64 encoded data - making custom errors difficult / annoying to use with Sapphire.
oasis-sdk/runtime-sdk/modules/evm/src/lib.rs
Lines 222 to 256 in 9573807
While we can handle this entirely in web3-gateway in a clunky fashion, by detecting if the revert string is a valid base64 encoding and then return the custom error instead of wrapping it again in Error(string) encoding, there is overlap with valid revert strings and base64 data.
I suggest returning the raw revert data, base64 encoded, without doing custom parsing. Which removes the special case from both runtime-sdk/evm & oasis-web3-gateway. Existing reverts with string messages will continue to work as expected, and custom reverts will start working. But - this will cause a small amount of time when errors are broken until all the web3 gateways are upgraded after runtime-sdk.
Alternatively, we can do the clunky workaround, and add a workaround to a workaround (presumably the workaround was 'I want simple strings returned in error messages')
The text was updated successfully, but these errors were encountered: