<commit_before>import os
import sys
import copy

from ethereum import utils, abi, genesis_helpers, config
from ethereum.hybrid_casper.casper_initiating_transactions import mk_initializers, purity_checker_address, purity_checker_abi
from ethereum.hybrid_casper import consensus
from ethereum.hybrid_casper.config import config
from ethereum.messages import apply_transaction
from ethereum.tools.tester import a0
from viper import compiler, optimizer, compile_lll
from viper.parser.parser_utils import LLLnode
import rlp

ethereum_path = os.path.dirname(sys.modules['ethereum'].__file__)
casper_contract_path = '/'.join((ethereum_path, '..', 'casper', 'casper', 'contracts', 'simple_casper.v.py'))
casper_code = open(casper_contract_path).read()
casper_bytecode = compiler.compile(casper_code)
casper_abi = compiler.mk_full_signature(casper_code)
casper_translator = abi.ContractTranslator(casper_abi)
purity_translator = abi.ContractTranslator(purity_checker_abi)

# Get a genesis state which is primed for Casper
def make_casper_genesis(alloc, epoch_length, withdrawal_delay, base_interest_factor, base_penalty_factor):
    # The Casper-specific dynamic config declaration
    config.casper_config['EPOCH_LENGTH'] = epoch_length
    config.casper_config['WITHDRAWAL_DELAY'] = withdrawal_delay
    config.casper_config['OWNER'] = a0
    config.casper_config['BASE_INTEREST_FACTOR'] = base_interest_factor
    config.casper_config['BASE_PENALTY_FACTOR'] = base_penalty_factor
    # Get initialization txs
    init_txs, casper_address = mk_initializers(config.casper_config, config.casper_config['NULL_SENDER'])
    config.casper_config['CASPER_ADDRESS'] = casper_address
    # Create state and apply required state_transitions for initializing Casper
    state = genesis_helpers.mk_basic_state(alloc, None, env=config.Env(config=config.casper_config))
    state.gas_limit = 10**8
    for tx in init_txs:
        state.set_balance(utils.privtoaddr(config.casper_config['NULL_SENDER']), 15**18)
        success, output = apply_transaction(state, tx)
        assert success
        state.gas_used = 0
        state.set_balance(utils.privtoaddr(config.casper_config['NULL_SENDER']), 0)
    consensus.initialize(state)
    state.commit()
    return state


def mk_validation_code(address):<commit_msg>Add genesis declaration to make_casper_state<commit_after>import os
import sys
import copy

from ethereum import utils, abi, genesis_helpers, config
from ethereum.hybrid_casper.casper_initiating_transactions import mk_initializers, purity_checker_address, purity_checker_abi
from ethereum.hybrid_casper import consensus
from ethereum.hybrid_casper.config import config
from ethereum.messages import apply_transaction
from ethereum.tools.tester import a0
from viper import compiler, optimizer, compile_lll
from viper.parser.parser_utils import LLLnode
import rlp

ethereum_path = os.path.dirname(sys.modules['ethereum'].__file__)
casper_contract_path = '/'.join((ethereum_path, '..', 'casper', 'casper', 'contracts', 'simple_casper.v.py'))
casper_code = open(casper_contract_path).read()
casper_bytecode = compiler.compile(casper_code)
casper_abi = compiler.mk_full_signature(casper_code)
casper_translator = abi.ContractTranslator(casper_abi)
purity_translator = abi.ContractTranslator(purity_checker_abi)

# Get a genesis state which is primed for Casper
def make_casper_genesis(alloc, epoch_length, withdrawal_delay, base_interest_factor, base_penalty_factor, genesis_declaration=None):
    # The Casper-specific dynamic config declaration
    config.casper_config['EPOCH_LENGTH'] = epoch_length
    config.casper_config['WITHDRAWAL_DELAY'] = withdrawal_delay
    config.casper_config['OWNER'] = a0
    config.casper_config['BASE_INTEREST_FACTOR'] = base_interest_factor
    config.casper_config['BASE_PENALTY_FACTOR'] = base_penalty_factor
    # Get initialization txs
    init_txs, casper_address = mk_initializers(config.casper_config, config.casper_config['NULL_SENDER'])
    config.casper_config['CASPER_ADDRESS'] = casper_address
    # Create state and apply required state_transitions for initializing Casper
    if genesis_declaration is None:
        state = genesis_helpers.mk_basic_state(alloc, None, env=config.Env(config=config.casper_config))
    else:
        state = genesis_helpers.state_from_genesis_declaration(genesis_declaration, config.Env(config=config.casper_config))
    state.gas_limit = 10**8
    for tx in init_txs:
        state.set_balance(utils.privtoaddr(config.casper_config['NULL_SENDER']), 15**18)
        success, output = apply_transaction(state, tx)
        assert success
        state.gas_used = 0
        state.set_balance(utils.privtoaddr(config.casper_config['NULL_SENDER']), 0)
    consensus.initialize(state)
    state.commit()
    return state


def mk_validation_code(address):
{'fraction_non_alphanumeric': 0.08547717842323652, 'fraction_numerical': 0.004564315352697096, 'mean_word_length': 6.131656804733728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7305242', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1542, 'n_words': 294}