Search in sources :

Example 1 with WrappedEvmAccount

use of org.hyperledger.besu.evm.worldstate.WrappedEvmAccount in project besu by hyperledger.

the class PrivacyBlockProcessorTest method mockPrivateStateArchive.

private MutableWorldState mockPrivateStateArchive() {
    final MutableWorldState mockPrivateState = mock(MutableWorldState.class);
    final WorldUpdater mockWorldUpdater = mock(WorldUpdater.class);
    final WrappedEvmAccount mockWrappedEvmAccount = mock(WrappedEvmAccount.class);
    final MutableAccount mockMutableAccount = mock(MutableAccount.class);
    when(mockWrappedEvmAccount.getMutable()).thenReturn(mockMutableAccount);
    when(mockWorldUpdater.createAccount(any())).thenReturn(mockWrappedEvmAccount);
    when(mockPrivateState.updater()).thenReturn(mockWorldUpdater);
    when(mockPrivateState.rootHash()).thenReturn(Hash.ZERO);
    return mockPrivateState;
}
Also used : MutableWorldState(org.hyperledger.besu.ethereum.core.MutableWorldState) WorldUpdater(org.hyperledger.besu.evm.worldstate.WorldUpdater) WrappedEvmAccount(org.hyperledger.besu.evm.worldstate.WrappedEvmAccount) MutableAccount(org.hyperledger.besu.evm.account.MutableAccount)

Example 2 with WrappedEvmAccount

use of org.hyperledger.besu.evm.worldstate.WrappedEvmAccount in project besu by hyperledger.

the class DebugOperationTracerTest method setupStorageForCapture.

private Map<UInt256, UInt256> setupStorageForCapture(final MessageFrame frame) {
    final WrappedEvmAccount account = mock(WrappedEvmAccount.class);
    final MutableAccount mutableAccount = mock(MutableAccount.class);
    when(account.getMutable()).thenReturn(mutableAccount);
    when(worldUpdater.getAccount(frame.getRecipientAddress())).thenReturn(account);
    final Map<UInt256, UInt256> updatedStorage = new TreeMap<>();
    updatedStorage.put(UInt256.ZERO, UInt256.valueOf(233));
    updatedStorage.put(UInt256.ONE, UInt256.valueOf(2424));
    when(mutableAccount.getUpdatedStorage()).thenReturn(updatedStorage);
    final Bytes32 word1 = Bytes32.fromHexString("0x01");
    final Bytes32 word2 = Bytes32.fromHexString("0x02");
    final Bytes32 word3 = Bytes32.fromHexString("0x03");
    frame.writeMemory(0, 32, word1);
    frame.writeMemory(32, 32, word2);
    frame.writeMemory(64, 32, word3);
    return updatedStorage;
}
Also used : WrappedEvmAccount(org.hyperledger.besu.evm.worldstate.WrappedEvmAccount) MutableAccount(org.hyperledger.besu.evm.account.MutableAccount) TreeMap(java.util.TreeMap) Bytes32(org.apache.tuweni.bytes.Bytes32) UInt256(org.apache.tuweni.units.bigints.UInt256)

Example 3 with WrappedEvmAccount

use of org.hyperledger.besu.evm.worldstate.WrappedEvmAccount in project besu by hyperledger.

the class DefaultMutablePrivateWorldStateUpdater method getAccount.

@Override
public EvmAccount getAccount(final Address address) {
    final EvmAccount privateAccount = privateWorldUpdater.getAccount(address);
    if (privateAccount != null && !privateAccount.isEmpty()) {
        return privateAccount;
    }
    final EvmAccount publicAccount = publicWorldUpdater.getAccount(address);
    if (publicAccount != null && !publicAccount.isEmpty()) {
        // FIXME
        ((WrappedEvmAccount) publicAccount).setImmutable(true);
        return publicAccount;
    }
    return privateAccount;
}
Also used : WrappedEvmAccount(org.hyperledger.besu.evm.worldstate.WrappedEvmAccount) EvmAccount(org.hyperledger.besu.evm.account.EvmAccount) WrappedEvmAccount(org.hyperledger.besu.evm.worldstate.WrappedEvmAccount)

Aggregations

WrappedEvmAccount (org.hyperledger.besu.evm.worldstate.WrappedEvmAccount)3 MutableAccount (org.hyperledger.besu.evm.account.MutableAccount)2 TreeMap (java.util.TreeMap)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 UInt256 (org.apache.tuweni.units.bigints.UInt256)1 MutableWorldState (org.hyperledger.besu.ethereum.core.MutableWorldState)1 EvmAccount (org.hyperledger.besu.evm.account.EvmAccount)1 WorldUpdater (org.hyperledger.besu.evm.worldstate.WorldUpdater)1