valory-xyz/trader-quickstart

[Staking] Uninformative error when running staked service without using the `--with-staking` flag

Closed this issue · 4 comments

The following error occurs when running a staked service without the --with-staking flag:

awk: cmd. line:1: warning: regexp escape sequence `\"' is not a known regexp operator
[Agent instance] Swapping Safe owner...
  - Starting swap_safe_owner.py script...
  - Safe address: 0xF785587eDF543DcBE3AF53444a17f0f1C1Dc0Ab1
  - Current owner: 0x5764AD53a2063D5b230758Cc44B1B699F0798eFF
  - New owner: 0x86B1cc666486822fBfED7CEb6a2cCFf1C4917dBd
  - Loading contracts...
  - Building Safe.swapOwner transaction...
  - Signing Safe.swapOwner transaction...
  - Safe.swapOwner transaction sent. Transaction hash: 0xc4142ff4e67fabde43e8923dcbab95f771f165708be490e25462328faceafe9f
  - Waiting for transaction receipt...
  - Safe.swapOwner transaction successfully mined.
  - Safe owner successfully swapped from 0x5764AD53a2063D5b230758Cc44B1B699F0798eFF to 0x86B1cc666486822fBfED7CEb6a2cCFf1C4917dBd
[Service owner] Terminating on-chain service 191...
[2023-11-13 15:41:58,123][WARNING] Unable to estimate gas with default state , ValueError: {'code': -32015, 'message': 'Reverted 0xa43d6ada00000000000000000000000086b1cc666486822fbfed7ceb6a2ccff1c4917dbd0000000000000000000000005add592ce0a1b5dcecebb5dcac086cd9f9e3ea5c'}
Error: Service termination failed; {'code': -32015, 'message': 'Reverted 0xa43d6ada00000000000000000000000086b1cc666486822fbfed7ceb6a2ccff1c4917dbd0000000000000000000000005add592ce0a1b5dcecebb5dcac086cd9f9e3ea5c'}

In order to improve the UX we should provide a more informative error message.
@0xArdi maybe we could even add a check and if the service is staked but the flag was not used, then terminate early and inform the user.

It is also worth noting that reruning the script with the flag does not help and a manual intervention is then required.

Perhaps this error could be prevented as follows:

  1. On first run, ask the user if they want to use staking or not on this service.
  2. Save the value in the store staking=true / false.
  3. On each run, the user does not need to use any flag. The script will recover the value from the store.

Additionally, for legacy users using the --use-staking flag:

  1. Upon starting the script, save staking=true on the store.
  2. Display an informative message telling that the flag is no longer needed, and press a key to continue.
  3. Run the rest of the script.

For now i'd keep it simple and just store the mode ("staking"). If the user runs the second time and the specified flag/lack of flag does not match the stored mode the execution can be interrupted and the user can be asked for confirmation whether to continue with the mode or switch

After thinking a bit, this solution is in fact more difficult to implement (requires more logic to address missmatch between flag and stored value). I will implement the original proposal, and if it causes issues, we can consider the second option.

Addressed in #99