use of com.radixdlt.constraintmachine.ExecutionContext in project radixdlt by radixdlt.
the class RadixEngine method executeInternal.
private RadixEngineResult executeInternal(EngineStore.EngineStoreInTransaction<M> engineStoreInTransaction, List<Txn> txns, M meta, PermissionLevel permissionLevel, boolean skipAuthorization) throws RadixEngineException {
var processedTxns = new ArrayList<REProcessedTxn>();
// FIXME: This is quite the hack to increase sigsLeft for execution on noncommits (e.g. mempool)
// FIXME: Should probably just change metering
// Start with 0
var sigsLeft = meta != null ? 0 : 1000;
var storageStopwatch = Stopwatch.createUnstarted();
var verificationStopwatch = Stopwatch.createUnstarted();
for (int i = 0; i < txns.size(); i++) {
var txn = txns.get(i);
verificationStopwatch.start();
var context = new ExecutionContext(txn, permissionLevel, skipAuthorization, sigsLeft);
final REProcessedTxn processedTxn;
try {
processedTxn = this.verify(engineStoreInTransaction, txn, context);
} catch (TxnParseException | AuthorizationException | ConstraintMachineException e) {
throw new RadixEngineException(i, txns.size(), txn, e);
}
verificationStopwatch.stop();
// Carry sigs left to the next transaction
sigsLeft = context.sigsLeft();
storageStopwatch.start();
try {
engineStoreInTransaction.storeTxn(processedTxn);
} catch (Exception e) {
logger.error("Store of atom failed: " + processedTxn, e);
throw e;
}
storageStopwatch.stop();
processedTxns.add(processedTxn);
}
try {
batchVerifier.testMetadata(meta, processedTxns);
} catch (MetadataException e) {
logger.error("Invalid metadata: " + processedTxns);
throw e;
}
if (meta != null) {
engineStoreInTransaction.storeMetadata(meta);
}
return RadixEngineResult.create(processedTxns, verificationStopwatch.elapsed(TimeUnit.MILLISECONDS), storageStopwatch.elapsed(TimeUnit.MILLISECONDS));
}
use of com.radixdlt.constraintmachine.ExecutionContext in project radixdlt by radixdlt.
the class RadixEngine method executeInternal.
private RadixEngineResult<M> executeInternal(EngineStore.EngineStoreInTransaction<M> engineStoreInTransaction, List<Txn> txns, Optional<M> metaOpt, PermissionLevel permissionLevel, boolean skipAuthorization) throws RadixEngineException {
var processedTxns = new ArrayList<REProcessedTxn>();
// FIXME: This is quite the hack to increase sigsLeft for execution on noncommits (e.g. mempool)
// FIXME: Should probably just change metering
// Start with 0
var sigsLeft = metaOpt.isPresent() ? 0 : 1000;
var storageStopwatch = Stopwatch.createUnstarted();
var verificationStopwatch = Stopwatch.createUnstarted();
for (int i = 0; i < txns.size(); i++) {
var txn = txns.get(i);
verificationStopwatch.start();
var context = new ExecutionContext(txn, permissionLevel, skipAuthorization, sigsLeft);
final REProcessedTxn processedTxn;
try {
processedTxn = this.verify(engineStoreInTransaction, txn, context);
} catch (TxnParseException | AuthorizationException | ConstraintMachineException e) {
throw new RadixEngineException(i, txns.size(), txn, e);
}
verificationStopwatch.stop();
// Carry sigs left to the next transaction
sigsLeft = context.sigsLeft();
storageStopwatch.start();
try {
engineStoreInTransaction.storeTxn(processedTxn);
} catch (Exception e) {
logger.error("Store of atom failed: " + processedTxn, e);
throw e;
}
storageStopwatch.stop();
processedTxns.add(processedTxn);
}
try {
final var resultMetadata = metaOpt.map(meta -> {
final var postProcessedMetadata = postProcessor.process(meta, engineStoreInTransaction, processedTxns);
engineStoreInTransaction.storeMetadata(postProcessedMetadata);
return postProcessedMetadata;
}).orElse(null);
return RadixEngineResult.create(processedTxns, resultMetadata, verificationStopwatch.elapsed(TimeUnit.MILLISECONDS), storageStopwatch.elapsed(TimeUnit.MILLISECONDS));
} catch (PostProcessorException e) {
logger.error("Invalid metadata: " + processedTxns);
throw e;
}
}
Aggregations