Kaia에서만 발생하는 create2 제로 주소 이슈 (Issue with create2 resulting in zero address only on Kaia)

혹시 아시는 분이 계시다면 도움을 부탁드립니다.

Kaia와 Kairos에 동일한 바이너리의 컨트랙트를 배포하고 똑같은 input을 주었는데 결과가 달라져서 어려움을 겪고 있습니다.

이 컨트랙트는 내부에서 create2를 사용하는데, Kaia에서 실행 시 가끔 제로 주소가 반환되는 경우가 있어 그 원인을 조사하고 있습니다.

조사에 도움이 될 만한 힌트가 있으면 뭐든지 부탁드립니다.

현재 파악한 사항은 다음과 같습니다.

  • Kaia와 Kairos에서 4가지 입력 패턴으로 실행했고, Kaia에서만 2가지 패턴이 제로 주소로 반환됩니다.
  • 제로 주소가 나온 input을 다시 시도했지만 여전히 제로 주소가 반환됩니다.
  • Ethereum이나 Optimism에서 같은 바이너리로 테스트할 경우 제로 주소가 반환되지 않습니다.

If anyone can help, I’d appreciate your insights.

I’m encountering an issue where deploying the exact same contract binary to both Kaia and Kairos and providing identical input results in different outcomes.

The contract internally uses create2, but when executed on Kaia, it sometimes results in a zero address. I’m currently investigating the cause.

Any hints or advice you could provide would be very helpful.

Here’s what I’ve observed so far:

  • Running four input patterns on both Kaia and Kairos, only two patterns result in a zero address exclusively on Kaia.
  • Retrying the inputs that previously resulted in a zero address still produces the same outcome.
  • Testing the same binary on Ethereum or Optimism never results in a zero address.

Contract code being executed:


contract LogicFactory {
    event Created(address indexed addr);

    function deployByCreate2(
        bytes memory code,
        uint256 salt,
        bytes calldata data
    ) external returns (address) {
        address addr;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            addr := create2(0, add(code, 0x20), mload(code), salt)
            if iszero(extcodesize(addr)) {
                revert(0, 0)
            }
        }

        if (data.length > 0) {
            (bool success, ) = addr.call(data);
            if (!success) {
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    returndatacopy(0, 0, returndatasize())
                    revert(0, returndatasize())
                }
            }
        }

        emit Created(addr);

        return addr;
    }
}

Tx resulting in zero address on Kaia: Kaiascope.com
Kairos Tx: TESTNET Kairos (KAIA) Blockchain Explorer - KaiaScan

안녕하세요, 리포팅 감사합니다.

먼저 공유주신 Kaia tx의 에러 메시지를 보면 contract creation code storage out of gas 에러를 리턴하고 있습니다. 이는 kaia/blockchain/vm/evm.go at dev · kaiachain/kaia · GitHub 여기서 확인하실 수 있듯 contract creation gas 가 남아있는 gas보다 높을 경우 out of gas와 유사한 개념으로 리턴된다고 이해할 수 있을 것 같습니다. 즉, create2가 성공적으로 실행되었는데 이 값이 zero address인 것이 아니라, gas limit이 부족하여 create2 실행자체가 실패된 것이며, gas limit을 더 높이면 실행에 문제가 없을 것으로 예상됩니다.

리턴 값이 0x0이 되는 이유는, 해당 에러가 발생했을 시 stack을 clear하고 리턴하기 때문에 address가 zero address로 리턴됩니다.

0x0 가 리턴되었는데도 중간에 early revert가 안된 이유는 Kaia의 0x0 주소에는 실제로 contract code가 존재하기 때문에 non-zero EXTCODESIZE가 리턴되기 때문입니다.

감사합니다.

1 Like

답변 주셔서 감사합니다.

그런 일이 있었군요. gas_limit을 늘려서 시도해 보겠습니다.
공부를 위해 여쭤보는 것인데, contract creation code storage out of gas라는 메시지는 어디에서 확인할 수 있나요?

internal tx 탭에서 확인하실 수 있습니다. Kaiascope.com

오! 마우스를 올리면 나오는 거군요!
감사합니다. 많이 배웠습니다.

1 Like