コード例 #1
0
 def test_raw_tx_gas_price(self):
     self.assertEqual(
         2000000000,
         eth_common_utils.raw_tx_gas_price(
             memoryview(eth_fixtures.LEGACY_TRANSACTION), 0))
     self.assertEqual(
         2000000000,
         eth_common_utils.raw_tx_gas_price(
             memoryview(eth_fixtures.LEGACY_TRANSACTION_EIP_2718), 0))
     self.assertEqual(
         225600000000,
         eth_common_utils.raw_tx_gas_price(
             memoryview(eth_fixtures.ACL_TRANSACTION), 0))
コード例 #2
0
 def is_gas_price_above_min_network_fee(
         self, transaction_contents: Union[memoryview, bytearray]) -> bool:
     gas_price = eth_common_utils.raw_tx_gas_price(
         memoryview(transaction_contents), 0)
     if gas_price >= self.get_blockchain_network().min_tx_network_fee:
         return True
     return False
コード例 #3
0
 def publish_new_transaction(self, tx_hash: Sha256Hash,
                             tx_contents: memoryview) -> None:
     gas_price = eth_common_utils.raw_tx_gas_price(tx_contents, 0)
     if gas_price >= self.node.get_network_min_transaction_fee():
         self.node.feed_manager.publish_to_feed(
             EthNewTransactionFeed.NAME,
             EthRawTransaction(tx_hash, tx_contents, FeedSource.BDN_SOCKET))
コード例 #4
0
    def msg_tx_after_tx_service_process_complete(
            self,
            process_result: List[ProcessTransactionMessageFromNodeResult]):
        # calculate minimal tx gas price only if transaction validation is enabled
        if not self.node.opts.transaction_validation:
            return

        for result in process_result:
            fee = eth_common_utils.raw_tx_gas_price(
                memoryview(result.transaction_contents), 0)
            self.node.min_tx_from_node_gas_price.add(fee)
コード例 #5
0
    def tx_to_bx_txs(
        self,
        tx_msg,
        network_num,
        transaction_flag: Optional[TransactionFlag] = None,
        min_tx_network_fee: int = 0,
        account_id: str = common_constants.DECODED_EMPTY_ACCOUNT_ID
    ) -> List[Tuple[TxMessage, Sha256Hash, Union[bytearray, memoryview]]]:
        """
        Converts Ethereum transactions message to array of internal transaction messages

        The code is optimized and does not make copies of bytes

        :param tx_msg: Ethereum transaction message
        :param network_num: blockchain network number
        :param transaction_flag: transaction flag to assign to the BDN transaction.
        :param min_tx_network_fee: minimum transaction fee. excludes transactions with gas price below this value,
        :param account_id: the account id of the gateway
        :return: array of tuples (transaction message, transaction hash, transaction bytes)
        """

        if not isinstance(tx_msg, TransactionsEthProtocolMessage):
            raise TypeError(
                f"TransactionsEthProtocolMessage is expected for arg tx_msg but was {type(tx_msg)}"
            )
        bx_tx_msgs = []

        msg_bytes = memoryview(tx_msg.rawbytes())

        _, length, start = rlp_utils.consume_length_prefix(msg_bytes, 0)
        txs_bytes = msg_bytes[start:]

        tx_start_index = 0

        while True:
            bx_tx, _, tx_item_length, tx_item_start = eth_common_utils.raw_tx_to_bx_tx(
                txs_bytes, tx_start_index, network_num, transaction_flag,
                account_id)

            gas_price = eth_common_utils.raw_tx_gas_price(
                txs_bytes, tx_start_index)
            if gas_price >= min_tx_network_fee:
                bx_tx_msgs.append(
                    (bx_tx, bx_tx.message_hash(), bx_tx.tx_val()))

            tx_start_index = tx_item_start + tx_item_length

            if tx_start_index == len(txs_bytes):
                break

        return bx_tx_msgs
コード例 #6
0
    def test_raw_tx_gas_price(self):
        tx_bytes = \
            b"\xf8k" \
            b"!" \
            b"\x85\x0b\xdf\xd6>\x00" \
            b"\x82R\x08\x94" \
            b"\xf8\x04O\xf8$\xc2\xdc\xe1t\xb4\xee\x9f\x95\x8c*s\x84\x83\x18\x9e" \
            b"\x87\t<\xaf\xacj\x80\x00\x80" \
            b"!" \
            b"\xa0-\xbf,\xa9+\xae\xabJ\x03\xcd\xfa\xe3<\xbf$\x00e\xe2N|\xc9\xf7\xe2\xa9\x9c>\xdfn\x0cO\xc0\x16" \
            b"\xa0)\x11K=;\x96X}a\xd5\x00\x06eSz\xd1,\xe4>\xa1\x8c\xf8\x7f>\x0e:\xd1\xcd\x00?'?"

        self.assertEqual(
            51000000000,
            eth_common_utils.raw_tx_gas_price(memoryview(tx_bytes), 0))