Fixed storage encode bug
This commit is contained in:
parent
eb382199cc
commit
7af06b8c18
|
@ -103,13 +103,15 @@ public class Blockchain {
|
||||||
}
|
}
|
||||||
for (int i = blocks.size() - 1; i >= 0 ; --i) {
|
for (int i = blocks.size() - 1; i >= 0 ; --i) {
|
||||||
this.addBlock(blocks.get(i));
|
this.addBlock(blocks.get(i));
|
||||||
|
|
||||||
|
|
||||||
|
long blockNum = blocks.get(i).getNumber();
|
||||||
/* Debug check to see if the state is still as expected */
|
/* Debug check to see if the state is still as expected */
|
||||||
if(logger.isWarnEnabled()) {
|
if(logger.isWarnEnabled()) {
|
||||||
String blockStateRootHash = Hex.toHexString(blocks.get(i).getStateRoot());
|
String blockStateRootHash = Hex.toHexString(blocks.get(i).getStateRoot());
|
||||||
String worldStateRootHash = Hex.toHexString(WorldManager.getInstance().getRepository().getWorldState().getRootHash());
|
String worldStateRootHash = Hex.toHexString(WorldManager.getInstance().getRepository().getWorldState().getRootHash());
|
||||||
if(!blockStateRootHash.equals(worldStateRootHash))
|
if(!blockStateRootHash.equals(worldStateRootHash))
|
||||||
logger.warn("WARNING: STATE CONFLICT! worldstate {} mismatch", worldStateRootHash);
|
logger.warn("WARNING: STATE CONFLICT! block: {} worldstate {} mismatch", blockNum, worldStateRootHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Remove all wallet transactions as they already approved by the net
|
// Remove all wallet transactions as they already approved by the net
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.ethereum.crypto.SHA3Helper;
|
||||||
import org.ethereum.trie.Trie;
|
import org.ethereum.trie.Trie;
|
||||||
import org.ethereum.util.RLP;
|
import org.ethereum.util.RLP;
|
||||||
import org.ethereum.util.RLPElement;
|
import org.ethereum.util.RLPElement;
|
||||||
|
@ -57,7 +58,7 @@ public class ContractDetails {
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
|
|
||||||
storageTrie.update(key.getData(), value.getData());
|
storageTrie.update(key.getData(), RLP.encodeElement( value.getNoLeadZeroesData() ));
|
||||||
|
|
||||||
int index = storageKeys.indexOf(key);
|
int index = storageKeys.indexOf(key);
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ public class ContractDetails {
|
||||||
for (int i = 0; i < keys.size(); ++i) {
|
for (int i = 0; i < keys.size(); ++i) {
|
||||||
DataWord key = storageKeys.get(i);
|
DataWord key = storageKeys.get(i);
|
||||||
DataWord value = storageValues.get(i);
|
DataWord value = storageValues.get(i);
|
||||||
storageTrie.update(key.getData(), value.getData());
|
storageTrie.update(key.getData(), RLP.encodeElement( value.getNoLeadZeroesData() ));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.code = code.getRLPData();
|
this.code = code.getRLPData();
|
||||||
|
@ -152,7 +153,7 @@ public class ContractDetails {
|
||||||
}
|
}
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
DataWord value = storageValues.get(i);
|
DataWord value = storageValues.get(i);
|
||||||
values[i] = RLP.encodeElement(value.getData());
|
values[i] = RLP.encodeElement(value.getNoLeadZeroesData());
|
||||||
}
|
}
|
||||||
byte[] rlpKeysList = RLP.encodeList(keys);
|
byte[] rlpKeysList = RLP.encodeList(keys);
|
||||||
byte[] rlpValuesList = RLP.encodeList(values);
|
byte[] rlpValuesList = RLP.encodeList(values);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.ethereum.json;
|
package org.ethereum.json;
|
||||||
|
|
||||||
|
import org.ethereum.util.RLP;
|
||||||
import org.ethereum.vm.DataWord;
|
import org.ethereum.vm.DataWord;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONValue;
|
import org.json.simple.JSONValue;
|
||||||
|
@ -28,7 +29,9 @@ public class JSONHelper {
|
||||||
|
|
||||||
for (DataWord key : storageKeys) {
|
for (DataWord key : storageKeys) {
|
||||||
outMap.put(Hex.toHexString(key.getData()),
|
outMap.put(Hex.toHexString(key.getData()),
|
||||||
Hex.toHexString(storageMap.get(key).getData()));
|
Hex.toHexString(
|
||||||
|
RLP.encodeElement( storageMap.get(key).getNoLeadZeroesData() )
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
String mapString = JSONValue.toJSONString(outMap);
|
String mapString = JSONValue.toJSONString(outMap);
|
||||||
|
|
Loading…
Reference in New Issue