ergoplatform / oracle-core

Core off-chain component of Oracle Pools
Apache License 2.0
62 stars 37 forks source link

Ignore `Not enough boxes to spend` node error, but keep wallet out of coins error #220

Closed greenhat closed 1 year ago

greenhat commented 1 year ago
2023-01-13T06:28:52.125639036+02:00 DEBUG oracle_core - Height 226558. Building action for command: PublishSubsequentDataPoint { republish: false }
2023-01-13T06:28:52.516734688+02:00 INFO oracle_core::actions - Datapoint published successfully, tx id: "9c9ff079dd734c03fdfbecd8b22c72a55d41655c386466bcbeb50aee1ea75794"
2023-01-13T06:29:22.558433190+02:00 DEBUG oracle_core::state - Height 226559. Live epoch state: LiveEpochState { pool_box_epoch_id: 4425, local_datapoint_box_state: Some(Collected { height: 226552 }), latest_pool_datapoint: 1052188552188, latest_pool_box_height: 226552 }
2023-01-13T06:29:22.558494310+02:00 DEBUG oracle_core - Height 226559. Building action for command: PublishSubsequentDataPoint { republish: false }
2023-01-13T06:29:22.724916409+02:00 DEBUG oracle_core::actions - Node rejected tx with error: Double spending attempt
2023-01-13T06:29:52.763507854+02:00 DEBUG oracle_core::state - Height 226559. Live epoch state: LiveEpochState { pool_box_epoch_id: 4425, local_datapoint_box_state: Some(Collected { height: 226552 }), latest_pool_datapoint: 1052188552188, latest_pool_box_height: 226552 }
2023-01-13T06:29:52.763570134+02:00 DEBUG oracle_core - Height 226559. Building action for command: PublishSubsequentDataPoint { republish: false }
2023-01-13T06:29:52.986781288+02:00 ERROR oracle_core - error: node error: Node error: The node rejected the request you provided.
Node Response: Malformed request: Not enough boxes to spend
2023-01-13T06:30:23.028897333+02:00 DEBUG oracle_core::state - Height 226561. Live epoch state: LiveEpochState { pool_box_epoch_id: 4425, local_datapoint_box_state: Some(Posted { epoch_id: 4425, height: 226558 }), latest_pool_datapoint: 1052188552188, latest_pool_box_height: 226552 }
2023-01-13T06:30:53.071274177+02:00 DEBUG oracle_core::state - Height 226562. Live epoch state: LiveEpochState { pool_box_epoch_id: 4425, local_datapoint_box_state: Some(Posted { epoch_id: 4425, height: 226558 }), latest_pool_datapoint: 1052188552188, latest_pool_box_height: 226552 }
2023-01-13T06:31:23.118494629+02:00 DEBUG oracle_core::state - Height 226562. Live epoch state: LiveEpochState { pool_box_epoch_id: 4425, local_datapoint_box_state: Some(Posted { epoch_id: 4425, height: 226558 }), latest_pool_datapoint: 1052188552188, latest_pool_box_height: 226552 }
2023-01-13T06:31:53.156609533+02:00 DEBUG oracle_core::state - Height 226562. Live epoch state: LiveEpochState { pool_box_epoch_id: 4425, local_datapoint_box_state: Some(Posted { epoch_id: 4425, height: 226558 }), latest_pool_datapoint: 1052188552188, latest_pool_box_height: 226552 }
reqlez commented 1 year ago

How would this be accomplished?

Do you put date/time for the last "Datapoint published successfully" in some variable and then check if it's been more than X minutes since last "Datapoint published successfully" then okay to output "Not enough boxes to spend" or do you have another idea?

I could work on this one since I need something to work on :)

Maybe we can use this with some API endpoint later to show "isHealthy" status for the oracle?

greenhat commented 1 year ago

This error "not enough boxes to spend" is thrown when the node cannot find all the input boxes because the previous tx already spent some of them (tx was included in the block after oracle asked the node's wallet for unspent boxes the prepare the new tx). I believe we can ignore it completely because when the wallet is out of coins, we should fail much earlier when we build the tx in the oracle. It'd be great if you could simulate a node running out of coins with log_level: TRACE.