Search in sources :

Example 61 with DataWord

use of org.ethereum.vm.DataWord in project rskj by rsksmart.

the class RemascStorageProvider method getBrokenSelectionRule.

public Boolean getBrokenSelectionRule() {
    if (brokenSelectionRule != null) {
        return brokenSelectionRule;
    }
    DataWord address = new DataWord(BROKEN_SELECTION_RULE_KEY.getBytes(StandardCharsets.UTF_8));
    byte[] bytes = this.repository.getStorageBytes(this.contractAddress, address);
    if (bytes == null || bytes.length == 0) {
        return Boolean.FALSE;
    }
    if (bytes[0] == 0) {
        return Boolean.FALSE;
    } else {
        return Boolean.TRUE;
    }
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 62 with DataWord

use of org.ethereum.vm.DataWord in project rskj by rsksmart.

the class ContractDetailsCacheImpl method get.

@Override
public DataWord get(DataWord key) {
    DataWord value = storage.get(key);
    if (value != null) {
        value = value.clone();
    } else {
        if (origContract == null) {
            return null;
        }
        value = origContract.get(key);
        storage.put(key.clone(), value == null ? DataWord.ZERO.clone() : value.clone());
    }
    if (value == null || value.isZero()) {
        return null;
    } else {
        return value;
    }
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 63 with DataWord

use of org.ethereum.vm.DataWord in project rskj by rsksmart.

the class ContractDetailsCacheImpl method setStorage.

@Override
public void setStorage(List<DataWord> storageKeys, List<DataWord> storageValues) {
    for (int i = 0; i < storageKeys.size(); ++i) {
        DataWord key = storageKeys.get(i);
        DataWord value = storageValues.get(i);
        if (value.isZero()) {
            storage.put(key, null);
        }
    }
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 64 with DataWord

use of org.ethereum.vm.DataWord in project rskj by rsksmart.

the class Stack method swap.

public void swap(int from, int to) {
    if (isAccessible(from) && isAccessible(to) && (from != to)) {
        if (traceListener != null) {
            traceListener.onStackSwap(from, to);
        }
        DataWord tmp = get(from);
        set(from, set(to, tmp));
    }
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 65 with DataWord

use of org.ethereum.vm.DataWord in project rskj by rsksmart.

the class ProgramInvokeImpl method getDataValue.

/*     CALLDATALOAD  op   */
public DataWord getDataValue(DataWord indexData) {
    BigInteger tempIndex = indexData.value();
    // possible overflow is caught below
    int index = tempIndex.intValue();
    // maximum datavalue size
    int size = 32;
    if (msgData == null || index >= msgData.length || tempIndex.compareTo(maxMsgData) == 1) {
        return new DataWord();
    }
    if (index + size > msgData.length) {
        size = msgData.length - index;
    }
    byte[] data = new byte[32];
    System.arraycopy(msgData, index, data, 0, size);
    return new DataWord(data);
}
Also used : BigInteger(java.math.BigInteger) DataWord(org.ethereum.vm.DataWord)

Aggregations

DataWord (org.ethereum.vm.DataWord)133 Test (org.junit.Test)88 Repository (org.ethereum.core.Repository)41 RskAddress (co.rsk.core.RskAddress)25 TestUtils.randomDataWord (org.ethereum.TestUtils.randomDataWord)22 BigInteger (java.math.BigInteger)19 LogInfo (org.ethereum.vm.LogInfo)17 HashMapDB (org.ethereum.datasource.HashMapDB)14 Program (org.ethereum.vm.program.Program)13 Stack (org.ethereum.vm.program.Stack)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)11 InvocationOnMock (org.mockito.invocation.InvocationOnMock)11 RepositoryImpl (co.rsk.db.RepositoryImpl)9 ContractDetails (org.ethereum.db.ContractDetails)9 Trie (co.rsk.trie.Trie)8 CallTransaction (org.ethereum.core.CallTransaction)8 TrieImpl (co.rsk.trie.TrieImpl)7 TrieStore (co.rsk.trie.TrieStore)7 Coin (co.rsk.core.Coin)5