Git Product home page Git Product logo

iroha-python's Introduction

iroha-python's People

Contributors

6r1d avatar alexstroke avatar appetrosyan avatar bastos525 avatar dependabot[bot] avatar i1i1 avatar nxsaken avatar quentini avatar ryjones avatar s8sato avatar samhsmith avatar takemiyamakoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iroha-python's Issues

Notice: trailofbits/gh-action-pip-audit is now pypa/gh-action-pip-audit

Thanks for using gh-action-pip-audit in your CI!

I'm filing this issue (as an actual human being) to let you know that we recently became a PyPA member project, and correspondingly changed our repo from trailofbits/gh-action-pip-audit to pypa/gh-action-pip-audit.

As part of keeping your workflows up-to-date, we recommend that you change your workflow slugs to pypa/gh-action-pip-audit. Once you do that, Dependabot (or whatever other tooling you use) should track updates to the action correctly.

P.S.: I'm filing these issues instead of making PRs, so that you (as maintainers) can confirm the trustworthiness of the change. If you'd prefer me to make a PR instead, give me a ping and I'll do so.

Functions to create genesis block missing

In official iroha's documentation I see example of directly creating genesis block (here). It is code from documentation:

admin = commons.new_user('admin@test')
alice = commons.new_user('alice@test')
bob = commons.new_user('bob@test')
iroha = Iroha(admin['id'])

@commons.hex
def genesis_tx():
    test_permissions = [primitive_pb2.can_create_account]
    genesis_commands = commons.genesis_block(admin, alice, test_permissions)
    tx = iroha.transaction(genesis_commands)
    IrohaCrypto.sign_transaction(tx, admin['key'])
    return tx

@commons.hex
def create_account_tx():
    tx = iroha.transaction([
        iroha.command('CreateAccount', account_name='bob', domain_id='test', public_key=bob['key'])
    ], creator_account=alice['id'])
    IrohaCrypto.sign_transaction(tx, alice['key'])
    return tx

But in library code I don't see functions: commons.genesis_block. On the other hand I see that functionalities in java's part of documentation:

private static BlockOuterClass.Block getGenesisBlock() {
    return new GenesisBlockBuilder()
        // first transaction
        .addTransaction(
            // transactions in genesis block can have no creator
            Transaction.builder(null)
                // by default peer is listening on port 10001
                .addPeer("0.0.0.0:10001", peerKeypair.getPublic())
                // create default "user" role
                .createRole(userRole,
                    Arrays.asList(
                        RolePermission.can_transfer,
                        RolePermission.can_get_my_acc_ast,
                        RolePermission.can_get_my_txs,
                        RolePermission.can_receive
                    )
                )
                .createDomain(bankDomain, userRole)
                // create user A
                .createAccount("user_a", bankDomain, useraKeypair.getPublic())
                // create user B
                .createAccount("user_b", bankDomain, userbKeypair.getPublic())
                // create usd#bank with precision 2
                .createAsset(usdName, bankDomain, 2)
                // transactions in genesis block can be unsigned
                .build() // returns ipj model Transaction
                .build() // returns unsigned protobuf Transaction
        )
        // we want to increase user_a balance by 100 usd
        .addTransaction(
            Transaction.builder(user("user_a"))
                .addAssetQuantity(usd, new BigDecimal("100"))
                .build()
                .build()
        )
        .build();
  }

Using send_blocks_stream_query with the timeout option causes memory leak on iroha

Hi,

I don't know if this is an iroha or a iroha-python issue but in brief, I was using send_blocks_stream_query to monitor some transactions using a separate thread and to get a change to stop the thread I was using the timeout parameter set to 2sec.

    def get_blocks(self, callback):

        if self.thread is None and self.task is None:
            from threading import Thread
            self.task = GetBlocksTask(self)

            t = Thread(target = self.task.run, args=(callback, ))
            t.start()
            self.thread = t
        else:
            raise ValueError("Thread already started, stop it first")

    def stop_tasks(self):
        self.task.terminate()
        self.thread.join()

