Search in sources :

Example 61 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class BlockHeaderBuilder method build.

public static BlockHeader build(BlockHeaderTck headerTck) {
    BlockHeader header = new BlockHeader(parseData(headerTck.getParentHash()), parseData(headerTck.getUncleHash()), parseData(headerTck.getCoinbase()), parseData(headerTck.getBloom()), parseNumericData(headerTck.getDifficulty()), getPositiveLong(headerTck.getNumber()), parseData(headerTck.getGasLimit()), getPositiveLong(headerTck.getGasUsed()), getPositiveLong(headerTck.getTimestamp()), parseData(headerTck.getExtraData()), null, 0);
    header.setReceiptsRoot(parseData(headerTck.getReceiptTrie()));
    header.setTransactionsRoot(parseData(headerTck.getTransactionsTrie()));
    header.setStateRoot(parseData(headerTck.getStateRoot()));
    return header;
}
Also used : BlockHeader(org.ethereum.core.BlockHeader)

Example 62 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class DifficultyRuleTest method parentDifficultyLessHeaderDifficulty.

@Ignore
// pass rule
@Test
public void parentDifficultyLessHeaderDifficulty() {
    BlockHeader header = getHeader(10004);
    BlockHeader parent = getHeader(10000);
    assertTrue(rule.validate(header, parent));
}
Also used : BlockHeader(org.ethereum.core.BlockHeader) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 63 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class ParentGasLimitRuleTest method parentGasLimitTooGreaterThanGasLimit.

// no pass rule
@Test
public void parentGasLimitTooGreaterThanGasLimit() {
    BlockHeader header = getHeader(9);
    BlockHeader parent = getHeader(100);
    assertFalse(rule.validate(header, parent));
}
Also used : BlockHeader(org.ethereum.core.BlockHeader) Test(org.junit.Test)

Example 64 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class ParentGasLimitRuleTest method parentGasLimitTooLessThanGasLimit.

// no pass rule
@Test
public void parentGasLimitTooLessThanGasLimit() {
    BlockHeader header = getHeader(100);
    BlockHeader parent = getHeader(9);
    assertFalse(rule.validate(header, parent));
}
Also used : BlockHeader(org.ethereum.core.BlockHeader) Test(org.junit.Test)

Example 65 with BlockHeader

use of org.ethereum.core.BlockHeader in project rskj by rsksmart.

the class FamilyUtils method getUsedUncles.

public static Set<Keccak256> getUsedUncles(BlockStore blockStore, long blockNumber, byte[] parentHash, int limitNum) {
    Set<Keccak256> ret = new HashSet<>();
    if (blockStore == null) {
        return ret;
    }
    long minNumber = max(0, blockNumber - limitNum);
    Block it = blockStore.getBlockByHash(parentHash);
    while (it != null && it.getNumber() >= minNumber) {
        for (BlockHeader uncle : it.getUncleList()) {
            ret.add(uncle.getHash());
        }
        it = blockStore.getBlockByHash(it.getParentHash().getBytes());
    }
    return ret;
}
Also used : Block(org.ethereum.core.Block) Keccak256(co.rsk.crypto.Keccak256) BlockHeader(org.ethereum.core.BlockHeader) HashSet(java.util.HashSet)

Aggregations

BlockHeader (org.ethereum.core.BlockHeader)65 Test (org.junit.Test)36 Block (org.ethereum.core.Block)27 ArrayList (java.util.ArrayList)13 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)9 BlockDifficulty (co.rsk.core.BlockDifficulty)5 Keccak256 (co.rsk.crypto.Keccak256)5 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)4 BlockBuilder (co.rsk.test.builders.BlockBuilder)4 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)4 BlockStore (org.ethereum.db.BlockStore)4 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)3 BigInteger (java.math.BigInteger)3 MainNetConfig (org.ethereum.config.net.MainNetConfig)3 DataWord (org.ethereum.vm.DataWord)3 DifficultyCalculator (co.rsk.core.DifficultyCalculator)2 BlockChainImplTest (co.rsk.core.bc.BlockChainImplTest)2 HashSet (java.util.HashSet)2 Bloom (org.ethereum.core.Bloom)2 Transaction (org.ethereum.core.Transaction)2