repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
FATE
FATE-master/python/federatedml/framework/hetero/sync/paillier_keygen_sync.py
# Copyright 2019 The FATE Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
2,185
34.258065
91
py
FATE
FATE-master/python/federatedml/framework/hetero/sync/gradient_sync.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2019 The FATE Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
1,599
33.042553
75
py
FATE
FATE-master/python/federatedml/framework/hetero/sync/__init__.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2019 The FATE Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
661
35.777778
75
py
FATE
FATE-master/python/federatedml/framework/hetero/sync/loss_sync.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2019 The FATE Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
2,388
38.816667
110
py
FATE
FATE-master/rust/fate_crypto/fate_crypto/__init__.py
from .fate_crypto import hash, psi __all__ = ["hash", "psi"]
62
14.75
34
py
FATE
FATE-master/rust/fate_crypto/fate_crypto/hash/__init__.py
0
0
0
py
FATE
FATE-master/rust/fate_crypto/fate_crypto/psi/__init__.py
0
0
0
py
FATE
FATE-master/rust/fate_crypto/scripts/bump_version.py
import toml import pathlib import argparse root_path = pathlib.Path(__file__).parent.parent.resolve() def update_version(version): with open(root_path.joinpath("Cargo.toml")) as f: cargo = toml.load(f) old_version = cargo["package"]["version"] print(f"bump fate_crypto version from `{old_version}`...
655
27.521739
74
py
FATE
FATE-master/rust/fate_crypto/tests/test_psi_bench.py
import random import hashlib from fate_crypto.psi import Curve25519 def ecdh(k, m): return k.encrypt(m) def dh(k, e): return k.diffie_hellman(e) def sha256(value): return hashlib.sha256(bytes(value, encoding="utf-8")).digest() def test_ecdh_encrypt_bench(benchmark): k = Curve25519() m = rand...
686
19.205882
69
py
FATE
FATE-master/rust/fate_crypto/tests/test_psi_ecdh.py
from fate_crypto.psi import Curve25519 import pickle import unittest import random class TestStringMethods(unittest.TestCase): def test_ecdh(self): k1 = Curve25519() k2 = Curve25519() m = random.SystemRandom().getrandbits(33 * 8).to_bytes(33, "little") self.assertEqual( ...
703
26.076923
78
py
FATE
FATE-master/rust/fate_crypto/tests/test_sm3_hash.py
import unittest from fate_crypto.hash import sm3_hash class TestCorrect(unittest.TestCase): def test_hash_1(self): data = b"abc" expected = "66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0" self.assertEqual(sm3_hash(data).hex(), expected) def test_hash_2(self): ...
589
30.052632
85
py
FATE
FATE-master/doc/__init__.py
0
0
0
py
FATE
FATE-master/doc/mkdocs/hook.py
import os import re import glob import git _INCLUDE_EXAMPLES_REGEX = re.compile( r"""(?P<_includer_indent>[^\S\r\n]*){\s*%\s*include-examples\s*"(?P<example_name>[^")]+)"\s*%\s*}\s*""", flags=re.VERBOSE | re.DOTALL, ) _INCLUDE_EXAMPLE_REGEX = re.compile( r"""(?P<_includer_indent>[^\S\r\n]*){\s*%\s*include...
5,721
31.146067
108
py
FATE
FATE-master/doc/mkdocs/gen_params_doc.py
"""Generate parms pages.""" import os import mkdocs_gen_files repo_base = os.path.abspath( os.path.join( os.path.abspath(__file__), os.path.pardir, os.path.pardir, os.path.pardir ) ) params_source = os.path.join(repo_base, "python", "federatedml", "param") params_doc_target = os.path.join(repo_base, "d...
1,105
32.515152
97
py
CRL
CRL-main/run_continual.py
import torch from config import Param from methods.utils import setup_seed from methods.manager import Manager def run(args): setup_seed(args.seed) print("hyper-parameter configurations:") print(str(args.__dict__)) manager = Manager(args) manager.train(args) if __name__ == '__main__': par...
653
24.153846
72
py
CRL
CRL-main/config.py
import argparse import os """ Detailed hyper-parameter configurations. """ class Param: def __init__(self): parser = argparse.ArgumentParser() parser = self.all_param(parser) all_args, unknown = parser.parse_known_args() self.args = all_args def all_param(self, parser): ...
2,647
32.518987
108
py
CRL
CRL-main/methods/utils.py
from dataloaders.data_loader import get_data_loader import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from tqdm import tqdm, trange import random class Moment: def __init__(self, args) -> None: self.labels = None self.mem_labels = None self.memle...
5,091
38.78125
119
py
CRL
CRL-main/methods/model.py
import torch.nn as nn import torch import torch.nn.functional as F from .backbone import Bert_Encoder class Encoder(nn.Module): def __init__(self, args): super().__init__() self.encoder = Bert_Encoder(args) self.output_size = self.encoder.out_dim dim_in = self.output_size s...
644
27.043478
48
py
CRL
CRL-main/methods/backbone.py
import torch.nn as nn import torch import numpy as np from transformers import BertModel, BertConfig class Bert_Encoder(nn.Module): def __init__(self, config, out_token=False): super(Bert_Encoder, self).__init__() # load model self.encoder = BertModel.from_pretrained(config.bert_path).cud...
3,220
42.527027
115
py
CRL
CRL-main/methods/manager.py
from dataloaders.sampler import data_sampler from dataloaders.data_loader import get_data_loader from .model import Encoder from .utils import Moment, dot_dist import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np import random from tqdm import tqdm, trange fr...
14,339
42.98773
139
py
CRL
CRL-main/dataloaders/sampler.py
import pickle import random import json, os from transformers import BertTokenizer import numpy as np def get_tokenizer(args): tokenizer = BertTokenizer.from_pretrained(args.bert_path, additional_special_tokens=["[E11]", "[E12]", "[E21]", "[E22]"]) return tokenizer class data_sampler(object): def __init_...
6,542
41.764706
127
py
CRL
CRL-main/dataloaders/data_loader.py
import torch from torch.utils.data import Dataset, DataLoader class data_set(Dataset): def __init__(self, data,config=None): self.data = data self.config = config self.bert = True def __len__(self): return len(self.data) def __getitem__(self, idx): return (self.da...
1,180
24.673913
89
py
consensus-specs
consensus-specs-master/setup.py
from setuptools import setup, find_packages, Command from setuptools.command.build_py import build_py from distutils import dir_util from distutils.util import convert_path from pathlib import Path import os import re import string import textwrap from typing import Dict, NamedTuple, List, Sequence, Optional, TypeVar, ...
47,658
35.887771
192
py
consensus-specs
consensus-specs-master/scripts/gen_kzg_trusted_setups.py
import os from pathlib import Path from eth2spec.utils.kzg import ( dump_kzg_trusted_setup_files, ) if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument( "--secret", dest="secret", type=int, required=True, help='the...
972
21.113636
94
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/__init__.py
# See setup.py about usage of VERSION.txt import os with open(os.path.join(os.path.dirname(__file__), 'VERSION.txt')) as f: __version__ = f.read().strip()
159
31
71
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/debug/decode.py
from typing import Any from eth2spec.utils.ssz.ssz_impl import hash_tree_root from eth2spec.utils.ssz.ssz_typing import ( uint, Container, List, boolean, Vector, ByteVector, ByteList, Union, View ) def decode(data: Any, typ): if issubclass(typ, (uint, boolean)): return typ(data) elif issubclas...
1,620
36.697674
74
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/debug/random_value.py
from random import Random from enum import Enum from typing import Type from eth2spec.utils.ssz.ssz_typing import ( View, BasicView, uint, Container, List, boolean, Vector, ByteVector, ByteList, Bitlist, Bitvector, Union ) # in bytes UINT_BYTE_SIZES = (1, 2, 4, 8, 16, 32) random_mode_names = ("random", "zer...
6,311
36.129412
104
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/debug/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/debug/encode.py
from eth2spec.utils.ssz.ssz_impl import hash_tree_root, serialize from eth2spec.utils.ssz.ssz_typing import ( uint, boolean, Bitlist, Bitvector, Container, Vector, List, Union ) def encode(value, include_hash_tree_roots=False): if isinstance(value, uint): # Larger uints are boxed and the class dec...
1,803
41.952381
98
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/config/config_util.py
from pathlib import Path from typing import Dict, Iterable, Union, BinaryIO, TextIO, Any from ruamel.yaml import YAML def parse_config_vars(conf: Dict[str, Any]) -> Dict[str, Any]: """ Parses a dict of basic str/int/list types into more detailed python types """ out: Dict[str, Any] = dict() for k,...
2,176
33.015625
96
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/config/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/gen_helpers/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/gen_helpers/gen_base/settings.py
import multiprocessing # Generator mode setting MODE_SINGLE_PROCESS = 'MODE_SINGLE_PROCESS' MODE_MULTIPROCESSING = 'MODE_MULTIPROCESSING' # Test generator mode GENERATOR_MODE = MODE_SINGLE_PROCESS # Number of subprocesses when using MODE_MULTIPROCESSING NUM_PROCESS = multiprocessing.cpu_count() // 2 - 1 # Diagnostic...
363
25
56
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py
from dataclasses import ( dataclass, field, ) import os import time import shutil import argparse from pathlib import Path import sys import json from typing import Iterable, AnyStr, Any, Callable import traceback from collections import namedtuple from ruamel.yaml import ( YAML, ) from filelock import Fi...
13,418
31.970516
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/gen_helpers/gen_base/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_typing.py
from typing import ( Any, Callable, Iterable, NewType, Tuple, ) from dataclasses import dataclass # Elements: name, out_kind, data # # out_kind is the type of data: # - "meta" for generic data to collect into a meta data dict # - "cfg" for a spec config dictionary # - "data" for generic # - "ss...
891
23.108108
92
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/gen_helpers/gen_from_tests/gen.py
from importlib import import_module from inspect import getmembers, isfunction from typing import Any, Callable, Dict, Iterable, Optional, List, Union from eth2spec.utils import bls from eth2spec.test.helpers.constants import ALL_PRESETS, TESTGEN_FORKS from eth2spec.test.helpers.typing import SpecForkName, PresetBaseN...
5,408
39.669173
113
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/gen_helpers/gen_from_tests/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/context.py
import pytest from copy import deepcopy from dataclasses import dataclass import importlib from eth2spec.phase0 import mainnet as spec_phase0_mainnet, minimal as spec_phase0_minimal from eth2spec.altair import mainnet as spec_altair_mainnet, minimal as spec_altair_minimal from eth2spec.bellatrix import mainnet as spec...
25,667
33.224
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/exceptions.py
class SkippedTest(Exception): ... class BlockNotFoundException(Exception): ...
89
11.857143
40
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/conftest.py
from eth2spec.test import context from eth2spec.test.helpers.constants import ( ALL_PHASES, ) from eth2spec.utils import bls as bls_utils # We import pytest only when it's present, i.e. when we are running tests. # The test-cases themselves can be generated without installing pytest. def module_exists(module_nam...
2,887
27.88
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/eip6110/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/eip6110/block_processing/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/eip6110/block_processing/test_process_deposit_receipt.py
from eth2spec.test.context import spec_state_test, always_bls, with_eip6110_and_later from eth2spec.test.helpers.deposits import ( prepare_deposit_receipt, run_deposit_receipt_processing, run_deposit_receipt_processing_with_specific_fork_version ) from eth2spec.test.helpers.state import next_epoch_via_block...
10,954
37.710247
115
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/eip6110/sanity/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/eip6110/sanity/blocks/__init__.py
from .test_deposit_transition import * # noqa: F401 F403
58
28.5
57
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/eip6110/sanity/blocks/test_deposit_transition.py
from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) from eth2spec.test.context import ( spec_state_test, with_phases, EIP6110, ) from eth2spec.test.helpers.deposits import ( build_deposit_data, deposit_from_context, prepare_deposit_receipt, ) from eth2spec.test.helpe...
10,366
44.073913
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/shard_block.py
from eth2spec.test.helpers.block import get_state_and_beacon_parent_root_at_slot from eth2spec.test.helpers.keys import privkeys from eth2spec.utils import bls from eth2spec.utils.bls import only_with_bls @only_with_bls() def sign_shard_block(spec, beacon_state, shard, block, proposer_index=None): slot = block.me...
3,443
37.696629
108
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/attestations.py
from lru import LRU from typing import List from eth2spec.test.context import expect_assertion_error from eth2spec.test.helpers.state import state_transition_and_sign_block, next_epoch, next_slot from eth2spec.test.helpers.block import build_empty_block_for_next_slot from eth2spec.test.helpers.forks import is_post_al...
15,116
37.465649
120
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/constants.py
from .typing import SpecForkName, PresetBaseName # # SpecForkName # # Some of the Spec module functionality is exposed here to deal with phase-specific changes. PHASE0 = SpecForkName('phase0') ALTAIR = SpecForkName('altair') BELLATRIX = SpecForkName('bellatrix') CAPELLA = SpecForkName('capella') DENEB = SpecForkName...
2,012
26.958333
100
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/block_processing.py
def for_ops(state, operations, fn) -> None: for operation in operations: fn(state, operation) def get_process_calls(spec): return { # PHASE0 'process_block_header': lambda state, block: spec.process_block_header(state, block), 'process_randao': lambda st...
2,922
46.145161
113
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/keys.py
from py_ecc.bls import G2ProofOfPossession as bls # Enough keys for 256 validators per slot in worst-case epoch length privkeys = [i + 1 for i in range(32 * 256)] pubkeys = [bls.SkToPk(privkey) for privkey in privkeys] pubkey_to_privkey = {pubkey: privkey for privkey, pubkey in zip(privkeys, pubkeys)}
304
42.571429
83
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/withdrawals.py
import random def set_validator_fully_withdrawable(spec, state, index, withdrawable_epoch=None): if withdrawable_epoch is None: withdrawable_epoch = spec.get_current_epoch(state) validator = state.validators[index] validator.withdrawable_epoch = withdrawable_epoch # set exit epoch as well to ...
2,483
46.769231
117
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/block_header.py
from eth2spec.utils import bls def sign_block_header(spec, state, header, privkey): domain = spec.get_domain( state=state, domain_type=spec.DOMAIN_BEACON_PROPOSER, ) signing_root = spec.compute_signing_root(header, domain) signature = bls.Sign(privkey, signing_root) return spec.Sig...
378
30.583333
76
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/voluntary_exits.py
from random import Random from eth2spec.utils import bls from eth2spec.test.context import expect_assertion_error from eth2spec.test.helpers.forks import is_post_deneb from eth2spec.test.helpers.keys import privkeys def prepare_signed_exits(spec, state, indices, fork_version=None): def create_signed_exit(index): ...
3,028
30.884211
113
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/deposits.py
from random import Random from eth2spec.test.context import expect_assertion_error from eth2spec.test.helpers.forks import is_post_altair from eth2spec.test.helpers.keys import pubkeys, privkeys from eth2spec.test.helpers.state import get_balance from eth2spec.utils import bls from eth2spec.utils.merkle_minimal import...
14,700
36.407125
118
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/genesis.py
from eth2spec.test.helpers.constants import ( ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110, ) from eth2spec.test.helpers.execution_payload import ( compute_el_header_block_hash, ) from eth2spec.test.helpers.forks import ( is_post_altair, is_post_bellatrix, is_post_capella, is_post_eip6110, ) from eth2spec.tes...
5,759
39.56338
118
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/attester_slashings.py
from eth2spec.test.helpers.attestations import get_valid_attestation, sign_attestation, sign_indexed_attestation def get_valid_attester_slashing(spec, state, slot=None, signed_1=False, signed_2=False, filter_participant_set=None): attestation_1 = get_valid_attestation( spec, state, slot=slot, sign...
2,235
33.4
117
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/state.py
from eth2spec.test.context import expect_assertion_error from eth2spec.test.helpers.block import apply_empty_block, sign_block, transition_unsigned_block from eth2spec.test.helpers.forks import is_post_altair from eth2spec.test.helpers.voluntary_exits import get_unslashed_exited_validators def get_balance(state, inde...
5,444
31.218935
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/rewards.py
from random import Random from lru import LRU from eth2spec.phase0.mainnet import VALIDATOR_REGISTRY_LIMIT # equal everywhere, fine to import from eth2spec.test.helpers.forks import is_post_altair, is_post_bellatrix from eth2spec.test.helpers.state import ( next_epoch, ) from eth2spec.test.helpers.random import (...
19,779
36.965451
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/block.py
from eth2spec.test.helpers.execution_payload import build_empty_execution_payload from eth2spec.test.helpers.forks import is_post_altair, is_post_bellatrix from eth2spec.test.helpers.keys import privkeys from eth2spec.utils import bls from eth2spec.utils.bls import only_with_bls from eth2spec.utils.ssz.ssz_impl import ...
5,113
40.241935
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/merkle.py
from remerkleable.tree import gindex_bit_iter def build_proof(anchor, leaf_index): if leaf_index <= 1: return [] # Nothing to prove / invalid index node = anchor proof = [] # Walk down, top to bottom to the leaf bit_iter, _ = gindex_bit_iter(leaf_index) for bit in bit_iter: # ...
656
28.863636
56
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py
from eth_utils import encode_hex from eth2spec.test.exceptions import BlockNotFoundException from eth2spec.test.helpers.attestations import ( next_epoch_with_attestations, next_slots_with_attestations, state_transition_with_full_block, ) def get_anchor_root(spec, state): anchor_block_header = state.la...
11,578
34.959627
105
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py
from collections import Counter from eth2spec.test.context import ( expect_assertion_error, ) from eth2spec.test.helpers.keys import privkeys from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) from eth2spec.test.helpers.block_processing import run_block_processing_to from eth2spec.uti...
6,629
39.426829
117
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/typing.py
from typing import NewType SpecForkName = NewType("SpecForkName", str) PresetBaseName = NewType("PresetBaseName", str)
120
23.2
47
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py
from eth_hash.auto import keccak from trie import HexaryTrie from rlp import encode from rlp.sedes import big_endian_int, Binary, List from eth2spec.debug.random_value import get_random_bytes_list from eth2spec.test.helpers.forks import ( is_post_capella, is_post_deneb, is_post_eip6110, ) def get_executi...
10,290
37.543071
118
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/bls_to_execution_changes.py
from eth2spec.utils import bls from eth2spec.test.helpers.keys import pubkeys, privkeys, pubkey_to_privkey def get_signed_address_change(spec, state, validator_index=None, withdrawal_pubkey=None, to_execution_address=None, ...
1,502
33.159091
75
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/epoch_processing.py
from eth2spec.test.helpers.forks import ( is_post_altair, is_post_capella, ) def get_process_calls(spec): # unrecognized processing functions will be ignored. # This sums up the aggregate of processing functions of all phases. # Note: make sure to explicitly remove/override a processing function ...
3,000
39.013333
111
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py
from random import Random from eth2spec.test.helpers.keys import privkeys, pubkeys from eth2spec.test.helpers.state import ( state_transition_and_sign_block, ) from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) from eth2spec.test.helpers.sync_committee import ( compute_committee_i...
9,715
36.369231
116
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/sharding.py
import random from eth2spec.utils.ssz.ssz_typing import ( Container, Bytes20, Bytes32, ByteList, List, Union, boolean, uint256, uint64, ) from eth2spec.utils.ssz.ssz_impl import serialize # # Containers from EIP-4844 # MAX_CALLDATA_SIZE = 2**24 MAX_VERSIONED_HASHES_LIST_SIZE = 2**24 MAX_AC...
3,487
26.904
90
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/forks.py
from .constants import ( PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110, ) def is_post_fork(a, b): if a == EIP6110: return b in [PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110] if a == DENEB: return b in [PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB] if a == CAPELLA: r...
957
22.365854
72
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py
from enum import Enum, auto from eth2spec.test.helpers.attester_slashings import ( get_valid_attester_slashing_by_indices, ) from eth2spec.test.helpers.attestations import next_slots_with_attestations from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, build_empty_block, sign_blo...
14,768
37.460938
115
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/random.py
from random import Random from eth2spec.test.helpers.attestations import cached_prepare_state_with_attestations from eth2spec.test.helpers.deposits import mock_deposit from eth2spec.test.helpers.forks import is_post_altair from eth2spec.test.helpers.state import next_epoch def set_some_activations(spec, state, rng, ...
9,007
43.81592
120
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/optimistic_sync.py
from dataclasses import dataclass from enum import Enum from typing import ( Dict, Optional, ) from eth_utils import encode_hex from eth2spec.utils.ssz.ssz_typing import Bytes32 from eth2spec.test.helpers.fork_choice import ( add_block, ) class PayloadStatusV1StatusAlias(Enum): NOT_VALIDATED = "NOT_...
6,833
32.336585
116
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/custody.py
from eth2spec.test.helpers.keys import privkeys from eth2spec.test.helpers.merkle import build_proof from eth2spec.utils import bls from eth2spec.utils.ssz.ssz_typing import Bitlist, ByteVector, ByteList BYTES_PER_CHUNK = 32 def get_valid_early_derived_secret_reveal(spec, state, epoch=None): current_epoch = spec...
7,099
38.88764
115
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/pow_block.py
from random import Random from eth2spec.utils.ssz.ssz_typing import uint256 class PowChain: blocks = [] def __init__(self, blocks): self.blocks = blocks def __iter__(self): return iter(self.blocks) def head(self, offset=0): assert offset <= 0 return self.blocks[offse...
1,082
26.075
93
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/inactivity_scores.py
from random import Random def randomize_inactivity_scores(spec, state, minimum=0, maximum=50000, rng=Random(4242)): state.inactivity_scores = [rng.randint(minimum, maximum) for _ in range(len(state.validators))] def zero_inactivity_scores(spec, state, rng=None): state.inactivity_scores = [0] * len(state.val...
329
32
99
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/light_client.py
from eth2spec.test.helpers.state import ( transition_to, ) from eth2spec.test.helpers.sync_committee import ( compute_aggregate_sync_committee_signature, compute_committee_indices, ) from math import floor def get_sync_aggregate(spec, state, num_participants=None, signature_slot=None): # By default, t...
2,457
33.619718
99
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/proposer_slashings.py
from eth2spec.test.helpers.block_header import sign_block_header from eth2spec.test.helpers.forks import is_post_altair, is_post_bellatrix from eth2spec.test.helpers.keys import pubkey_to_privkey from eth2spec.test.helpers.state import get_balance from eth2spec.test.helpers.sync_committee import ( compute_committee...
4,413
39.495413
117
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/bellatrix/fork.py
BELLATRIX_FORK_TEST_META_TAGS = { 'fork': 'bellatrix', } def run_fork_test(post_spec, pre_state): yield 'pre', pre_state post_state = post_spec.upgrade_to_bellatrix(pre_state) # Stable fields stable_fields = [ 'genesis_time', 'genesis_validators_root', 'slot', # History '...
1,593
32.914894
118
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/bellatrix/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/altair/fork.py
ALTAIR_FORK_TEST_META_TAGS = { 'fork': 'altair', } def run_fork_test(post_spec, pre_state): # Clean up state to be more realistic pre_state.current_epoch_attestations = [] yield 'pre', pre_state post_state = post_spec.upgrade_to_altair(pre_state) # Stable fields stable_fields = [ ...
1,362
30.697674
118
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/altair/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/deneb/fork.py
from eth2spec.test.helpers.constants import ( DENEB, ) DENEB_FORK_TEST_META_TAGS = { 'fork': DENEB, } def run_fork_test(post_spec, pre_state): yield 'pre', pre_state post_state = post_spec.upgrade_to_deneb(pre_state) # Stable fields stable_fields = [ 'genesis_time', 'genesis_valida...
2,208
33.515625
118
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/deneb/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/capella/fork.py
CAPELLA_FORK_TEST_META_TAGS = { 'fork': 'capella', } def run_fork_test(post_spec, pre_state): yield 'pre', pre_state post_state = post_spec.upgrade_to_capella(pre_state) # Stable fields stable_fields = [ 'genesis_time', 'genesis_validators_root', 'slot', # History 'latest...
2,067
35.280702
118
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/helpers/capella/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/random/test_random.py
""" This module is generated from the ``random`` test generator. Please do not edit this file manually. See the README for that generator for more information. """ from eth2spec.test.helpers.constants import BELLATRIX from eth2spec.test.context import ( misc_balances_in_default_range_with_many_validators, with...
28,480
63.876993
945
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/random/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_deposit.py
from eth2spec.test.context import ( spec_state_test, always_bls, with_bellatrix_and_later, ) from eth2spec.test.helpers.deposits import ( run_deposit_processing_with_specific_fork_version, ) @with_bellatrix_and_later @spec_state_test @always_bls def test_ineffective_deposit_with_previous_fork_version(...
1,185
29.410256
108
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_voluntary_exit.py
from eth2spec.test.context import ( spec_state_test, always_bls, with_bellatrix_and_later, with_phases, ) from eth2spec.test.helpers.constants import ( BELLATRIX, CAPELLA, ) from eth2spec.test.helpers.keys import pubkey_to_privkey from eth2spec.test.helpers.state import ( next_epoch, ) from ...
3,940
27.352518
108
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/test_process_execution_payload.py
from random import Random from eth2spec.test.helpers.execution_payload import ( build_empty_execution_payload, build_randomized_execution_payload, compute_el_block_hash, get_execution_payload_header, build_state_with_incomplete_transition, build_state_with_complete_transition, ) from eth2spec.t...
12,744
34.013736
119
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/block_processing/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_on_merge_block.py
from eth2spec.utils.ssz.ssz_typing import uint256 from eth2spec.test.exceptions import BlockNotFoundException from eth2spec.test.context import spec_state_test, with_phases, BELLATRIX from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot, ) from eth2spec.test.helpers.execution_payload import ( ...
7,491
39.939891
107
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/__init__.py
0
0
0
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/sanity/test_blocks.py
from random import Random from eth2spec.test.helpers.state import ( state_transition_and_sign_block, next_slot, ) from eth2spec.test.helpers.block import ( build_empty_block_for_next_slot ) from eth2spec.test.helpers.execution_payload import ( build_randomized_execution_payload ) from eth2spec.test.cont...
1,895
27.298507
111
py
consensus-specs
consensus-specs-master/tests/core/pyspec/eth2spec/test/bellatrix/sanity/__init__.py
0
0
0
py