Description
Steps to reproduce
Deploy the contract below to EVM sidechain testnet. It is important that we keep the version fixed at 0.8.25
as MCOPY (0x5e) is ony available at ^0.8.25.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
contract MCopyTest {
function copyMemory(bytes memory input) public pure returns (bytes memory) {
bytes memory result = new bytes(input.length);
assembly {
let length := mload(input) // Load length of input
let inputPtr := add(input, 0x20) // Pointer to input data (skip length prefix)
let resultPtr := add(result, 0x20) // Pointer to result data (skip length prefix)
mcopy(resultPtr, inputPtr, length) // Perform memory copy using MCOPY
}
return result;
}
function example() public pure returns (bytes memory) {
bytes memory input = hex"12345600af151531";
return copyMemory(input);
}
}
Now this is a simple deployment script:
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import {Script, console} from "forge-std/Script.sol";
import {MCopyTest} from "../src/MCopyTest.sol";
contract CounterScript is Script {
MCopyTest public mCopyTest;
function setUp() public {}
function run() public {
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
mCopyTest = new MCopyTest();
vm.stopBroadcast();
}
}
Running forge script script/MCopyTest.deploy.sol --rpc-url https://rpc-evm-sidechain.xrpl.org --broadcast --verify --verifier blockscout --verifier-url https://explorer.xrplevm.org/api/
will deploy the contract (it is another bug that the contract verifier does not work for code compiled above certain version of solidity, because you won't be able to see the verified contract on Blockscout explorer on https://explorer.xrplevm.org/).
An example contract deployed is at https://explorer.xrplevm.org/address/0x836ffb3f6058283f40b331ab8b069278b6aaddb3.
Now on your cli, just run:
cast call 0x836FFB3f6058283f40b331AB8b069278b6AAdDb3 "example()(bytes)" --rpc-url https://rpc-evm-sidechain.xrpl.org
And as we discussed before, it seems that it requires an update from an upstream dependency. I've checked Evmos and it appears that they don't support this opcode at all. have a look at these lines:
So... 0x5e
is just missing from the implementation. While we can't resolve this issue immediately, it might be useful to write about unsupported opcodes on public docs so that devs don't waste their time.
Expected behavior
Call to exapmle()(bytes)
must succeed without throwing an error.
Actual behavior
The function call throws an error:
Error: server returned an error response: error code -32000: rpc error: code = Internal desc = invalid opcode: opcode 0x5e not defined