chaintope / glueby

[WIP] A Ruby library of smart contracts that can be used on Tapyrus.
MIT License
7 stars 10 forks source link

AR::Timestamp syncer does not work #80

Open nakajo2011 opened 3 years ago

nakajo2011 commented 3 years ago

Description

::AR::Timestamp status is not changed after block sync.

The condition of change status to :confirmed is the current status is :unconfirmed. But when we should change to :unconfirmed? I think :confirmed status means is just including block. If that is so, What is :unconfirmed means?

Expected Work

::AR::Timestamp status should be changed to :confirmed after block sync if that tx is included in block.

Execution Logs

Running via Spring preloader in process 84
Loading development environment (Rails 6.1.4)
irb(main):001:0> wallet_id = Glueby::Internal::Wallet::AR::Wallet.first.wallet_id
   (2.3ms)  SELECT sqlite_version(*)
  Glueby::Internal::Wallet::AR::Wallet Load (4.0ms)  SELECT "glueby_wallets".* FROM "glueby_wallets" ORDER BY "glueby_wallets"."id" ASC LIMIT ?  [["LIMIT", 1]]
=> "0f4b0561dea061a6cb4c628aab5c6fc2"
irb(main):002:0> t = Glueby::Contract::AR::Timestamp.new(wallet_id: wallet_id, content: "hoge")
=> 
#<Glueby::Contract::AR::Timestamp:0x00005582fc71b450
...
irb(main):003:0> t.save!
  TRANSACTION (0.1ms)  begin transaction
  Glueby::Contract::AR::Timestamp Create (72.8ms)  INSERT INTO "glueby_timestamps" ("status", "content_hash", "prefix", "wallet_id") VALUES (?, ?, ?, ?)  [["status", 0], ["content_hash", "ecb666d778725ec97307044d642bf4d160aabb76f56c0069c71ea25b1e926825"], ["prefix", ""], ["wallet_id", "0f4b0561dea061a6cb4c628aab5c6fc2"]]
  TRANSACTION (19.0ms)  commit transaction
=> true
irb(main):004:0> Glueby::Contract::AR::Timestamp.all
  Glueby::Contract::AR::Timestamp Load (4.1ms)  SELECT "glueby_timestamps".* FROM "glueby_timestamps"
=> 
[#<Glueby::Contract::AR::Timestamp:0x00005582fdebdc70
  id: 1,
  txid: nil,
  status: "init",
  content_hash: "ecb666d778725ec97307044d642bf4d160aabb76f56c0069c71ea25b1e926825",
  prefix: "",
  wallet_id: "0f4b0561dea061a6cb4c628aab5c6fc2">]
irb(main):005:1* class Helper include GluebyHelper
irb(main):006:0> end
=> Helper
irb(main):007:0> h = Helper.new
=> #<Helper:0x00005582fe56f528>
irb(main):008:0> wallet = Glueby::Wallet.load(wallet_id)
  Glueby::Internal::Wallet::AR::Wallet Exists? (2.8ms)  SELECT 1 AS one FROM "glueby_wallets" WHERE "glueby_wallets"."wallet_id" = ? LIMIT ?  [["wallet_id", "0f4b0561dea061a6cb4c628aab5c6fc2"], ["LIMIT", 1]]
=> #<Glueby::Wallet:0x00005582fdf5d9a0 @internal_wallet=#<Glueby::Internal::Wallet:0x00005582fdf5da90 @id="0f4b0561dea061a6cb4c628aab5c6fc2">>
irb(main):009:0> h.generate_block(wallet)
  Glueby::Internal::Wallet::AR::Wallet Load (3.6ms)  SELECT "glueby_wallets".* FROM "glueby_wallets" WHERE "glueby_wallets"."wallet_id" = ? LIMIT ?  [["wallet_id", "0f4b0561dea061a6cb4c628aab5c6fc2"], ["LIMIT", 1]]
  Glueby::Internal::Wallet::AR::Key Load (4.9ms)  SELECT "glueby_keys".* FROM "glueby_keys" WHERE "glueby_keys"."wallet_id" = ? AND "glueby_keys"."label" = ?  [["wallet_id", 1], ["label", "receive"]]
=> ["d53ddc9806fc9d5e664bd4f5be21987dca2d8fa90d5dc216d50962da95f2980e"]
irb(main):010:0> Glueby::Contract::AR::Timestamp.all
  Glueby::Contract::AR::Timestamp Load (3.5ms)  SELECT "glueby_timestamps".* FROM "glueby_timestamps"
=> 
[#<Glueby::Contract::AR::Timestamp:0x00005582fe38cdc8
  id: 1,
  txid: nil,
  status: "init",
  content_hash: "ecb666d778725ec97307044d642bf4d160aabb76f56c0069c71ea25b1e926825",
  prefix: "",
  wallet_id: "0f4b0561dea061a6cb4c628aab5c6fc2">]
irb(main):011:0> 

Environments

glueby version: revision: 7b345102d153623cf694d0cf051d3b1c5fb0a820 rails version: 6.1.4 ruby version: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

Yamaguchi commented 3 years ago

Have you already execute these tasks?

https://github.com/chaintope/glueby#rails-support