@Override public Constants getCommonConstants() { // TODO make a guard wrapper which throws exception if the requested constant differs among configs return configs[0].getConstants(); }
public Eip160HFConfig(BlockchainConfig parent) { super(parent); constants = new ConstantsAdapter(parent.getConstants()) { @Override public int getMAX_CONTRACT_SZIE() { return 0x6000; } }; }
@Override public Constants getConstants() { return parent.getConstants(); }
public boolean isContractExist(BlockchainConfig blockchainConfig) { return !FastByteComparisons.equal(codeHash, EMPTY_DATA_HASH) || !blockchainConfig.getConstants().getInitialNonce().equals(nonce); }
protected void initDaoConfig(BlockchainConfig parent, long forkBlockNumber) { this.parent = parent; this.constants = parent.getConstants(); this.forkBlockNumber = forkBlockNumber; BlockHeaderRule rule = new ExtraDataPresenceRule(DAO_EXTRA_DATA, supportFork); headerValidators().add(Pair.of(forkBlockNumber, new BlockHeaderValidator(rule))); }
BigInteger blockReward = config.getBlockchainConfig().getConfigForBlock(block.getNumber()).getConstants().getBLOCK_REWARD(); BigInteger inclusionReward = blockReward.divide(BigInteger.valueOf(32));
if (m_endGas.compareTo(BigInteger.valueOf(returnDataGasValue)) < 0) { if (!blockchainConfig.getConstants().createEmptyContractOnOOG()) { program.setRuntimeFailure(Program.Exception.notEnoughSpendingGas("No gas to return just created contract", returnDataGasValue, program)); } else if (getLength(result.getHReturn()) > blockchainConfig.getConstants().getMAX_CONTRACT_SZIE()) {
@Test public void testConstantinopleBlock() { final int byzStart = 50; final int cnstStart = 60; GenesisConfig genesisConfig = new GenesisConfig(); genesisConfig.constantinopleBlock = cnstStart; JsonNetConfig config = new JsonNetConfig(genesisConfig); assertBlockchainConfigExistsAt(config, cnstStart, ConstantinopleConfig.class); BlockchainConfig blockchainConfig = config.getConfigForBlock(cnstStart); assertEquals("Default chainId must be '1'", new Integer(1), blockchainConfig.getChainId()); assertEquals("Reward should be 2 ETH", EtherUtil.convert(2, EtherUtil.Unit.ETHER), blockchainConfig.getConstants().getBLOCK_REWARD()); assertTrue("EIP-1014 skinny CREATE2 should be activated among others", blockchainConfig.eip1014()); genesisConfig.chainId = 99; config = new JsonNetConfig(genesisConfig); blockchainConfig = config.getConfigForBlock(cnstStart); assertEquals("chainId should be copied from genesis config", new Integer(99), blockchainConfig.getChainId()); assertEquals("Default Frontier reward is 5 ETH", EtherUtil.convert(5, EtherUtil.Unit.ETHER), config.getConfigForBlock(byzStart).getConstants().getBLOCK_REWARD()); genesisConfig.byzantiumBlock = byzStart; config = new JsonNetConfig(genesisConfig); // Respawn so we have Byzantium on byzStart instead of Frontier assertEquals("Reward should be 3 ETH in Byzantium", EtherUtil.convert(3, EtherUtil.Unit.ETHER), config.getConfigForBlock(byzStart).getConstants().getBLOCK_REWARD()); assertEquals("Reward should be changed to 2 ETH in Constantinople", EtherUtil.convert(2, EtherUtil.Unit.ETHER), config.getConfigForBlock(cnstStart).getConstants().getBLOCK_REWARD()); }
long afterSpend = programInvoke.getGas().longValue() - storageCost - result.getGasUsed(); if (afterSpend < 0) { if (!blockchainConfig.getConstants().createEmptyContractOnOOG()) { result.setException(Program.Exception.notEnoughSpendingGas("No gas to return just created contract", storageCost, this)); track.saveCode(newAddress, EMPTY_BYTE_ARRAY); } else if (getLength(code) > blockchainConfig.getConstants().getMAX_CONTRACT_SZIE()) { result.setException(Program.Exception.notEnoughSpendingGas("Contract size too large: " + getLength(result.getHReturn()), storageCost, this));