Hyperledger-iroha Digest, Vol 5, Issue 1


Michele
 

I have created a gitHub issue for that one, https://github.com/hyperledger/iroha/issues/833
After quite a few testing the problem seems to be around data encoding of the signature. 
Would be useful to define the conversion needed for Swift -> Iroha communication and then document that and add to the Iroha-ios library.

Thanks,
Michele


2018-01-02 12:00 GMT+00:00 <hyperledger-iroha-request@...>:

Send Hyperledger-iroha mailing list submissions to
        hyperledger-iroha@lists.hyperledger.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.hyperledger.org/mailman/listinfo/hyperledger-iroha
or, via email, send a message with subject or body 'help' to
        hyperledger-iroha-request@lists.hyperledger.org

You can reach the person managing the list at
        hyperledger-iroha-owner@lists.hyperledger.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Hyperledger-iroha digest..."


Today's Topics:

   1. Re: iOS app using gRPC-swift client code cause irohad to
      crash (Michele Simone)


----------------------------------------------------------------------

Message: 1
Date: Tue, 2 Jan 2018 10:08:25 +0000
From: Michele Simone <michele.si@...>
To: justkitsu@..., bogdan@...
Cc: hyperledger-iroha@lists.hyperledger.org
Subject: Re: [Hyperledger-iroha] iOS app using gRPC-swift client code
        cause irohad to crash
Message-ID:
        <CACH5=1a7qm4oqwABFmvd9M6qvJh9YKrCN8f7d=rAO88QwHhcpQ@...>
Content-Type: text/plain; charset="utf-8"

Hi thank you for your answer,

I though the signature might be the issue as is the only data field not
strongly typed.
I'm adding the signature to the message converting the String to UTF8 with
a function similar to the following:

private func addSignatureTo(_ query: inout Iroha_Protocol_Query) {
        let keypair = IrohaSwift.createKeyPair()
        var signature = Iroha_Protocol_Signature()
        signature.pubkey = keypair.publicKey.data(using: .utf8)!
        signature.signature = sign(publicKey: keypair.publicKey,
privateKey: keypair.privateKey, message: try!
query.payload.jsonString()).data(using: .utf8)!
        query.signature = signature
}

I'm leveraging https://github.com/hyperledger/iroha-ios for the
cryptographic component.


===== Irohad Log: =====
[18:19:42][th: 5383][info] [MAIN] << start
[18:19:42][th: 5383][info] [MAIN] << config initialized
[18:19:42][th: 5383][info] [IROHAD] << created
[18:19:42][th: 5383][info] [StorageImpl:initConnection] << Start storage
creation
[18:19:42][th: 5383][info] [StorageImpl:initConnection] << block store
created
[18:19:42][th: 5383][info] [StorageImpl:initConnection] << connection to
Redis completed
[18:19:42][th: 5383][info] [StorageImpl:initConnection] << connection to
PostgreSQL completed
[18:19:42][th: 5383][info] [StorageImpl:initConnection] << transaction to
PostgreSQL initialized
[18:19:42][th: 5383][info] [IROHAD] << [Init] => storage
[18:19:42][th: 5383][info] [StorageImpl] << Drop ledger
[18:19:42][th: 5383][info] [StorageImpl] << drop dp
[18:19:42][th: 5383][info] [StorageImpl] << drop redis
[18:19:42][th: 5383][info] [StorageImpl] << drop block store
[18:19:42][th: 5383][info] [MAIN] << Block is parsed
[18:19:42][th: 5383][info] [MAIN] << Genesis block inserted, number of
transactions: 1
[18:19:42][th: 5383][info] [IROHAD] << [Init] => converters
[18:19:42][th: 5383][info] [IROHAD] << [Init] => peer query
[18:19:42][th: 5383][info] [IROHAD] << [Init] => crypto provider
[18:19:42][th: 5383][info] [IROHAD] << [Init] => validators
[18:19:42][th: 5383][info] [OrderingGate] << Subscribe
[18:19:42][th: 5383][info] [IROHAD] << [Init] => init ordering gate - [true]
[18:19:42][th: 5383][info] [IROHAD] << [Init] => init simulator
[18:19:42][th: 5383][info] [IROHAD] << [Init] => block loader
[18:19:42][th: 5383][info] [IROHAD] << [Init] => consensus gate
[18:19:42][th: 5383][info] [IROHAD] << [Init] => synchronizer
[18:19:42][th: 5383][info] [IROHAD] << [Init] => pcs
[18:19:42][th: 5383][info] [IROHAD] << [Init] => command service
[18:19:42][th: 5383][info] [IROHAD] << [Init] => query service
[18:19:42][th: 5383][info] [MAIN] << Running iroha
[18:19:42][th: 5383][info] [IROHAD] << ===> iroha initialized
terminate called after throwing an instance of 'std::invalid_argument'
  what():  blob_t: input string has incorrect length
./start.sh: line 1:  5383 Aborted



==== Irohad starting parameters ====

../build/bin/irohad --config config.sample --genesis_block genesis.block
--keypair_name node0

Genesys block as generated by cli with peer list as localhost:20000


==== Protobuf and gPRC ===

I have generated the protobuf objects and the gRPC client stub using
https://github.com/grpc/grpc-swift and
https://github.com/apple/swift-protobuf plugins for the peptic compiler.

I'm then sending messages to the peer with:

 let queryServer = Iroha_Protocol_QueryServiceService(address:
"\(ip):\(port)", secure: false)
        do {
            var message = createGetAccountInfoMessage()
            addSignatureTo(&message)
            print("============== TESTING QUERY SERVICE ================")
            print(message.textFormatString())
            let find = try queryServer.find(message)
            print(find.textFormatString())
        } catch {
            print(error)
        }
        print("============== END TESTING QUERY SERVICE ================")



I will open a GitHub issue with those details as suggested. Please let me
know if there's anything I can contribute back to the community.
Thanks,
Michele



2017-12-30 13:14 GMT+00:00 <justkitsu@...>:

> On Friday, December 29, 2017 9:33:29 PM MSK you wrote:
> > Hi all, I'm trying to build a simple iOS application sending command to
> > iroha network running on a local machine. At the moment I've managed to
> > generate the client side using grpc-swift starting from the proto
> > definitions in the iroha project. Now every command or query I try to
> send
> > to the network kill the irohad with the following error
> >
> > ---------
> > terminate called after throwing an instance of 'std::invalid_argument'
> >   what():  blob_t: input string has incorrect length
> > ./start.sh: line 1:  5383 Aborted
> > ---------------
> >
> > Any help or advise please on what can be causing this issue ?
> >
> > ps: I've sent the same message on rocket chat but seems quite not active
> > over there sorry for spamming.
>
>
> Hello, Michele!
>
> So far we haven't entirely test swift bindings and don't really (prob.) now
> most of the troubles. It's quite hard to understand the issue from that
> amount
> of information. Would be nice to note:
> - what branch/commit of iroha did you use
> - any logs from irohad
> - how did you start irohad (e.g genesis block info, argument params, etc)
> - how did you create protobuf objects and how did you call grpc
>
> Imo that probably an iroha's issue so you can open a new one at the github
> (https://github.com/hyperledger/iroha/issues).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hyperledger.org/pipermail/hyperledger-iroha/attachments/20180102/87cbd7ce/attachment-0001.html>

------------------------------

_______________________________________________
Hyperledger-iroha mailing list
Hyperledger-iroha@lists.hyperledger.org
https://lists.hyperledger.org/mailman/listinfo/hyperledger-iroha


End of Hyperledger-iroha Digest, Vol 5, Issue 1
***********************************************