Check for unknown Qortal-only AT function codes & add safety to AT running in general

This commit is contained in:
catbref 2020-06-25 14:22:28 +01:00
parent faa6405d5f
commit 2c14a12464
2 changed files with 8 additions and 1 deletions

View File

@ -100,7 +100,11 @@ public class AT {
// [Re]create AT machine state using AT state data or from scratch as applicable
MachineState state = MachineState.fromBytes(api, loggerFactory, latestAtStateData.getStateData(), codeBytes);
state.execute();
try {
state.execute();
} catch (Exception e) {
throw new DataException(String.format("Uncaught exception while running AT '%s'", atAddress), e);
}
long creation = this.atData.getCreation();
byte[] stateData = state.toBytes();

View File

@ -449,6 +449,9 @@ public class QortalATAPI extends API {
public void platformSpecificPostCheckExecute(FunctionData functionData, MachineState state, short rawFunctionCode) throws ExecutionException {
QortalFunctionCode qortalFunctionCode = QortalFunctionCode.valueOf(rawFunctionCode);
if (qortalFunctionCode == null)
throw new IllegalFunctionCodeException("Unknown Qortal function code 0x" + String.format("%04x", rawFunctionCode) + " encountered");
qortalFunctionCode.execute(functionData, state, rawFunctionCode);
}