# Path: rlp/sedes/big_endian_int.py
# class BigEndianInt(object):
#     def __init__(self, l=None):
#     def serialize(self, obj):
#     def deserialize(self, serial):
# 
# Path: rlp/sedes/binary.py
# class Binary(object):
#     def __init__(self, min_length=None, max_length=None, allow_empty=False):
#     def fixed_length(cls, l, allow_empty=False):
#     def is_valid_type(cls, obj):
#     def is_valid_length(self, l):
#     def serialize(self, obj):
#     def deserialize(self, serial):
# 
# Path: rlp/sedes/lists.py
# class CountableList(object):
# 
#     """A sedes for lists of arbitrary length.
# 
#     :param element_sedes: when (de-)serializing a list, this sedes will be
#                           applied to all of its elements
#     :param max_length: maximum number of allowed elements, or `None` for no limit
#     """
# 
#     def __init__(self, element_sedes, max_length=None):
#         self.element_sedes = element_sedes
#         self.max_length = max_length
# 
#     @to_list
#     def serialize(self, obj):
#         if not is_sequence(obj):
#             raise ListSerializationError('Can only serialize sequences', obj)
# 
#         if self.max_length is not None and len(obj) > self.max_length:
#             raise ListSerializationError(
#                 'Too many elements ({}, allowed {})'.format(
#                     len(obj),
#                     self.max_length,
#                 ),
#                 obj=obj,
#             )
# 
#         for index, element in enumerate(obj):
#             try:
#                 yield self.element_sedes.serialize(element)
#             except SerializationError as e:
#                 raise ListSerializationError(obj=obj, element_exception=e, index=index)
# 
#     @to_tuple
#     def deserialize(self, serial):
#         if not is_sequence(serial):
#             raise ListDeserializationError('Can only deserialize sequences', serial=serial)
#         for index, element in enumerate(serial):
#             if self.max_length is not None and index >= self.max_length:
#                 raise ListDeserializationError(
#                     'Too many elements (more than {})'.format(self.max_length),
#                     serial=serial,
#                 )
# 
#             try:
#                 yield self.element_sedes.deserialize(element)
#             except DeserializationError as e:
#                 raise ListDeserializationError(serial=serial, element_exception=e, index=index)
# 
# Path: rlp/sedes/serializable.py
# class Serializable(BaseSerializable, metaclass=SerializableBase):
#     """
#     The base class for serializable objects.
#     """
#     pass


import random
import rlp
import time
from rlp.sedes import big_endian_int, BigEndianInt, Binary, binary, CountableList
from rlp.sedes.serializable import Serializable
"""
util to benchmark known usecase
"""

address = Binary.fixed_length(20, allow_empty=True)
int20 = BigEndianInt(20)
int32 = BigEndianInt(32)
int256 = BigEndianInt(256)
hash32 = Binary.fixed_length(32)
trie_root = Binary.fixed_length(32, allow_empty=True)


def zpad(x, l):
    return b'\x00' * max(0, l - len(x)) + x


class Transaction(Serializable):
    fields = [
        ('nonce', big_endian_int),
        ('gasprice', big_endian_int),
        ('startgas', big_endian_int),
        ('to', address),
        ('value', big_endian_int),
        ('data', binary),

# Path: rlp/sedes/big_endian_int.py
# class BigEndianInt(object):
#     def __init__(self, l=None):
#     def serialize(self, obj):
#     def deserialize(self, serial):
# 
# Path: rlp/sedes/binary.py
# class Binary(object):
#     def __init__(self, min_length=None, max_length=None, allow_empty=False):
#     def fixed_length(cls, l, allow_empty=False):
#     def is_valid_type(cls, obj):
#     def is_valid_length(self, l):
#     def serialize(self, obj):
#     def deserialize(self, serial):
# 
# Path: rlp/sedes/lists.py
# class CountableList(object):
# 
#     """A sedes for lists of arbitrary length.
# 
#     :param element_sedes: when (de-)serializing a list, this sedes will be
#                           applied to all of its elements
#     :param max_length: maximum number of allowed elements, or `None` for no limit
#     """
# 
#     def __init__(self, element_sedes, max_length=None):
#         self.element_sedes = element_sedes
#         self.max_length = max_length
# 
#     @to_list
#     def serialize(self, obj):
#         if not is_sequence(obj):
#             raise ListSerializationError('Can only serialize sequences', obj)
# 
#         if self.max_length is not None and len(obj) > self.max_length:
#             raise ListSerializationError(
#                 'Too many elements ({}, allowed {})'.format(
#                     len(obj),
#                     self.max_length,
#                 ),
#                 obj=obj,
#             )
# 
#         for index, element in enumerate(obj):
#             try:
#                 yield self.element_sedes.serialize(element)
#             except SerializationError as e:
#                 raise ListSerializationError(obj=obj, element_exception=e, index=index)
# 
#     @to_tuple
#     def deserialize(self, serial):
#         if not is_sequence(serial):
#             raise ListDeserializationError('Can only deserialize sequences', serial=serial)
#         for index, element in enumerate(serial):
#             if self.max_length is not None and index >= self.max_length:
#                 raise ListDeserializationError(
#                     'Too many elements (more than {})'.format(self.max_length),
#                     serial=serial,
#                 )
# 
#             try:
#                 yield self.element_sedes.deserialize(element)
#             except DeserializationError as e:
#                 raise ListDeserializationError(serial=serial, element_exception=e, index=index)
# 
# Path: rlp/sedes/serializable.py
# class Serializable(BaseSerializable, metaclass=SerializableBase):
#     """
#     The base class for serializable objects.
#     """
#     pass


# Path: tests/speed.py
import random
import rlp
import time
from rlp.sedes import big_endian_int, BigEndianInt, Binary, binary, CountableList
from rlp.sedes.serializable import Serializable

"""
util to benchmark known usecase
"""

address = Binary.fixed_length(20, allow_empty=True)
int20 = BigEndianInt(20)
int32 = BigEndianInt(32)
int256 = BigEndianInt(256)
hash32 = Binary.fixed_length(32)
trie_root = Binary.fixed_length(32, allow_empty=True)


def zpad(x, l):
    return b'\x00' * max(0, l - len(x)) + x


class Transaction(Serializable):
    fields = [
        ('nonce', big_endian_int),
        ('gasprice', big_endian_int),
        ('startgas', big_endian_int),
        ('to', address),
        ('value', big_endian_int),
        ('data', binary),

        ('v', big_endian_int),