[NC-1752] Fix SSTORE original value (#79)

* [NC-1752] Delegate calls to getOriginalAccount all the way to the actual store. Ensures we get the actual original value even when updaters are nested due to nested calls.

* Upgrade ethereum reference tests to include the new sstore tests.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
This commit is contained in:
Adrian Sutton
2018-10-17 16:12:52 +10:00
committed by GitHub
parent 89da64f96c
commit 9a464a29b9
5 changed files with 27 additions and 11 deletions

View File

@@ -79,7 +79,7 @@ public abstract class AbstractWorldUpdater<W extends WorldView, A extends Accoun
@Override
public Account getOriginalAccount(final Address address) {
return world.get(address);
return world.getOriginalAccount(address);
}
@Override

View File

@@ -77,14 +77,6 @@ public interface WorldUpdater extends MutableWorldView {
*/
MutableAccount getMutable(Address address);
/**
* Retrieve the original account, prior to any modifications made by this updater.
*
* @param address the address of the account.
* @return the account {@code address} or {@code null} if the account does not exist.
*/
Account getOriginalAccount(Address address);
/**
* Deletes the provided account.
*

View File

@@ -14,7 +14,18 @@ package tech.pegasys.pantheon.ethereum.core;
/** Generic interface for a view over the accounts of the world state. */
public interface WorldView {
WorldView EMPTY = address -> null;
WorldView EMPTY =
new WorldView() {
@Override
public Account get(final Address address) {
return null;
}
@Override
public Account getOriginalAccount(final Address address) {
return null;
}
};
/**
* Get an account provided it's address.
@@ -24,4 +35,12 @@ public interface WorldView {
* such account.
*/
Account get(Address address);
/**
* Retrieve the original account, prior to any modifications made in this transaction.
*
* @param address the address of the account.
* @return the account {@code address} or {@code null} if the account does not exist.
*/
Account getOriginalAccount(Address address);
}

View File

@@ -100,6 +100,11 @@ public class DefaultMutableWorldState implements MutableWorldState {
.orElse(null);
}
@Override
public Account getOriginalAccount(final Address address) {
return get(address);
}
private AccountState deserializeAccount(
final Address address, final Hash addressHash, final BytesValue encoded) throws RLPException {
final RLPInput in = RLP.input(encoded);