update returndataload and returndatacopy

ReturnDataLoad and ReturnDataCopy had recent spec changes. Fix that.

Signed-off-by: Danno Ferrin <danno@numisight.com>
mega-eof
Danno Ferrin 6 months ago
parent 8032d0ba36
commit e1d74231af
  1. 14
      evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataCopyOperation.java
  2. 3
      evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataLoadOperation.java

@ -51,13 +51,15 @@ public class ReturnDataCopyOperation extends AbstractOperation {
final Bytes returnData = frame.getReturnData();
final int returnDataLength = returnData.size();
try {
final long end = Math.addExact(sourceOffset, numBytes);
if (end > returnDataLength) {
return INVALID_RETURN_DATA_BUFFER_ACCESS;
if (frame.getCode().getEofVersion() < 1) {
try {
final long end = Math.addExact(sourceOffset, numBytes);
if (end > returnDataLength) {
return INVALID_RETURN_DATA_BUFFER_ACCESS;
}
} catch (final ArithmeticException ae) {
return OUT_OF_BOUNDS;
}
} catch (final ArithmeticException ae) {
return OUT_OF_BOUNDS;
}
final long cost = gasCalculator().dataCopyOperationGasCost(frame, memOffset, numBytes);

@ -21,6 +21,7 @@ import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
/** The Return data copy operation. */
public class ReturnDataLoadOperation extends AbstractOperation {
@ -44,7 +45,7 @@ public class ReturnDataLoadOperation extends AbstractOperation {
if (offset > retunDataSize) {
value = Bytes.EMPTY;
} else if (offset + 32 >= returnData.size()) {
value = returnData.slice(offset);
value = Bytes32.rightPad(returnData.slice(offset));
} else {
value = returnData.slice(offset, 32);
}

Loading…
Cancel
Save