Skip to content

Commit

Permalink
Update fvm lib for fixing callback issue (CP-27)
Browse files Browse the repository at this point in the history
  • Loading branch information
AionJayT committed Apr 15, 2020
1 parent 6335911 commit 50bd96b
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 22 deletions.
Binary file renamed lib/fastvm-4d55b49.jar → lib/fastvm-9f1f780.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion modAionImpl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dependencies {
compile project(':modEvtMgrImpl')
compile project(':modPrecompiled')
compile project(':modTxPool')
compile files("${rootProject.projectDir}/lib/fastvm-4d55b49.jar")
compile files("${rootProject.projectDir}/lib/fastvm-9f1f780.jar")
compile 'org.json:json:20180813'
compile 'info.picocli:picocli:4.0.0'
compile files("${rootProject.projectDir}/lib/aion-types-22a3be9.jar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,8 @@ private RetValidPreBlock generatePreBlock(Block block) {
getPostExecutionWorkForGeneratePreBlock(repository),
BlockCachingContext.PENDING,
bestBlock.getNumber(),
forkUtility.isUnityForkActive(block.getNumber()));
forkUtility.isUnityForkActive(block.getNumber()),
forkUtility.isSignatureSwapForkActive(block.getNumber()));

for (AionTxExecSummary summary : executionSummaries) {
if (!summary.isRejected()) {
Expand Down Expand Up @@ -1823,7 +1824,8 @@ private AionBlockSummary applyBlock(Block block) {
getPostExecutionWorkForApplyBlock(repository),
executionTypeForAVM,
cachedBlockNumberForAVM,
forkUtility.isUnityForkActive(block.getNumber()));
forkUtility.isUnityForkActive(block.getNumber()),
forkUtility.isSignatureSwapForkActive(block.getNumber()));

// Check for rejected transaction already included in the chain.
if (isException(block.getNumber())) {
Expand Down
8 changes: 6 additions & 2 deletions modAionImpl/src/org/aion/zero/impl/blockchain/AionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public long estimateTxNrg(AionTransaction tx, Block block) {
boolean fork040enabled = false;
boolean checkBlockEnergyLimit = false;
boolean unityForkEnabled = false;
boolean signatureSwapForkEnabled = ((AionBlockchainImpl)aionHub.getBlockchain()).forkUtility.isSignatureSwapForkActive(block.getNumber());

return BulkExecutor.executeTransactionWithNoPostExecutionWork(
block.getDifficulty(),
Expand All @@ -148,7 +149,8 @@ public long estimateTxNrg(AionTransaction tx, Block block) {
LOG_VM,
BlockCachingContext.CALL,
block.getNumber(),
unityForkEnabled)
unityForkEnabled,
signatureSwapForkEnabled)
.getReceipt()
.getEnergyUsed();
} catch (VmFatalException e) {
Expand All @@ -172,6 +174,7 @@ public AionTxReceipt callConstant(AionTransaction tx, Block block) {
boolean fork040enabled = false;
boolean checkBlockEnergyLimit = false;
boolean unityForkEnabled = false;
boolean signatureSwapForkEnabled = ((AionBlockchainImpl)aionHub.getBlockchain()).forkUtility.isSignatureSwapForkActive(block.getNumber());

return BulkExecutor.executeTransactionWithNoPostExecutionWork(
block.getDifficulty(),
Expand All @@ -188,7 +191,8 @@ public AionTxReceipt callConstant(AionTransaction tx, Block block) {
LOG_VM,
BlockCachingContext.CALL,
block.getNumber(),
unityForkEnabled)
unityForkEnabled,
signatureSwapForkEnabled)
.getReceipt();
} catch (VmFatalException e) {
LOG_GEN.error("Shutdown due to a VM fatal error.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,8 @@ private AionTxExecSummary executeTx(AionTransaction tx) {
LOGGER_VM,
BlockCachingContext.PENDING,
bestBlk.getNumber(),
blockchain.forkUtility.isUnityForkActive(currentBlockNumber));
blockchain.forkUtility.isUnityForkActive(currentBlockNumber),
blockchain.forkUtility.isSignatureSwapForkActive(currentBlockNumber));
} catch (VmFatalException e) {
LOGGER_VM.error("Shutdown due to a VM fatal error.", e);
System.exit(SystemExitCodes.FATAL_VM_ERROR);
Expand Down
25 changes: 17 additions & 8 deletions modAionImpl/src/org/aion/zero/impl/vm/common/BulkExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public final class BulkExecutor {
* @param cachedBlockNumber represents a main chain block that is common to the current main
* chain and the block that is about to be imported used for cache retrieval (AVM specific
* parameter)
* @param signatureSwapForkEnabled the flag represents the current signature swap consensus status.
*/
public static List<AionTxExecSummary> executeAllTransactionsInBlock(
byte[] blockDifficulty,
Expand All @@ -75,7 +76,8 @@ public static List<AionTxExecSummary> executeAllTransactionsInBlock(
PostExecutionWork postExecutionWork,
BlockCachingContext blockCachingContext,
long cachedBlockNumber,
boolean unityForkEnabled)
boolean unityForkEnabled,
boolean signatureSwapForkEnabled)
throws VmFatalException {

if (blockDifficulty == null) {
Expand Down Expand Up @@ -113,7 +115,8 @@ public static List<AionTxExecSummary> executeAllTransactionsInBlock(
fork040Enable,
blockCachingContext,
cachedBlockNumber,
unityForkEnabled);
unityForkEnabled,
signatureSwapForkEnabled);
}

/**
Expand Down Expand Up @@ -153,7 +156,8 @@ public static AionTxExecSummary executeTransactionWithNoPostExecutionWork(
Logger logger,
BlockCachingContext blockCachingContext,
long cachedBlockNumber,
boolean unityforkEnabled)
boolean unityforkEnabled,
boolean signatureSwapForkEnabled)
throws VmFatalException {

if (blockDifficulty == null) {
Expand Down Expand Up @@ -185,7 +189,8 @@ public static AionTxExecSummary executeTransactionWithNoPostExecutionWork(
fork040Enable,
blockCachingContext,
cachedBlockNumber,
unityforkEnabled)
unityforkEnabled,
signatureSwapForkEnabled)
.get(0);
}

Expand All @@ -206,7 +211,8 @@ private static List<AionTxExecSummary> executeInternal(
boolean fork040enabled,
BlockCachingContext blockCachingContext,
long cachedBlockNumber,
boolean unityForkEnabled)
boolean unityForkEnabled,
boolean signatureSwapForkEnabled)
throws VmFatalException {
List<AionTxExecSummary> allSummaries = new ArrayList<>();

Expand Down Expand Up @@ -256,7 +262,8 @@ private static List<AionTxExecSummary> executeInternal(
isLocalCall,
blockRemainingEnergy,
fork040enabled,
unityForkEnabled);
unityForkEnabled,
signatureSwapForkEnabled);
} else if (transactionIsPrecompiledContractCall(firstTransactionInNextBatch)) {
currentBatchOfSummaries =
executeNextBatchOfPrecompiledTransactions(
Expand Down Expand Up @@ -367,7 +374,8 @@ private static List<AionTxExecSummary> executeNextBatchOfFvmTransactions(
boolean isLocalCall,
long blockRemainingEnergy,
boolean fork040enabled,
boolean unityForkEnabled)
boolean unityForkEnabled,
boolean signatureSwapForkEnabled)
throws VmFatalException {

// Grab the next batch of fvm transactions to execute.
Expand All @@ -393,7 +401,8 @@ private static List<AionTxExecSummary> executeNextBatchOfFvmTransactions(
isLocalCall,
fork040enabled,
blockRemainingEnergy,
unityForkEnabled);
unityForkEnabled,
signatureSwapForkEnabled);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public final class ExternalStateForFvm implements IExternalStateForFvm {
private final long blockEnergyLimit;
private final FvmDataWord blockDifficulty;
private final boolean isUnityForkEnabled;
private final boolean signatureSwapForkEnabled;

public ExternalStateForFvm(RepositoryCache<AccountState> repository, AionAddress miner, FvmDataWord blockDifficulty, boolean isLocalCall, boolean allowNonceIncrement, boolean isFork040enabled, long blockNumber, long blockTimestamp, long blockEnergyLimit, boolean unityForkEnabled) {
public ExternalStateForFvm(RepositoryCache<AccountState> repository, AionAddress miner, FvmDataWord blockDifficulty, boolean isLocalCall, boolean allowNonceIncrement, boolean isFork040enabled, long blockNumber, long blockTimestamp, long blockEnergyLimit, boolean unityForkEnabled, boolean signatureSwapForkEnabled) {
this.repository = repository;
this.miner = miner;
this.blockDifficulty = blockDifficulty;
Expand All @@ -48,6 +49,7 @@ public ExternalStateForFvm(RepositoryCache<AccountState> repository, AionAddress
this.blockTimestamp = blockTimestamp;
this.blockEnergyLimit = blockEnergyLimit;
this.isUnityForkEnabled = unityForkEnabled;
this.signatureSwapForkEnabled = signatureSwapForkEnabled;
}

/** Commits the changes in this world state to its parent world state. */
Expand Down Expand Up @@ -79,7 +81,7 @@ public void rollback() {
*/
@Override
public IExternalStateForFvm newChildExternalState() {
return new ExternalStateForFvm(this.repository.startTracking(), this.miner, this.blockDifficulty, this.isLocalCall, this.allowNonceIncrement, this.isFork040enabled, this.blockNumber, this.blockTimestamp, this.blockEnergyLimit, this.isUnityForkEnabled);
return new ExternalStateForFvm(this.repository.startTracking(), this.miner, this.blockDifficulty, this.isLocalCall, this.allowNonceIncrement, this.isFork040enabled, this.blockNumber, this.blockTimestamp, this.blockEnergyLimit, this.isUnityForkEnabled, this.signatureSwapForkEnabled);
}

/**
Expand Down Expand Up @@ -498,6 +500,11 @@ public byte[] getBlockHashByNumber(long blockNumber) {
return this.repository.getBlockHashByNumber(blockNumber);
}

@Override
public boolean isForkSignatureSwapEnabled() {
return this.signatureSwapForkEnabled;
}

/**
* If data.length > 16 then data is aligned to be 32 bytes.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public static List<AionTxExecSummary> executeTransactions(
boolean isLocalCall,
boolean fork040enabled,
long initialBlockEnergyLimit,
boolean unityForkEnabled)
boolean unityForkEnabled,
boolean signatureSwapForkEnabled)
throws VmFatalException {

List<AionTxExecSummary> transactionSummaries = new ArrayList<>();
Expand All @@ -91,7 +92,8 @@ public static List<AionTxExecSummary> executeTransactions(
blockNumber,
blockTimestamp,
blockNrgLimit,
unityForkEnabled);
unityForkEnabled,
signatureSwapForkEnabled);

// Process the results of the transactions.
for (AionTransaction transaction : transactions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ private AionTxExecSummary executeTransaction(AionTransaction transaction, boolea
getPostExecutionWorkForGeneratePreBlock(blockchain.getRepository()),
BlockCachingContext.PENDING,
block.getNumber(),
false,
false);

return list.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ private AionTxExecSummary executeTransaction(AionTransaction transaction) throws
getPostExecutionWorkForGeneratePreBlock(blockchain.getRepository()),
BlockCachingContext.PENDING,
block.getNumber(),
false,
false);

return list.get(0);
Expand Down
1 change: 1 addition & 0 deletions modAionImpl/test/org/aion/zero/impl/vm/Benchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ private static AionTxExecSummary executeTransaction(AionTransaction transaction)
LOGGER,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);
}
}
4 changes: 4 additions & 0 deletions modAionImpl/test/org/aion/zero/impl/vm/ContractIntegTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public void testFvmEmptyContract() throws Exception {
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);

if (txType == TransactionTypes.DEFAULT) {
Expand Down Expand Up @@ -1934,6 +1935,7 @@ private AionTxExecSummary executeTransaction(
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);
}

Expand Down Expand Up @@ -2031,6 +2033,7 @@ public void testFvmEmptyContractWith200KEnrygyBeforeUnity() throws IOException,
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);

if (txType == TransactionTypes.DEFAULT) {
Expand Down Expand Up @@ -2150,6 +2153,7 @@ public void testFvmEmptyContractWith226160EnergyAfterUnity() throws IOException,
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);

if (txType == TransactionTypes.DEFAULT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ private AionTxExecSummary executeTransaction(
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ private AionTxExecSummary executeTransaction(
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ private AionTxExecSummary executeTransaction(
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ private AionTxExecSummary executeTransaction(
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ private AionTxExecSummary executeTransaction(
LOGGER_VM,
BlockCachingContext.PENDING,
block.getNumber() - 1,
false,
false);
}
}
2 changes: 1 addition & 1 deletion modApiServer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {
compile project(':modCrypto')

compile project(':modAionImpl')
compile files("${rootProject.projectDir}/lib/fastvm-4d55b49.jar")
compile files("${rootProject.projectDir}/lib/fastvm-9f1f780.jar")
compile project(':modMcf')
compile project(':modEvtMgr')
compile project(':modEvtMgrImpl')
Expand Down
2 changes: 1 addition & 1 deletion modBase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ unitTest.dependsOn copyNativeLibsForModuleTests
clean.dependsOn deleteNativeLibs

dependencies {
compile files("${rootProject.projectDir}/lib/fastvm-4d55b49.jar")
compile files("${rootProject.projectDir}/lib/fastvm-9f1f780.jar")
compile files("${rootProject.projectDir}/lib/aion-types-22a3be9.jar")
compile project(':modUtil')
compile project(':modLogger')
Expand Down
2 changes: 1 addition & 1 deletion modBoot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
compile project(':modMcf')
compile project(':3rdParty.libnzmq')
compile 'org.slf4j:slf4j-api:1.7.25'
compile files("${rootProject.projectDir}/lib/fastvm-4d55b49.jar")
compile files("${rootProject.projectDir}/lib/fastvm-9f1f780.jar")

testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-all:1.3'
Expand Down
2 changes: 1 addition & 1 deletion modMcf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
compile 'com.madgag.spongycastle:prov:1.58.0.0'
compile 'com.madgag.spongycastle:core:1.58.0.0'
compile files('../lib/libnsc.jar')
compile files("${rootProject.projectDir}/lib/fastvm-4d55b49.jar")
compile files("${rootProject.projectDir}/lib/fastvm-9f1f780.jar")
compile files("${rootProject.projectDir}/lib/aion-types-22a3be9.jar")
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'com.google.guava:guava:25.1-jre'
Expand Down

0 comments on commit 50bd96b

Please sign in to comment.