Skip to content

Commit

Permalink
bug fix: removing the dirty setting cause a break in consensus for co…
Browse files Browse the repository at this point in the history
…ntracts deployed without code or storage
  • Loading branch information
AlexandraRoatis committed Apr 9, 2019
1 parent a016ec9 commit 1a79fb6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.aion.log.LogEnum;
import org.aion.mcf.core.AccountState;
import org.aion.mcf.db.IBlockStoreBase;
import org.aion.mcf.tx.TransactionTypes;
import org.aion.types.Address;
import org.aion.types.ByteArrayWrapper;
import org.slf4j.Logger;
Expand Down Expand Up @@ -61,6 +62,7 @@ public AccountState createAccount(Address address) {

// TODO: unify contract details initialization from Impl and Track
ContractDetails contractDetails = new ContractDetailsCacheImpl(null);
contractDetails.setDirty(true);
cachedDetails.put(address, contractDetails);

return accountState;
Expand Down Expand Up @@ -482,7 +484,9 @@ public void flushCopiesTo(Repository other, boolean clearStateAfterFlush) {
ContractDetails ctd = entry.getValue().copy();
// TODO: this functionality will be improved with the switch to a
// different ContractDetails implementation
if (ctd != null && ctd instanceof ContractDetailsCacheImpl) {
if (ctd != null
&& ctd instanceof ContractDetailsCacheImpl
&& ctd.getVmType() != TransactionTypes.DEFAULT) {
ContractDetailsCacheImpl contractDetailsCache = (ContractDetailsCacheImpl) ctd;
contractDetailsCache.commit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.aion.mcf.trie.TrieNodeResult;
import org.aion.mcf.tx.TransactionTypes;
import org.aion.p2p.V1Constants;
import org.aion.precompiled.ContractFactory;
import org.aion.types.Address;
import org.aion.types.ByteArrayWrapper;
import org.aion.util.conversions.Hex;
Expand Down Expand Up @@ -136,7 +137,9 @@ public void updateBatch(
}
} else {

if (!contractDetails.isDirty()) {
if (!contractDetails.isDirty()
|| (contractDetails.getVmType() == TransactionTypes.DEFAULT
&& !ContractFactory.isPrecompiledContract(address))) {
// code added because contract details are not reliably
// marked as dirty at present
// TODO: issue above will be solved with the conversion to a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ public ByteArrayWrapper get(ByteArrayWrapper key) {
}

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

setDirty(true);
setDirty(true);
}
}

public byte getVmType() {
Expand Down

0 comments on commit 1a79fb6

Please sign in to comment.