class GetBlocksTask:

    def __init__(self, helper):
        self._running = True
        self.helper = helper

    def terminate(self):
        self._running = False

    def run(self, callback):
        query = self.helper.iroha.blocks_query()
        IrohaCrypto.sign_query(query, self.helper.private_key)

        while self._running:
            try:
                for block in self.helper.net.send_blocks_stream_query(query, timeout=2):
                    callback(block)
            except Exception as e:
                # print("weird way to stop the thread...")
                pass

        print("Stopping loop")

From the python client point of view it works well but after a day, I saw that the iroha server memory increased from 20Mb to 2GB and more than 26K pids where created (one per 2s):

CONTAINER ID   NAME             CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O         PIDS
f54613a786e1   prometheus       0.00%     146.9MiB / 7.776GiB   1.84%     35.3MB / 2.46MB   0B / 4.1kB        8
00ea27268cbc   cadvisor         2.91%     108.2MiB / 7.776GiB   1.36%     3.8MB / 229MB     217kB / 0B        15
7c8a719e3648   explorer         0.00%     50MiB / 7.776GiB      0.63%     5.85kB / 314B     1.39MB / 0B       12
0aa1ad98c8fb   iroha0           0.02%     2.32GiB / 7.776GiB    29.84%    97.2MB / 107MB    20.5kB / 0B       26346
6ba0c59e1475   iroha1           0.02%     13.88MiB / 7.776GiB   0.17%     103MB / 112MB     20.5kB / 0B       15
36df6fdf5dd7   iroha2           0.02%     10.41MiB / 7.776GiB   0.13%     66MB / 64.3MB     20.5kB / 0B       13
dc8036cc6350   some-postgres0   0.00%     80.86MiB / 7.776GiB   1.02%     39.9MB / 17MB     1.68MB / 144MB    16
222d185b7a03   some-postgres1   0.00%     80.66MiB / 7.776GiB   1.01%     6MB / 4.82MB      815kB / 107MB     16
63fc52e43dbe   some-postgres2   0.00%     79.24MiB / 7.776GiB   1.00%     5.35MB / 4.56MB   6.38MB / 98.5MB   16
0f3d9f6fdef6   traefik          0.42%     34.68MiB / 7.776GiB   0.44%     197MB / 205MB     7.68MB / 188kB    11

So I stopped using the timeout parameter and I found another way to kill the thread but in any case, I get this is a serious bug.

Thanks!

Broken imports (iroha2 branch)

Yesterday, @baziorek found a weird import behavior in Iroha-python.

If he runs a command python3 -c "import iroha2; print(dir(iroha2))", this exception appears:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/agh/Pulpit/blockchain/iroha_code/iroha2/iroha-python/iroha2/__init__.py", line 2, in <module>
    from .sys import Client as _Client
  File "/home/agh/Pulpit/blockchain/iroha_code/iroha2/iroha-python/iroha2/sys/__init__.py", line 1, in <module>
    from ..iroha2 import *
ModuleNotFoundError: No module named 'iroha2.iroha2'

This repeats on:

Context:

  • pip 22.1.2 from /home/agh/.local/lib/python3.10/site-packages/pip (python 3.10)
  • Python 3.10.5
  • ~/.local/lib/python3.10/site-packages/ contains iroha2 and iroha_python-0.1.0.dist-info

need docstring

In order to explain how to use the API, top of all public methods is required docstring (PEP-257)

Basic documentation

As per user requests, at least some examples of how to transfer assets and general usage of the SDK.

Iroha 2: "Unhandled rejection: ParityScale"

LoNeWoLf reported an error in Discord:

return self.cl.submit_all_with_metadata(tx, {})
Exception: Error: Unexpected transaction response;
status: 500 Internal Server Error;
response body: Unhandled rejection: ParityScale

It happens with a standard docker-compose.yml, as shown in the tutorial.

Last commit in Iroha-python: 04c7980d6e, iroha2 branch.
Last commit in Iroha: 91da336af2, iroha2 branch.

The code used here is the standard example file, test.py. There's the copy to be sure:

