Source:
<code>public void callToPrecompiledAddress(MessageCall msg, PrecompiledContract contract) { if (getCallDeep() == MAX_DEPTH) { stackPushZero(); this.refundGas(msg.getGas().longValue(), " call deep limit reach"); return; } Repository track = getStorage().startTracking(); byte[] senderAddress = this.getOwnerAddress().getLast20Bytes(); byte[] codeAddress = msg.getCodeAddress().getLast20Bytes(); byte[] contextAddress = msg.getType().callIsStateless() ? senderAddress : codeAddress; BigInteger endowment = msg.getEndowment().value(); BigInteger senderBalance = track.getBalance(senderAddress); if (senderBalance.compareTo(endowment) < 0) { stackPushZero(); this.refundGas(msg.getGas().longValue(), "refund gas from message call"); return; } byte[] data = this.memoryChunk(msg.getInDataOffs().intValue(), msg.getInDataSize().intValue()); transfer(track, senderAddress, contextAddress, msg.getEndowment().value()); if (byTestingSuite()) { this.getResult().addCallCreate(data, msg.getCodeAddress().getLast20Bytes(), msg.getGas().getNoLeadZeroesData(), msg.getEndowment().getNoLeadZeroesData()); stackPushOne(); return; } long requiredGas = contract.getGasForData(data); if (requiredGas > msg.getGas().longValue()) { this.refundGas(0, "call pre-compiled"); this.stackPushZero(); track.rollback(); } else { Pair<Boolean, byte[]> out = contract.execute(data); if (out.getLeft()) { this.refundGas(msg.getGas().longValue() - requiredGas, "call pre-compiled"); this.stackPushOne(); track.commit(); } else { this.refundGas(0, "call pre-compiled"); this.stackPushZero(); <START> track.rollback(); <END> } this.memorySave(msg.getOutDataOffs().intValue(), out.getRight()); } }</code><technical_language>M.b. refactor PrecompiledContract a bit similar regular call, I.e. leave execute() throw OGException if enough gas for supplied data, other custom exceptions if invalid data supplied (there supply a detailed description call failed)</technical_language>

Target:
public void callToPrecompiledAddress(MessageCall msg, PrecompiledContract contract) { returnDataBuffer = null; if (getCallDeep() == MAX_DEPTH) { stackPushZero(); this.refundGas(msg.getGas().longValue(), " call deep limit reach"); return; } Repository track = getStorage().startTracking(); byte[] senderAddress = this.getOwnerAddress().getLast20Bytes(); byte[] codeAddress = msg.getCodeAddress().getLast20Bytes(); byte[] contextAddress = msg.getType().callIsStateless() ? senderAddress : codeAddress; BigInteger endowment = msg.getEndowment().value(); BigInteger senderBalance = track.getBalance(senderAddress); if (senderBalance.compareTo(endowment) < 0) { stackPushZero(); this.refundGas(msg.getGas().longValue(), "refund gas from message call"); return; } byte[] data = this.memoryChunk(msg.getInDataOffs().intValue(), msg.getInDataSize().intValue()); transfer(track, senderAddress, contextAddress, msg.getEndowment().value()); if (byTestingSuite()) { this.getResult().addCallCreate(data, msg.getCodeAddress().getLast20Bytes(), msg.getGas().getNoLeadZeroesData(), msg.getEndowment().getNoLeadZeroesData()); stackPushOne(); return; } long requiredGas = contract.getGasForData(data); if (requiredGas > msg.getGas().longValue()) { this.refundGas(0, "call pre-compiled"); this.stackPushZero(); track.rollback(); } else { Pair<Boolean, byte[]> out = contract.execute(data); if (out.getLeft()) { this.refundGas(msg.getGas().longValue() - requiredGas, "call pre-compiled"); this.stackPushOne(); returnDataBuffer = out.getRight(); track.commit(); } else { this.refundGas(0, "call pre-compiled"); this.stackPushZero(); track.rollback(); } this.memorySave(msg.getOutDataOffs().intValue(), out.getRight()); } }