@Override
  public void codeSuccess(final MessageFrame frame, final OperationTracer operationTracer) {
    final Bytes contractCode =
        frame.getCreatedCode() == null ? frame.getOutputData() : frame.getCreatedCode().getBytes();

    final long depositFee = evm.getGasCalculator().codeDepositGasCost(contractCode.size());

    if (frame.getRemainingGas() < depositFee) {
      LOG.trace(
          "Not enough gas to pay the code deposit fee for {}: "
              + "remaining gas = {} < {} = deposit fee",
          frame.getContractAddress(),
          frame.getRemainingGas(),
          depositFee);
      if (requireCodeDepositToSucceed) {
        LOG.trace("Contract creation error: insufficient funds for code deposit");
        frame.setExceptionalHaltReason(Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS));
        frame.setState(MessageFrame.State.EXCEPTIONAL_HALT);
        operationTracer.traceAccountCreationResult(
            frame, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS));
      } else {
        frame.setState(MessageFrame.State.COMPLETED_SUCCESS);
      }
    } else {
      final var invalidReason =
          contractValidationRules.stream()
              .map(rule -> rule.validate(contractCode, frame, evm))
              .filter(Optional::isPresent)
              .findFirst();
      if (invalidReason.isEmpty()) {
        frame.decrementRemainingGas(depositFee);

        // Finalize contract creation, setting the contract code.
        final MutableAccount contract =
            frame.getWorldUpdater().getOrCreate(frame.getContractAddress());
        contract.setCode(contractCode);
        LOG.trace(
            "Successful creation of contract {} with code of size {} (Gas remaining: {})",
            frame.getContractAddress(),
            contractCode.size(),
            frame.getRemainingGas());
        frame.setState(MessageFrame.State.COMPLETED_SUCCESS);
        if (operationTracer.isExtendedTracing()) {
          operationTracer.traceAccountCreationResult(frame, Optional.empty());
        }
      } else {
        final Optional<ExceptionalHaltReason> exceptionalHaltReason = invalidReason.get();
        frame.setExceptionalHaltReason(exceptionalHaltReason);
        frame.setState(MessageFrame.State.EXCEPTIONAL_HALT);
        operationTracer.traceAccountCreationResult(frame, exceptionalHaltReason);
      }
    }
  }
Instantiates a new Contract creation processor.

@param evm the evm
@param requireCodeDepositToSucceed the require code deposit to succeed
@param contractValidationRules the contract validation rules
@param initialContractNonce the initial contract nonce
evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java