Skip to content

Commit

Permalink
check if the AVM is enabled inside the BulkExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandraRoatis committed Feb 14, 2019
1 parent 6cbf05f commit aa2cfb4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions modAionImpl/src/org/aion/zero/impl/AionBlockchainImpl.java
Expand Up @@ -220,6 +220,7 @@ protected AionBlockchainImpl(
*/
this.chainConfiguration = chainConfig;
TransactionTypeValidator.enableAvmCheck(config.isAvmEnabled());
BulkExecutor.enabledAvmCheck(config.isAvmEnabled());

this.grandParentBlockHeaderValidator =
this.chainConfiguration.createGrandParentHeaderValidator();
Expand Down
32 changes: 24 additions & 8 deletions modVM/src/org/aion/vm/BulkExecutor.java
Expand Up @@ -55,6 +55,12 @@
public class BulkExecutor {
private static final Object LOCK = new Object();

private static boolean avmEnabled = false;

public static void enabledAvmCheck(boolean isEnabled) {
avmEnabled = isEnabled;
}

private IRepository repository;
private IRepositoryCache<AccountState, IBlockStoreBase<?, ?>> repositoryChild;
private PostExecutionWork postExecutionWork;
Expand Down Expand Up @@ -394,11 +400,16 @@ private ExecutionBatch fetchNextBatchOfTransactionsForAionVirtualMachine(int sta
* future.
*/
private boolean transactionIsForFastVirtualMachine(AionTransaction transaction) {
if (transaction.isContractCreationTransaction()) {
return transaction.getTargetVM() != VirtualMachineSpecs.AVM_CREATE_CODE;
// first verify that the AVM is enabled
if (avmEnabled) {
if (transaction.isContractCreationTransaction()) {
return transaction.getTargetVM() != VirtualMachineSpecs.AVM_CREATE_CODE;
} else {
return transaction.getDestinationAddress().toBytes()[0]
!= NodeEnvironment.CONTRACT_PREFIX;
}
} else {
return transaction.getDestinationAddress().toBytes()[0]
!= NodeEnvironment.CONTRACT_PREFIX;
return true;
}
}

Expand All @@ -409,11 +420,16 @@ private boolean transactionIsForFastVirtualMachine(AionTransaction transaction)
* the destination is an AVM contract address
*/
private boolean transactionIsForAionVirtualMachine(AionTransaction transaction) {
if (transaction.isContractCreationTransaction()) {
return transaction.getTargetVM() == VirtualMachineSpecs.AVM_CREATE_CODE;
// first verify that the AVM is enabled
if (avmEnabled) {
if (transaction.isContractCreationTransaction()) {
return transaction.getTargetVM() == VirtualMachineSpecs.AVM_CREATE_CODE;
} else {
return transaction.getDestinationAddress().toBytes()[0]
== NodeEnvironment.CONTRACT_PREFIX;
}
} else {
return transaction.getDestinationAddress().toBytes()[0]
== NodeEnvironment.CONTRACT_PREFIX;
return false;
}
}
}

0 comments on commit aa2cfb4

Please sign in to comment.