Search in sources :

Example 1 with SignedSystemException

use of com.radixdlt.constraintmachine.exceptions.SignedSystemException in project radixdlt by radixdlt.

the class ConstraintMachine method callProcedure.

/**
 * Executes a transition procedure given the next spun particle and a current validation state.
 */
private ReducerState callProcedure(Procedure procedure, Object procedureParam, ReducerState reducerState, Resources immutableAddrs, ExecutionContext context) throws SignedSystemException, InvalidPermissionException, AuthorizationException, MeterException, ProcedureException {
    // System permissions don't require additional authorization
    var authorization = procedure.authorization(procedureParam);
    var requiredLevel = authorization.permissionLevel();
    context.verifyPermissionLevel(requiredLevel);
    if (context.permissionLevel() != PermissionLevel.SYSTEM) {
        try {
            if (requiredLevel == PermissionLevel.USER) {
                this.meter.onUserProcedure(procedure.key(), procedureParam, context);
            } else if (requiredLevel == PermissionLevel.SUPER_USER) {
                this.meter.onSuperUserProcedure(procedure.key(), procedureParam, context);
            }
        } catch (Exception e) {
            throw new MeterException(e);
        }
        if (!context.skipAuthorization()) {
            try {
                authorization.authorizer().verify(immutableAddrs, context);
            } catch (Exception e) {
                throw new AuthorizationException(e);
            }
        }
    }
    return procedure.call(procedureParam, reducerState, immutableAddrs, context).state();
}
Also used : MeterException(com.radixdlt.constraintmachine.exceptions.MeterException) AuthorizationException(com.radixdlt.constraintmachine.exceptions.AuthorizationException) MeterException(com.radixdlt.constraintmachine.exceptions.MeterException) ProcedureException(com.radixdlt.constraintmachine.exceptions.ProcedureException) MissingProcedureException(com.radixdlt.constraintmachine.exceptions.MissingProcedureException) AuthorizationException(com.radixdlt.constraintmachine.exceptions.AuthorizationException) SignedSystemException(com.radixdlt.constraintmachine.exceptions.SignedSystemException) SubstateNotFoundException(com.radixdlt.constraintmachine.exceptions.SubstateNotFoundException) NotAResourceException(com.radixdlt.constraintmachine.exceptions.NotAResourceException) VirtualSubstateAlreadyDownException(com.radixdlt.constraintmachine.exceptions.VirtualSubstateAlreadyDownException) ConstraintMachineException(com.radixdlt.constraintmachine.exceptions.ConstraintMachineException) LocalSubstateNotFoundException(com.radixdlt.constraintmachine.exceptions.LocalSubstateNotFoundException) TrailingBytesException(com.radixdlt.engine.parser.exceptions.TrailingBytesException) InvalidPermissionException(com.radixdlt.constraintmachine.exceptions.InvalidPermissionException) TxnParseException(com.radixdlt.engine.parser.exceptions.TxnParseException) DeserializeException(com.radixdlt.serialization.DeserializeException)

Aggregations

AuthorizationException (com.radixdlt.constraintmachine.exceptions.AuthorizationException)1 ConstraintMachineException (com.radixdlt.constraintmachine.exceptions.ConstraintMachineException)1 InvalidPermissionException (com.radixdlt.constraintmachine.exceptions.InvalidPermissionException)1 LocalSubstateNotFoundException (com.radixdlt.constraintmachine.exceptions.LocalSubstateNotFoundException)1 MeterException (com.radixdlt.constraintmachine.exceptions.MeterException)1 MissingProcedureException (com.radixdlt.constraintmachine.exceptions.MissingProcedureException)1 NotAResourceException (com.radixdlt.constraintmachine.exceptions.NotAResourceException)1 ProcedureException (com.radixdlt.constraintmachine.exceptions.ProcedureException)1 SignedSystemException (com.radixdlt.constraintmachine.exceptions.SignedSystemException)1 SubstateNotFoundException (com.radixdlt.constraintmachine.exceptions.SubstateNotFoundException)1 VirtualSubstateAlreadyDownException (com.radixdlt.constraintmachine.exceptions.VirtualSubstateAlreadyDownException)1 TrailingBytesException (com.radixdlt.engine.parser.exceptions.TrailingBytesException)1 TxnParseException (com.radixdlt.engine.parser.exceptions.TxnParseException)1 DeserializeException (com.radixdlt.serialization.DeserializeException)1