from sawtooth_signing.secp256k1 import Secp256k1PublicKey from sawtooth_validator.protobuf import client_batch_submit_pb2 from sawtooth_validator.protobuf.transaction_pb2 import TransactionHeader from sawtooth_validator.protobuf.batch_pb2 import BatchHeader from sawtooth_validator.protobuf.block_pb2 import BlockHeader from sawtooth_validator.protobuf.network_pb2 import GossipMessage from sawtooth_validator import metrics from sawtooth_validator.networking.dispatch import HandlerResult from sawtooth_validator.networking.dispatch import HandlerStatus from sawtooth_validator.networking.dispatch import Handler from sawtooth_validator.protobuf.validator_pb2 import Message from sawtooth_validator.journal.timed_cache import TimedCache LOGGER = logging.getLogger(__name__) COLLECTOR = metrics.get_collector(__name__) def is_valid_block(block): # validate block signature header = BlockHeader() header.ParseFromString(block.header) context = create_context('secp256k1') public_key = Secp256k1PublicKey.from_hex(header.signer_public_key) if not context.verify(block.header_signature, block.header, public_key): LOGGER.debug("block failed signature validation: %s", block.header_signature) return False # validate all batches in block. These are not all batches in the
from sawtooth_validator.concurrent.threadpool import \ InstrumentedThreadPoolExecutor from sawtooth_validator.execution.context_manager import \ CreateContextException from sawtooth_validator.execution.scheduler_serial import SerialScheduler from sawtooth_validator.execution.scheduler_parallel import ParallelScheduler from sawtooth_validator.execution.processor_manager import ProcessorType from sawtooth_validator.execution.processor_manager import ProcessorManager from sawtooth_validator.execution.processor_manager import \ RoundRobinProcessorIterator from sawtooth_validator.networking.future import FutureResult from sawtooth_validator.networking.future import FutureTimeoutError from sawtooth_validator import metrics LOGGER = logging.getLogger(__name__) COLLECTOR = metrics.get_collector(__name__) class TransactionExecutorThread: """A thread of execution controlled by the TransactionExecutor. Provides the functionality that the journal can process on several schedulers at once. """ def __init__(self, service, context_manager, scheduler, processor_manager, settings_view_factory, invalid_observers):