[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.
Adrian Sutton 6 years ago committed by GitHub
parent b8dbe88358
commit 6fa1e7354b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/AbstractWorldUpdater.java
  2. 8
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/WorldUpdater.java
  3. 21
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/WorldView.java
  4. 5
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/worldstate/DefaultMutableWorldState.java
  5. 2
      ethereum/referencetests/src/test/resources

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

@ -77,14 +77,6 @@ public interface WorldUpdater extends MutableWorldView {
*/ */
MutableAccount getMutable(Address address); 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. * Deletes the provided account.
* *

@ -14,7 +14,18 @@ package tech.pegasys.pantheon.ethereum.core;
/** Generic interface for a view over the accounts of the world state. */ /** Generic interface for a view over the accounts of the world state. */
public interface WorldView { 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. * Get an account provided it's address.
@ -24,4 +35,12 @@ public interface WorldView {
* such account. * such account.
*/ */
Account get(Address address); 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);
} }

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

@ -1 +1 @@
Subproject commit 95a309203890e6244c6d4353ca411671973c13b5 Subproject commit e9d998ff7a5e71679ce02f21583dc89df4a87c13
Loading…
Cancel
Save