Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object graph changes for AVM testnet reset #873

Merged
merged 5 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified lib/org-aion-avm-api.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-core.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-rt.jar
Binary file not shown.
Binary file modified lib/org-aion-avm-userlib.jar
Binary file not shown.
12 changes: 12 additions & 0 deletions modAionImpl/src/org/aion/zero/impl/AionBlockchainImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,18 @@ private AionBlockSummary applyBlock(IAionBlock block) {
for (AionTxExecSummary summary : executionSummaries) {
receipts.add(summary.getReceipt());
summaries.add(summary);

// save contract creation data to contract details
AionTxReceipt receipt = summary.getReceipt();
AionTransaction tx = receipt.getTransaction();
if (tx.isContractCreationTransaction() && receipt.isSuccessful()) {
track.saveVmType(
tx.getContractAddress(),
TransactionTypeRule.isValidAVMContractDeployment(tx.getTargetVM())
? TransactionTypes.AVM_CREATE_CODE
// FVM contracts do not always have the correct type
: TransactionTypes.FVM_CREATE_CODE);
}
}
}
Map<Address, BigInteger> rewards = addReward(block);
Expand Down
6 changes: 5 additions & 1 deletion modAionImpl/src/org/aion/zero/impl/AionHubUtils.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.aion.zero.impl;

import static org.aion.mcf.tx.TransactionTypes.FVM_CREATE_CODE;

import java.math.BigInteger;
import java.util.Map;
import org.aion.interfaces.db.RepositoryCache;
import org.aion.mcf.vm.types.DataWordImpl;
import org.aion.precompiled.ContractFactory;
import org.aion.types.Address;
import org.aion.types.ByteArrayWrapper;
import org.aion.precompiled.ContractFactory;
import org.aion.zero.impl.db.AionRepositoryImpl;

/** {@link AionHub} functionality where a full instantiation of the class is not desirable. */
Expand All @@ -18,6 +20,8 @@ public static void buildGenesis(AionGenesis genesis, AionRepositoryImpl reposito

Address networkBalanceAddress = ContractFactory.getTotalCurrencyContractAddress();
track.createAccount(networkBalanceAddress);
// saving FVM type for networkBalance contract
track.saveVmType(networkBalanceAddress, FVM_CREATE_CODE);

for (Map.Entry<Integer, BigInteger> addr : genesis.getNetworkBalances().entrySet()) {
// assumes only additions are performed in the genesis
Expand Down
17 changes: 10 additions & 7 deletions modAionImpl/src/org/aion/zero/impl/StandaloneBlockchain.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.aion.zero.impl;

import static org.aion.mcf.tx.TransactionTypes.FVM_CREATE_CODE;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -8,23 +10,23 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.aion.interfaces.db.ContractDetails;
import org.aion.interfaces.db.PruneConfig;
import org.aion.interfaces.db.RepositoryCache;
import org.aion.interfaces.db.RepositoryConfig;
import org.aion.mcf.vm.types.DataWordImpl;
import org.aion.types.Address;
import org.aion.types.ByteArrayWrapper;
import org.aion.crypto.ECKey;
import org.aion.crypto.ECKeyFac;
import org.aion.crypto.HashUtil;
import org.aion.db.impl.DBVendor;
import org.aion.db.impl.DatabaseFactory;
import org.aion.interfaces.db.ContractDetails;
import org.aion.interfaces.db.PruneConfig;
import org.aion.interfaces.db.RepositoryCache;
import org.aion.interfaces.db.RepositoryConfig;
import org.aion.mcf.config.CfgPrune;
import org.aion.mcf.core.AccountState;
import org.aion.mcf.core.ImportResult;
import org.aion.mcf.valid.BlockHeaderValidator;
import org.aion.mcf.vm.types.DataWordImpl;
import org.aion.precompiled.ContractFactory;
import org.aion.types.Address;
import org.aion.types.ByteArrayWrapper;
import org.aion.types.Hash256;
import org.aion.zero.exceptions.HeaderStructureException;
import org.aion.zero.impl.blockchain.ChainConfiguration;
Expand Down Expand Up @@ -317,6 +319,7 @@ public AbstractEnergyStrategyLimit getEnergyLimitStrategy() {

RepositoryCache track = bc.getRepository().startTracking();
track.createAccount(ContractFactory.getTotalCurrencyContractAddress());
track.saveVmType(ContractFactory.getTotalCurrencyContractAddress(), FVM_CREATE_CODE);

for (Map.Entry<Integer, BigInteger> key : genesis.getNetworkBalances().entrySet()) {
// assumes only additions can be made in the genesis
Expand Down
16 changes: 5 additions & 11 deletions modAionImpl/src/org/aion/zero/impl/db/AbstractContractDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ public abstract class AbstractContractDetails implements ContractDetails {
protected int detailsInMemoryStorageLimit;

private Map<ByteArrayWrapper, byte[]> codes = new HashMap<>();
// set to FVM_CREATE_CODE to update encoding for FVM contracts
protected byte vmType = TransactionTypes.FVM_CREATE_CODE;
private byte[] performCode;
// classes extending this rely on this value starting off as null
protected byte[] objectGraph = null;

// using the default transaction type to specify undefined VM
protected byte vmType = TransactionTypes.DEFAULT;

protected AbstractContractDetails() {
this(0, 64 * 1024);
Expand Down Expand Up @@ -61,7 +64,6 @@ public void setTransformedCode(byte[] transformedCode) {
setDirty(true);
}


@Override
public void setCode(byte[] code) {
if (code == null) {
Expand All @@ -88,14 +90,6 @@ public void appendCodes(Map<ByteArrayWrapper, byte[]> codes) {
this.codes.putAll(codes);
}

public void setVmType(byte vmType) {
this.vmType = vmType;
}

public byte getVmType() {
return vmType;
}

@Override
public void setDirty(boolean dirty) {
this.dirty = dirty;
Expand Down
Loading