Skip to content

Commit

Permalink
Update AVM v2 jars to commit 4aa3cd0
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Jan 7, 2020
1 parent ed8537e commit 110697a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
Binary file modified lib/modAvmVersion2.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-api-v2.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-core-v2.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-rt-v2.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-tooling-v2.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-userlib-v2.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-utilities-v2.jar
Binary file not shown.
42 changes: 24 additions & 18 deletions modAvmVersion2/src/org/aion/avm/version2/ContractFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import org.aion.avm.core.dappreading.UserlibJarBuilder;
import org.aion.avm.stub.IContractFactory;
import org.aion.avm.tooling.deploy.OptimizedJarBuilder;
import org.aion.avm.userlib.CodeAndArguments;
import org.aion.avm.userlib.abi.ABIDecoder;
import org.aion.avm.userlib.abi.ABIEncoder;
import org.aion.avm.userlib.abi.ABIException;
import org.aion.avm.userlib.abi.ABIToken;
import org.aion.avm.version2.contracts.GenericContract;
import org.aion.avm.version2.contracts.HelloWorld;
import org.aion.avm.version2.contracts.InternalTransaction;
Expand All @@ -25,19 +22,19 @@ public byte[] getDeploymentBytes(AvmContract contract) {

switch (contract) {
case HELLO_WORLD:
return new CodeAndArguments(UserlibJarBuilder.buildJarForMainAndClasses(HelloWorld.class, ABIDecoder.class, ABIException.class, ABIToken.class), new byte[0]).encodeToBytes();
return new CodeAndArguments(getOptimizedDappBytes(HelloWorld.class), new byte[0]).encodeToBytes();
case LOG_TARGET:
return new CodeAndArguments(UserlibJarBuilder.buildJarForMainAndClasses(LogTarget.class, ABIDecoder.class, ABIException.class, ABIToken.class), new byte[0]).encodeToBytes();
return new CodeAndArguments(getOptimizedDappBytes(LogTarget.class), new byte[0]).encodeToBytes();
case STATEFULNESS:
return new CodeAndArguments(UserlibJarBuilder.buildJarForMainAndClasses(Statefulness.class, ABIEncoder.class, ABIDecoder.class, ABIException.class, ABIToken.class), new byte[0]).encodeToBytes();
return new CodeAndArguments(getOptimizedDappBytes(Statefulness.class), new byte[0]).encodeToBytes();
case GENERIC_CONTRACT:
return new CodeAndArguments(UserlibJarBuilder.buildJarForMainAndClasses(GenericContract.class, ABIDecoder.class, ABIException.class, ABIToken.class), new byte[0]).encodeToBytes();
return new CodeAndArguments(getOptimizedDappBytes(GenericContract.class), new byte[0]).encodeToBytes();
case INTERNAL_TRANSACTION:
return new CodeAndArguments(UserlibJarBuilder.buildJarForMainAndClasses(InternalTransaction.class, ABIEncoder.class, ABIDecoder.class, ABIException.class, ABIToken.class), new byte[0]).encodeToBytes();
return new CodeAndArguments(getOptimizedDappBytes(InternalTransaction.class), new byte[0]).encodeToBytes();
case TRANSACTION_HASH:
return new CodeAndArguments(UserlibJarBuilder.buildJarForMainAndClasses(TransactionHash.class), new byte[0]).encodeToBytes();
return new CodeAndArguments(getOptimizedDappBytes(TransactionHash.class), new byte[0]).encodeToBytes();
case META_TRANSACTION_PROXY:
return new CodeAndArguments(UserlibJarBuilder.buildJarForMainAndClasses(MetaTransactionProxy.class, ABIEncoder.class, ABIDecoder.class, ABIException.class, ABIToken.class), new byte[0]).encodeToBytes();
return new CodeAndArguments(getOptimizedDappBytes(MetaTransactionProxy.class), new byte[0]).encodeToBytes();
default : throw new IllegalStateException("The following contract is not supported by version 2 of the avm: " + contract);
}
}
Expand All @@ -50,20 +47,29 @@ public byte[] getJarBytes(AvmContract contract) {

switch (contract) {
case HELLO_WORLD:
return UserlibJarBuilder.buildJarForMainAndClasses(HelloWorld.class, ABIDecoder.class, ABIException.class, ABIToken.class);
return getOptimizedDappBytes(HelloWorld.class);
case LOG_TARGET:
return UserlibJarBuilder.buildJarForMainAndClasses(LogTarget.class, ABIDecoder.class, ABIException.class, ABIToken.class);
return getOptimizedDappBytes(LogTarget.class);
case STATEFULNESS:
return UserlibJarBuilder.buildJarForMainAndClasses(Statefulness.class, ABIEncoder.class, ABIDecoder.class, ABIException.class, ABIToken.class);
return getOptimizedDappBytes(Statefulness.class);
case GENERIC_CONTRACT:
return UserlibJarBuilder.buildJarForMainAndClasses(GenericContract.class, ABIDecoder.class, ABIException.class, ABIToken.class);
return getOptimizedDappBytes(GenericContract.class);
case INTERNAL_TRANSACTION:
return UserlibJarBuilder.buildJarForMainAndClasses(InternalTransaction.class, ABIEncoder.class, ABIDecoder.class, ABIException.class, ABIToken.class);
return getOptimizedDappBytes(InternalTransaction.class);
case TRANSACTION_HASH:
return UserlibJarBuilder.buildJarForMainAndClasses(TransactionHash.class);
return getOptimizedDappBytes(TransactionHash.class);
case META_TRANSACTION_PROXY:
return UserlibJarBuilder.buildJarForMainAndClasses(MetaTransactionProxy.class, ABIEncoder.class, ABIDecoder.class, ABIException.class, ABIToken.class);
return getOptimizedDappBytes(MetaTransactionProxy.class);
default : throw new IllegalStateException("The following contract is not supported by version 2 of the avm: " + contract);
}
}

public byte[] getOptimizedDappBytes(Class<?> mainClass, Class<?> ...otherClasses) {
byte[] jarBytes = UserlibJarBuilder.buildJarForMainAndClassesAndUserlib(mainClass, otherClasses);
return new OptimizedJarBuilder(false, jarBytes, 1)
.withUnreachableMethodRemover()
.withRenamer()
.withConstantRemover()
.getOptimizedBytes();
}
}

0 comments on commit 110697a

Please sign in to comment.