cryptiumlabs / backerei

Automated reward payment & account management for Tezos bakers.
https://cryptium.ch/networks/tezos
GNU General Public License v3.0
49 stars 11 forks source link

Error while running backerei payout #62

Closed ghost closed 4 years ago

ghost commented 4 years ago

Dear Cryptium Labs, I have built my node in archive mode and I am willing to use backerei.

I have run the init, see my backerei.yaml file (I have hidden my baker address):

babylonStartingCycle: 160 fees: -- 238 - denominator: 25 numerator: 2 fromAddress: tz1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx fromAccountName: jga-baker1 databasePath: /home/tezos/.backerei.json cycleLength: 4096 clientPath: /usr/local/bin/tezos-client preservedCycles: 5 clientConfigFile: /home/tezos/.tezos-client/config startingCycle: 238 host: 127.0.0.1 snapshotInterval: 512 payoutDelay: 0 payEstimatedRewards: true bakerAddress: tz1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx port: 8732

As starting cycle, I've put the first cycle I have baked/endorsed a block (as mentioned in the documentation).

When I run "backerei payout", I am getting the following errror : Enter source account password: Creating new DB in file /home/tezos/.backerei.json... Updating DB with estimates for cycle 238... backerei: should not happen

Please note that I am using a Ledger Nano S to bake. I have the baking app opened all the time and therefore I'm unable to transfer fund since I don't have Tezos Wallet running, I'm guessing it could be an issue? Do I need another Ledger Nano with the Tezos Wallet opened and from where I send rewards to my delegators?

Can you please assist?

Many thanks,

nicolasochem commented 4 years ago

I see the same issue with a baker I'm setting up. I tried several existing baker addresses, they all give this error. Somehow, only cryptium labs and a handful of others seem to work.

The error comes from this line:

https://github.com/cryptiumlabs/backerei/blob/master/src/Backerei/Delegation.hs#L24

nicolasochem commented 4 years ago

The problem:

https://github.com/cryptiumlabs/backerei/blob/master/src/Backerei/Delegation.hs#L17

  delegators <- RPC.delegatedContracts config snapshotBlockHash delegate

With some backers hash passed as parameter, this call returns the baker pubkey hash itself as part of the list of delegators. In some other bakers (like cryptium), it does not. The program expect that the baker's hash NOT be part of the list.

What is expected is that the key should not be there, otherwise calculations don't match and the program crashes, so I need to delete it when it's present.

So what is needed, is to filter out the baker hash when it appears here.

I tried to import delete function from data.List and do:

  delegators <- delete delegate (RPC.delegatedContracts config snapshotBlockHash delegate)  

But I get

/home/nochem/workspace/backerei/src/Backerei/Delegation.hs:17:34-89: error:
    • Couldn't match expected type ‘[T.Text]’
                  with actual type ‘IO [T.Text]’
    • In the second argument of ‘delete’, namely
        ‘(RPC.delegatedContracts config snapshotBlockHash delegate)’
      In a stmt of a 'do' block:
        delegators <- delete
                        delegate (RPC.delegatedContracts config snapshotBlockHash delegate)
      In the expression:
        do snapshotBlockHash <- snapshotHash
                                  config cycle cycleLength snapshotInterval
           delegators <- delete
                           delegate (RPC.delegatedContracts config snapshotBlockHash delegate)
           T.putStrLn
             $ T.concat ["delegator list ", T.pack $ P.show delegators]
           balances <- mapM
                         (RPC.balanceAt config snapshotBlockHash) delegators
           ....
   |
17 |   delegators <- delete delegate (RPC.delegatedContracts config snapshotBlockHash delegate)
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It seems that the data is of type IO and not Text, can I get some expert Haskell help here?