Code
import iroha2
import json
from iroha2 import Client
from iroha2.data_model import domain
from iroha2.data_model.isi import *
from iroha2.data_model.domain import *
from iroha2.data_model.expression import *
from iroha2.data_model.events import FilterBox, pipeline
from iroha2.data_model import *
cfg = json.loads(open("./config.json").read())
cl = Client(cfg)
domain = NewDomain("iroha_python")
register = Register.identifiable(domain)
hash = cl.submit_isi(register)
filter = FilterBox.Pipeline(
    pipeline.EventFilter(
        entity_kind=pipeline.EntityKind.Transaction(),
        status_kind=pipeline.StatusKind.Committed(),
        hash=None,
    ))
listener = cl.listen(filter)
for event in listener:
    print(event)
    if event["Pipeline"]["status"] == "Committed" \
        and event["Pipeline"]["hash"] == hash:
        break

design

I propose this.

Archtecture

iroha
โ”œโ”€โ”€ transaction.py
|    โ”œโ”€โ”€ Builder
|    โ””โ”€โ”€ Validator
โ”œโ”€โ”€ repository.py
|    โ”œโ”€โ”€ AssetRepo
|    โ””โ”€โ”€ TransactionRepo
โ”œโ”€โ”€ crypto.py
|    โ”œโ”€โ”€ Hash
|    โ””โ”€โ”€ KeyPair
โ””โ”€โ”€ connection.py

Requirements.txt is missing

pip install -r requirements.txt

But where is requirements.txt?

โ”œโ”€โ”€ iroha.py
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ test_iroha.py
โ””โ”€โ”€ tox.ini

Iroha python 1.4.1 - is code generated with too new version?

Unfortunately I've prepared everything for new release: iroha-python 1.4.1. Unfortunately I noticed problems when importing some of python files generated from protobuf.

The problem which I noticed is:

