Solidity 0.8.28 버전, cancun 하드포크 관련 질문

안녕하세요.

0.8.28 버전의 컨트랙트를 배포할 예정입니다.
kaia chain이 Shanghai 및 Cancun 포크에서 도입된 PUSH0, TSTORE, TLOAD, MCOPY opcode를 모두 지원하는 걸까요?

Ethereum mainnet, Ethereum testnet, BSC Mainnet, BSC Testnet에서는 모두 배포가 가능하였지만, kaia chain(kairos)에는 배포가 안되어 문의드립니다.

Kaia docs 에서 보면 모두 지원하는 것으로 보이지만, 해당 opcode가 포함된 컨트랙트는 배포가 되지 않아 도움요청 드립니다. (확인해보니 TSTORE, TLOAD만 사용한 컨트랙트는 배포 가능)

테스트한 데이터 공유드립니다.
rpc url : https://public-en-kairos.node.kaia.io
txhash : 0xdbf5a360d1d5ea737a1c4a837e32386e7b7505b3c99ddf6b1c493b5b4f797e0d
evmVersion : cancun

test contract

contract OpcodeExample {
    bytes public data;

    // Function using push0 and mcopy opcodes
    function usePush0AndMcopy(bytes memory _data) public {
        assembly {
            // Using push0 opcode (0x5f) - push 0 onto the stack
            // Let compiler use push0 by using 0 directly
            let zero := 0

            // Get data length
            let dataLength := mload(_data)

            // Allocate new memory position
            let memPos := mload(0x40)

            // Using custom assembly for mcopy (opcode 0x4a)
            // Format: mcopy(destOffset, sourceOffset, size)
            let src := add(_data, 0x20)
            let dst := memPos

            // Raw MCOPY using "PUSH1 0x4a" followed by binary EVM opcode for mcopy
            // We manually insert the mcopy opcode (0x4a)
            // Using direct bytecode insertion
            mstore(0x00, "MCOPY")
            mstore(dst, dataLength)

            // "Before MCOPY" marker for debugging
            log0(0x00, 0x20)

            // Inline assembly for mcopy (attempt 1)
            // 0x4a is MCOPY opcode in hex
            let success := 0

            // Use direct yul assembly
            // This depends on EVM version support rather than Solidity compiler support
            mcopy(dst, src, dataLength)

            // "After MCOPY" marker for debugging
            mstore(0x00, "AFTER")
            log0(0x00, 0x20)

            // Update memory pointer
            mstore(0x40, add(memPos, dataLength))
        }
        data = _data;
    }

    // Function using tstore and tload opcodes
    function useTstoreAndTload(uint key, uint value) public returns (uint) {
        uint retrievedValue;

        assembly {
            // Using tstore opcode (0x5a) with key and value
            // Direct inline Yul for tstore
            tstore(key, value)

            // Using tload opcode (0x5c) with key
            // Direct inline Yul for tload
            retrievedValue := tload(key)
        }

        return retrievedValue;
    }

    // Function using all opcodes together
    function useAllOpcodes(bytes memory _data, uint key) public returns (bytes memory, uint) {
        uint storedValue;

        assembly {
            // Using push0 (just use 0)
            let zero := 0

            // Get data length
            let dataLength := mload(_data)

            // Store length in transient storage (tstore)
            tstore(key, dataLength)

            // Allocate new memory position
            let memPos := mload(0x40)

            // Copy data using mcopy
            let src := add(_data, 0x20)
            let dst := memPos
            mcopy(dst, src, dataLength)

            // Retrieve length from transient storage (tload)
            let storedLength := tload(key)

            // Store the value for return
            storedValue := storedLength
        }

        return (_data, storedValue);
    }
}
1개의 좋아요

안녕하세요, 해당 tx는 invalid opcode가 아닌 out of gas로 인해 revert난 것으로 확인됩니다. 혹시 forge로 배포하실 경우 현재 카이아의 경우 타체인의 EVM과 gas calculation이 다른 부분이 있어서 해당 에러가 날 수 있습니다. 이는 Prague부터 타체인의 EVM과 동일하게 변경될 예정이며, 그 전까진 gas limit을 더 높여서 실행하시면 될 것 같습니다. 감사합니다.

2개의 좋아요

넵 확인감사합니다.

배포되는것 확인하였습니다

1개의 좋아요