LoginSignup
1
1

More than 3 years have passed since last update.

[Hyperledger Iroha]Pythonライブラリからクエリを実行すると[bad timestamp: sent from future]が返ってくる

Posted at

内容

ちょっとしたことですが対応方法をメモ

エラー内容

Hyperledger Irohaのライブラリを使ってRoleを取得するクエリを実行する

get_role.py
from iroha import Iroha, IrohaCrypto, IrohaGrpc
import iroha_config

net = IrohaGrpc(iroha_config.IROHA_HOST)

iroha = Iroha(iroha_config.ADMIN_ACCOUNT)
admin_priv_key = iroha_config.ADMIN_PRIV_KEY

# Queryの作成
get_block_query = iroha.query(
    'GetRoles'
)

# Transactionへ署名
IrohaCrypto.sign_query(get_block_query, iroha_config.ADMIN_PRIV_KEY)

# Transactionの送信
response = net.send_query(get_block_query)
print(response)

エラーの内容

error_response {
  message: "Query: [[bad timestamp: sent from future, timestamp: 1594256328577, now: 1594147827999 ]]\n"
}
query_hash: "e4567087a82943225e0a774cf4b4349a62f35854f947b8ecf78039a945ae3858"

エラーの原因と対応策

Pythonを動かしているクライアントとirohaを動かしているVMの時間がずれていたことが原因

以下のコマンドで時間を合わせる

# ntpdate ntp.nict.jp
 9 Jul 10:18:36 ntpdate[8383]: step time server 133.243.238.244 offset 108402.649465 sec

実行結果

エラー対応後の実行結果

roles_response {
  roles: "admin"
  roles: "user"
  roles: "money_creator"
}
query_hash: "9b27f830f9a388590a9131f7960b4d3aca8908614cc89fa6631c11d5365196b8"
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1