/home/devops/.local/lib/python3.9/site-packages/requests/__init__.py:109: RequestsDependencyWarning: urllib3 (1.26.9) or chardet (5.0.0)/charset_normalizer (2.1.0) doesn't match a supported version!
  warnings.warn(
Traceback (most recent call last):
  File "/home/devops/watra-ledger/src/tokens/kezo.py", line 9, in <module>
    import iroha_common
  File "/home/devops/watra-ledger/src/iroha_common.py", line 7, in <module>
    from iroha import primitive_pb2, IrohaCrypto, binascii, IrohaGrpc, Iroha, commands_pb2, queries_pb2
  File "/home/devops/.local/lib/python3.9/site-packages/iroha/__init__.py", line 7, in <module>
    from .iroha import *
  File "/home/devops/.local/lib/python3.9/site-packages/iroha/iroha.py", line 17, in <module>
    from . import endpoint_pb2
  File "/home/devops/.local/lib/python3.9/site-packages/iroha/endpoint_pb2.py", line 38, in <module>
    _descriptor.EnumValueDescriptor(
  File "/home/devops/.local/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Fortunately the problem is when somebody is using deeper features of library (not just import iroha but e.g. from iroha import primitive_pb2).


First question - who saw the problem? Is the problem in Your environment? Please describe me details?


If somebody has the problem please tell me in the issue. Fastest solution is to add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python environment variable. And I would have to generate files from protobuf files with older version, but it will take time...

Refactor codegen for Enum

Codegen for enums currently uses complex meta-class constructor, which should be simplified to be more in line with make_struct and make_tuple factories.

More idiomatic API

    Yeah, here I'm mostly focusing on at least having actual types instead of jsonly-typed blobs of something.

Making it look like Python will require either way more future work or some approach to codegen I didn't think of.

Originally posted by @QuentinI in #125 (comment)

Add Pytest tests

Currently there are no real tests in the Python SDK. We should ensure that:

  • the backend SDK works as expected,
  • add the code samples in the tutorial as tests, and
  • add some more tests for the Python API itself.

How to mint asset in iroha v2 python SDK?

The snippet to mint asset in the documentation doesn't work. Please revise.

amount = Expression(Value(U32(42)))
destination = Expression(Value(Identifiable(asset.DefinitionId.parse("rose#wonderland"))))
mint_amount = Mint(amount, destination)
cl.submit_isi(mint_amount)

The error

Traceback (most recent call last):
  File "/home/test-python-sdk-v2/asset.py", line 52, in <module>
    mint_asset()
  File "/home/test-python-sdk-v2/asset.py", line 39, in mint_asset
    hash = cl.submit_isi(mint)
  File "/home/iroha-python/venv/lib/python3.10/site-packages/iroha2/__init__.py", line 26, in submit_isi
    return self.submit_tx([_Instruction(isi)])
  File "/home/iroha-python/venv/lib/python3.10/site-packages/iroha2/__init__.py", line 23, in submit_tx
    return self.cl.submit_all_with_metadata(tx, {})
Exception: Error: data did not match any variant of untagged enum ExpressionDeserializeWrapper
    0: data did not match any variant of untagged enum ExpressionDeserializeWrapper

Update the versioning to emit wheel with the correct semver

Currently, we are not able to tell which version of Iroha is the current version the python library is linked against.

This gives users next to no feedback. I propose updating the version emitted in Cargo.toml to move in lockstep with our release cycle.

receiving random grpc._channel._MultiThreadedRendezvous errors from iroha server every 24hours or so

Hello,
[I already posted this to the iroha main repo]
We are using Iroha 1.2 latest on kubernetes. Setup is a single peer, with a postgresql 13 DB - and under like 20 transactions per second.
We are using the python client. We are streaming through the results using a generator. here is the code:

def send_tx_and_stream_result(net, tx, user_private_key):
    iroha.IrohaCrypto.sign_transaction(tx, user_private_key)
    hex_hash = binascii.hexlify(iroha.IrohaCrypto.hash(tx))
    print('Transaction hash = {}, creator = {}'.format(
        hex_hash, tx.payload.reduced_payload.creator_account_id))
    net.send_tx(tx)
    for status in net.tx_status_stream(tx, timeout=args.wlts_iroha_tx_status_timeoout):
        txStatusResponse = wallets_pb2.TxStatusResponse()
        txStatusResponse.status_name = status[0]
        txStatusResponse.status_code = status[1]
        txStatusResponse.error_code = status[2]
        yield txStatusResponse

Iroha works fine and then, every now and then, we start seeing the message:
'grpc._channel._MultiThreadedRendezvous ' errors and Iroha stops being responsive.

Here is our configmap and genesys:

apiVersion: v1
kind: ConfigMap
metadata:
  name: iroha-config
  namespace: caravel-iroha
data:
  genesis.block: |
    {
      "block_v1":{
        "payload":{
            "transactions":[
              {
                  "payload":{
                    "reducedPayload":{
                        "commands":[
                          {
                              "addPeer":{
                                "peer":{
                                    "address":"XYZ:10001",
                                    "peerKey":"XYZ"
                                }
                              }
                          },
                          {
                              "createRole":{
                                "roleName":"admin",
                                "permissions":[
                                    "can_add_peer",
                                    "can_add_signatory",
                                    "can_create_account",
                                    "can_create_domain",
                                    "can_get_all_acc_ast",
                                    "can_get_all_acc_ast_txs",
                                    "can_get_all_acc_detail",
                                    "can_get_all_acc_txs",
                                    "can_get_all_accounts",
                                    "can_get_all_signatories",
                                    "can_get_all_txs",
                                    "can_get_blocks",
                                    "can_get_roles",
                                    "can_read_assets",
                                    "can_remove_signatory",
                                    "can_set_quorum",
                                    "can_receive"
                                ]
                              }
                          },
                          {
                              "createRole":{
                                "roleName":"user",
                                "permissions":[
                                    "can_add_signatory",
                                    "can_get_my_acc_ast",
                                    "can_get_my_acc_ast_txs",
                                    "can_get_my_acc_detail",
                                    "can_get_my_acc_txs",
                                    "can_get_my_account",
                                    "can_get_my_signatories",
                                    "can_get_my_txs",
                                    "can_grant_can_add_my_signatory",
                                    "can_grant_can_remove_my_signatory",
                                    "can_grant_can_set_my_account_detail",
                                    "can_grant_can_set_my_quorum",
                                    "can_grant_can_transfer_my_assets",
                                    "can_receive",
                                    "can_remove_signatory",
                                    "can_set_quorum",
                                    "can_transfer"
                                ]
                              }
                          },
                          {
                              "createRole":{
                                "roleName":"money_creator",
                                "permissions":[
                                    "can_add_asset_qty",
                                    "can_create_asset",
                                    "can_receive",
                                    "can_transfer"
                                ]
                              }
                          },
                          {
                              "createDomain":{
                                "domainId":"caravel",
                                "defaultRole":"user"
                              }
                          },
                          {
                              "createAsset":{
                                "assetName":"XYZ",
                                "domainId":"XYZ",
                                "precision":2
                              }
                          },
                          {
                              "createAccount":{
                                "accountName":"XYZ",
                                "domainId":"XYZ",
                                "publicKey":"XYZ"
                              }
                          },
                          {
                              "createAccount":{
                                "accountName":"XYZ",
                                "domainId":"XYZ",
                                "publicKey":"XYZ"
                              }
                          },
                          {
                              "createAccount":{
                                "accountName":"XYZ",
                                "domainId":"XYZ",
                                "publicKey":"XYZ"
                              }
                          },
                        
                          {
                              "appendRole":{
                                "accountId":"XYZ@XYZ",
                                "roleName":"admin"
                              }
                          },
                          {
                              "appendRole":{
                                "accountId":"XYZ@XYZ",
                                "roleName":"money_creator"
                              }
                          }
                        ],
                        "quorum":1
                    }
                  }
              }
            ],
            "txNumber":1,
            "height":"1",
            "prevBlockHash":"0000000000000000000000000000000000000000000000000000000000000000"
        }
      }
    }
  config.docker: |
    {
      "block_store_path" : "/opt/block_store/",
      "torii_port" : 50051,
      "internal_port" : 10001,
      "pg_opt" : "host=XYZ port=5432 user=XYZ password=XYZ dbname=irohadefault",
      "database": {
        "host": "XYZ",
        "port": 5432,
        "user": "XYZ",
        "password": "XYZ",
        "working database": "iroha_data",
        "maintenance database": "iroha_maintenance"
      },
      "max_proposal_size" : 3000,
      "proposal_delay" : 1000,
      "vote_delay" : 5000,
      "load_delay" : 5000,
      "mst_enable" : true,
      "log": {
        "level": "trace",
        "patterns": {
          "debug": "debug %v",
          "error": "error %v!"
        },
        "children": {
          "KeysManager": {
            "level": "trace"
          },
          "Irohad": {
            "children": {
              "Storage": {
                "level": "trace",
                "patterns": {
                  "debug": "thread %t: %v."
                }
              }
            }
          }
        }
      }
    }

Do you think me using the generator being a problem under heavy load ?
Thank you so much,
Rafik

Transport Closed

Hi all,

I am trying to execute example usage script, that is demonstrated in iroha-python repo Readme,

from iroha import Iroha, IrohaCrypto, IrohaGrpc

iroha = Iroha('alice@test')
net = IrohaGrpc('127.0.0.1:50051')

alice_key = IrohaCrypto.private_key()
alice_tx = iroha.transaction(
    [iroha.command(
        'TransferAsset', 
        src_account_id='alice@test', 
        dest_account_id='bob@test', 
        asset_id='bitcoin#test',
        description='test',
        amount='1'
    )]
)
IrohaCrypto.sign_transaction(alice_tx, alice_key)
net.send_tx(alice_tx)

for status in net.tx_status_stream(alice_tx):
    print(status)

And I get the above error:

grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "Transport closed" debug_error_string = "{"created":"@1574768622.626196952","description":"Error received from peer ipv4:127.0.0.1:50051","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Transport closed","grpc_status":14}"

Any ideas??

Many thanks

Ordering Transaction Results Issue

https://iroha.readthedocs.io/en/main/develop/api/queries.html#result-pagination seems not to be working very well:

by @baziorek:

"I've tried:
pagination_meta = queries_pb2.TxPaginationMeta()
pagination_meta.ordering.sequence = [queries_pb2.kCreatedTime, queries_pb2.kAscending]

        query = iroha.query('GetAccountAssetTransactions', account_id=account_id, asset_id=asset_name, page_size=page_size, pagination_meta=pagination_meta)

But for each try I'm seeing problem, e.g. for above:
AttributeError: Assignment not allowed to repeated field "sequence" in protocol message object."

Example doesn't work

Steps to reproduce

  • Clone repo
  • build
  • pip install ./target/wheels/iroha_python-0.1.0-cp39-cp39-linux_x86_64.whl
  • cd example
  • docker compose up
  • python3 test.py

Expected

Success and script runs fully

Actual

image

Examples for the documentation

Hello.

I'd like to add the common language guide to the Iroha documentation.
Since Iroha for Python 3 is the most convenient for many users, it is necessary for the examples.

How stable are the examples displayed in the tutorial for Python 3?

I am mostly interested in:

  • Loading the JSON configuration for Iroha so it could be used by the Java library
  • Client setup, given the configuration above
  • Registering an Iroha domain
  • Registering an Iroha account
  • Registering an asset
  • Minting an asset mentioned above
  • Listing domains / accounts / assets, displaying an output

Potentially, it'll be great to enable these examples as tests, marking the parts useful for the end user with the comments.

Replace structures with methods in the Python API

The current approach of creating lots of objects is not very pythonic. It would be preferable, if instead we had a way of using dick-typing and methods + keyword arguments to set things up.

Example

As of today our example contains the following:

asset_definition = asset.Definition(
    "pyasset#python",
    asset.ValueType.Quantity(),
    asset.Mintable.Infinitely(),
)

In reality what we should have

asset_definition = asset.definition("pyasset#python", value_type = "q", mintable=True)

Where the method handles the conversion of the shorthand notation of "q" into Quantity, mintable=True into Mintable.Infinitely and not specifying them creates an asset with sensible defaults (which are Quantity and Mintable.Infinitely).

We can also treat the rust FromStr methods to do the conversion in place.

Unable to build the recent version according to the documentation

Today, @learningnoobi wrote that a fresh qroha-python is broken:

$ git clone https://github.com/hyperledger/iroha-python/ --branch iroha2 iroha-2-python
# ...

$ cd iroha-2-python
# ...

$ maturin build
๐Ÿน Building a mixed python/rust project

๐Ÿ’ฅ maturin failed
  Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
  Caused by: `cargo metadata` exited with an error:
    Updating git repository `https://github.com/hyperledger/iroha`
    Updating crates.io index
error: failed to select a version for `async-trait`.
    ... required by package `iroha_core v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_core` of package `iroha_client v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_client` of package `iroha_python v0.1.0 (โ€ฆ/iroha-2-python)`
versions that meet the requirements `^0.1.57` are: 0.1.57

all possible versions conflict with previously selected packages.

  previously selected package `async-trait v0.1.56`
    ... which satisfies dependency `async-trait = "^0.1"` (locked to 0.1.56) of package `iroha_core v2.0.0-pre-rc.5 (https://github.com/hyperledger/iroha?branch=iroha2-dev#f7fac5f2)`
    ... which satisfies git dependency `iroha_core` (locked to 2.0.0-pre-rc.5) of package `iroha_schema_gen v2.0.0-pre-rc.5 (https://github.com/hyperledger/iroha?branch=iroha2-dev#f7fac5f2)`
    ... which satisfies git dependency `iroha_schema_gen` (locked to 2.0.0-pre-rc.5) of package `generate v0.1.0 (โ€ฆ/iroha-2-python/generate)`

failed to select a version for `async-trait` which could resolve this conflict
$ rustc --version
rustc 1.64.0 (a55dd71d5 2022-09-19)
$ cargo --version
cargo 1.64.0 (387270bc7 2022-09-16)

I have also notified @QuentinI.

Pypi package 1.4.0 does only contain metadata

Hi Iroha Python team,

The 1.4.0 Pypi package seems to only include metadata without the client library python code.

> pip install iroha
> ls -ld lib/python3.7/site-packages/iroha*
lib/python3.7/site-packages/iroha-1.4.0.dist-info
> pip install iroha==1.0.0
> ls -ld lib/python3.7/site-packages/iroha*
lib/python3.7/site-packages/iroha  lib/python3.7/site-packages/iroha-1.0.0.dist-info

Thanks in advance,
All the best
Vince

Query "GetAccountAssets" has problem: AttributeError: Assignment not allowed to field "pagination_meta" in protocol message object.

I'm trying to create query according to documentation, but I can't assign one of mandatory fields to query: pagination_meta, because during running of script I see:
AttributeError: Assignment not allowed to field "pagination_meta" in protocol message object.

Full code:

    def get_account_tokens(self, account):
        asset_pagination = iroha.queries_pb2.AssetPaginationMeta()
        asset_pagination.page_size = 100
        query = self.iroha.query('GetAccountAssets', account_id=account, pagination_meta=asset_pagination)
        IrohaCrypto.sign_query(query, self.account_private_key)
        response = self.net.send_query(query)
        assets = response.account_assets_response.account_assets
        for asset in assets:
            asset_id = asset.asset_id
            balance = int(asset.balance)
            print(asset_id, balance)

I'm using version nawest (currently) version:

$ pip show iroha
Name: iroha
Version: 0.0.5.5

Incomplete function documentation

I am contemplating adopting Iroha, but the documentation is sparse and there are several SDKs that seem to be at different levels of maintenance and functional coverage. I'd prefer to use the Python one, but I have cloned this repo and find no ability to control the multisignature or access control functions of the ledger. How are these meant to be managed?

Better Exceptions.

Because iroha-python is a wrapper around rust code, the full trace-back for an exception is truncated to the Python code in which it was called. So all exceptions should contain the maximum amount of information.

For example

Traceback (most recent call last):
   File "/mnt/Archive/Git/iroha-python/example/./test.py", line 18, in <module>
hash = cl.submit_isi(register)
   File "/home/app/.local/lib/python3.9/site-packages/iroha2/__init__.py", line 39, in submit_isi
return self.submit_tx([_Instruction(isi)])
   File "/home/app/.local/lib/python3.9/site-packages/iroha2/__init__.py", line 36, in submit_tx
return self.cl.submit_all_with_metadata(tx, {})
   Exception: Failed to send transaction with hash HashOf(7f95850f295eb71cc94c40923a93f1e26d34dd401f216698a5fc4d2292344d26, PhantomData)

is insufficiently informative.

Get raw bytes of a built transaction

Add a possibility to get raw bytes of a transaction / query (SCALE encoded HTTP body content) without sending them to Iroha node.

This can be useful if some custom http clients are used.

Insecure use of ed25519

Bernstein's python3 reference implementation of ed25519 is not appropriate for production purposes as it makes the python interpreter run functions for which that interpreter is not (cryptographically) designed, creating realistic attack scenarios in many environments.

Your optimization remains incorporating this weakness (line 18-33?).

Still, iroha-python uses your optimization for such purposes: it generates signatures and public keys from secret keys using ./ed25519.py.

Yet, the repository does not make aware of not being eligible for production purposes. Also, https://iroha.readthedocs.io/ suggests using iroha-python for production use.

I suggest to use cryptography with ed25519 / docs which is well maintained and suited for production use. Will have a better performance, too.

More detailed exceptions

Today, sgull reported an error while trying to run the most basic documentation example while using a default config from the docs.

import json
from iroha2 import Client

cfg = json.loads(open("config.json").read())
cl = Client(cfg)

This is the error log, which, honestly, doesn't tell a lot to respond about:

Exception                                 Traceback (most recent call last)
Cell In[55], line 6
      4 cfg = json.loads(open("config.json").read())
      5 # cfg
----> 6 cl = Client(cfg)

File ~/.local/lib/python3.10/site-packages/iroha2/__init__.py:13, in Client.__init__(self, cfg, headers)
     11 def __init__(self, cfg, headers=None):
     12     if headers is None:
---> 13         self.cl = _Client(cfg)
     14     else:
     15         self.cl = _Client.with_headers(cfg, headers)

This error also repeats when he tries to run a test.py file.

We need to report if it's a malformed config that:

  • Can't be parsed
  • Misses some of the keys
  • Doesn't allow Iroha 2 client to connect
  • etc.

I'm certain there are several things I'm currently missing, and that doesn't allow to respond to the users. Let us discuss those and return to them later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.