Search in sources :

Example 51 with DataWord

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

the class ProgramInvokeMockImpl method getDataValue.

/**
 **************
 */
/**
 *  msg data **
 */
/**
 * *************
 */
/*     CALLDATALOAD  op   */
public DataWord getDataValue(DataWord indexData) {
    byte[] data = new byte[32];
    int index = indexData.value().intValue();
    int size = 32;
    if (msgData == null)
        return new DataWord(data);
    if (index > msgData.length)
        return new DataWord(data);
    if (index + 32 > msgData.length)
        size = msgData.length - index;
    System.arraycopy(msgData, index, data, 0, size);
    return new DataWord(data);
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 52 with DataWord

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

the class RepositoryBlockStore method setChainHead.

@Override
public void setChainHead(StoredBlock chainHead) throws BlockStoreException {
    byte[] ba = storedBlockToByteArray(chainHead);
    repository.addStorageBytes(contractAddress, new DataWord(BLOCK_STORE_CHAIN_HEAD_KEY.getBytes(StandardCharsets.UTF_8)), ba);
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 53 with DataWord

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

the class RepositoryBlockStore method put.

@Override
public synchronized void put(StoredBlock block) throws BlockStoreException {
    Sha256Hash hash = block.getHeader().getHash();
    byte[] ba = storedBlockToByteArray(block);
    repository.addStorageBytes(contractAddress, new DataWord(hash.toString()), ba);
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 54 with DataWord

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

the class SamplePrecompiledContract method GetResult.

public int GetResult(Object... args) {
    DataWord keyWord = new DataWord("result".getBytes(StandardCharsets.UTF_8));
    DataWord storedValue = repository.getStorageValue(contractAddress, keyWord);
    int result = (storedValue != null ? storedValue.intValue() : 0);
    return result;
}
Also used : DataWord(org.ethereum.vm.DataWord)

Example 55 with DataWord

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

the class BridgeEventLoggerImpl method logReleaseBtc.

public void logReleaseBtc(BtcTransaction btcTx) {
    List<DataWord> topics = Collections.singletonList(Bridge.RELEASE_BTC_TOPIC);
    byte[] data = RLP.encodeList(RLP.encodeString(btcTx.getHashAsString()), RLP.encodeElement(btcTx.bitcoinSerialize()));
    this.logs.add(new LogInfo(BRIDGE_CONTRACT_ADDRESS, topics, data));
}
Also used : LogInfo(org.ethereum.vm.LogInfo) 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