Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid parameters were provided: Computed payout is greater than total collateral #2131

Closed
holzeis opened this issue Mar 1, 2024 · 4 comments · Fixed by #2158
Closed

Invalid parameters were provided: Computed payout is greater than total collateral #2131

holzeis opened this issue Mar 1, 2024 · 4 comments · Fixed by #2158
Assignees
Labels
bug Something isn't working prod-environment

Comments

@holzeis
Copy link
Contributor

holzeis commented Mar 1, 2024

A user run into this issue, with a stuck pending order now as it seems the offer did not get rejected.

[ERROR] TIME: 2024-02-29T22:31:18.990184Z r: Failed to process incoming DLC message: Failed to handle ChannelOffer message from 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156: Invalid parameters were provided: Computed payout is greater than total collateral from: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156,kind: ChannelOffer

maybe relevant logs around the error

[INFO] TIME: 2024-02-29T22:31:15.792869Z r: Found channel manager data. Recovering from stored state 
[INFO] TIME: 2024-02-29T22:31:15.936618Z Coordinator version: 1.9.0
[INFO] TIME: 2024-02-29T22:31:15.936653Z Client is up to date: 1.9.0
[INFO] TIME: 2024-02-29T22:31:16.870010Z r: Listening on 0.0.0.0:58183 
[DEBUG] TIME: 2024-02-29T22:31:16.870898Z r: Getting all non-pending channels 
[INFO] TIME: 2024-02-29T22:31:16.871169Z r: Starting background processor 
[INFO] TIME: 2024-02-29T22:31:16.871775Z r: Lightning node started with node ID 03317f64131b9d5f8417b61da07f9dfc37e112d2778305770b1f2f581251daffac@0.0.0.0:58183 
[INFO] TIME: 2024-02-29T22:31:16.872079Z r: Keeping RGS snapshot up to date 
[INFO] TIME: 2024-02-29T22:31:16.872768Z r: Requesting RGS gossip update latest_sync_timestamp: 1709240400,rgs_server_url: https://rapidsync.lightningdevkit.org/snapshot/
[DEBUG] TIME: 2024-02-29T22:31:16.873225Z r: Syncing 0 shadow channels 
[DEBUG] TIME: 2024-02-29T22:31:16.874793Z r: Got all transactions transactions: []
[DEBUG] TIME: 2024-02-29T22:31:16.874935Z r: Syncing 0 shadow transactions 
[DEBUG] TIME: 2024-02-29T22:31:16.878042Z r: Got all spendable outputs outputs: []
[DEBUG] TIME: 2024-02-29T22:31:17.179663Z r: lightning_rapid_gossip_sync::processing: Processing RGS update from 1709240400 with 0 nodes, 0 channel announcements and 0 channel updates. 
[INFO] TIME: 2024-02-29T22:31:17.179983Z r: Updated network graph new_latest_sync_timestamp: 1709240400
[DEBUG] TIME: 2024-02-29T22:31:17.195473Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:31:17.195695Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:31:17.196038Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:31:17.196518Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:31:17.358914Z found no subscribers, skipping event
[INFO] TIME: 2024-02-29T22:31:17.359122Z r: Started on-chain sync 
[DEBUG] TIME: 2024-02-29T22:31:17.359294Z r: Setting up connection peer: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156@46.17.98.29:9045
[DEBUG] TIME: 2024-02-29T22:31:17.362175Z r: Connecting to orderbook API 
[DEBUG] TIME: 2024-02-29T22:31:17.363997Z r: Pruning expired orders 
[INFO] TIME: 2024-02-29T22:31:17.364491Z Backend started
[DEBUG] TIME: 2024-02-29T22:31:17.504933Z r: lightning::chain::chainmonitor: New best block 0000000000000000000021c835e2b3ce7487e81e874bd94aab89bebdbc5fe985 at height 832593 provided via best_block_updated 
[DEBUG] TIME: 2024-02-29T22:31:17.517950Z r: Connection setup completed peer: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156@46.17.98.29:9045
[DEBUG] TIME: 2024-02-29T22:31:17.518701Z r: Waiting to confirm established connection peer: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156@46.17.98.29:9045
[DEBUG] TIME: 2024-02-29T22:31:17.685032Z r: lightning::ln::peer_handler: Finished noise handshake for connection with 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156 
[DEBUG] TIME: 2024-02-29T22:31:17.686627Z r: tungstenite::handshake::client: Client handshake done. 
[INFO] TIME: 2024-02-29T22:31:17.686919Z r: Connected to orderbook realtime API 
[DEBUG] TIME: 2024-02-29T22:31:17.701667Z r: Fetched new polls new_polls: 1
[DEBUG] TIME: 2024-02-29T22:31:17.703628Z r: Polls to answer unanswered_polls: 1
[DEBUG] TIME: 2024-02-29T22:31:17.703755Z r: Unanswered polls poll_id: 1
[INFO] TIME: 2024-02-29T22:31:18.496258Z r: lightning::ln::peer_handler: Received peer Init message from 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156: DataLossProtect: required, InitialRoutingSync: not supported, UpfrontShutdownScript: supported, GossipQueries: not supported, VariableLengthOnion: required, StaticRemoteKey: required, PaymentSecret: required, BasicMPP: supported, Wumbo: supported, AnchorsNonzeroFeeHtlcTx: not supported, AnchorsZeroFeeHtlcTx: not supported, ShutdownAnySegwit: supported, Taproot: not supported, OnionMessages: not supported, ChannelType: supported, SCIDPrivacy: supported, ZeroConf: supported, unknown flags: none 
[DEBUG] TIME: 2024-02-29T22:31:18.496675Z r: lightning::ln::channelmanager: Generating channel_reestablish events for 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156 
[INFO] TIME: 2024-02-29T22:31:18.496818Z r: Peer connected! inbound: false,their_node_id: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156
[DEBUG] TIME: 2024-02-29T22:31:18.499131Z r: Sending last dlc message last_outbound_serialized_dlc_message.message_type: CollaborativeCloseOffer,peer: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156
[INFO] TIME: 2024-02-29T22:31:18.519876Z r: Connection established peer: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156@46.17.98.29:9045
[INFO] TIME: 2024-02-29T22:31:18.589620Z r: Successfully logged in to 10101 websocket api! 
[DEBUG] TIME: 2024-02-29T22:31:18.592361Z r: Received all orders from orderbook orders: []
[DEBUG] TIME: 2024-02-29T22:31:18.592440Z r: Updating prices prices: {BtcUsd: Price { bid: Some(61179), ask: Some(61187.5) }}
[INFO] TIME: 2024-02-29T22:31:18.975942Z r: Processing message from: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156,kind: ChannelOffer
[ERROR] TIME: 2024-02-29T22:31:18.990184Z r: Failed to process incoming DLC message: Failed to handle ChannelOffer message from 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156: Invalid parameters were provided: Computed payout is greater than total collateral from: 022ae8dbec1caa4dac93f07f2ebf5ad7a5dd08d375b79f11095e81b065c2155156,kind: ChannelOffer
[INFO] TIME: 2024-02-29T22:31:42.684868Z r: Finished on-chain sync duration: 25314,latest_height: 832593
[DEBUG] TIME: 2024-02-29T22:31:47.075532Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:31:47.075856Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:31:47.075940Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:31:47.075996Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:31:47.779265Z r: Pruning expired orders 
[WARN] TIME: 2024-02-29T22:32:15.134513Z r: Could not remove non-existing order order_id: c2988354-781e-4819-91d2-70e84aac9ba2
[WARN] TIME: 2024-02-29T22:32:15.134886Z r: Could not remove non-existing order order_id: 75af9c8c-98e8-4b38-9a65-3f801240358d
[DEBUG] TIME: 2024-02-29T22:32:15.134999Z r: Updating prices prices: {BtcUsd: Price { bid: Some(61271.5), ask: Some(61187.5) }}
[DEBUG] TIME: 2024-02-29T22:32:16.459737Z r: Updating prices prices: {BtcUsd: Price { bid: Some(61271.5), ask: Some(61278) }}
[DEBUG] TIME: 2024-02-29T22:32:17.040542Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:32:17.040818Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:32:17.045339Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:32:17.045463Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:32:17.779556Z r: Pruning expired orders 
[DEBUG] TIME: 2024-02-29T22:32:47.087964Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:32:47.088232Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:32:47.088491Z r: Response status code 200 OK 
[DEBUG] TIME: 2024-02-29T22:32:47.088591Z r: Successfully uploaded backup of dlc/03/636861696e5f6d6f6e69746f72. 
[DEBUG] TIME: 2024-02-29T22:32:47.780649Z r: Pruning expired orders 
[ERROR] TIME: 2024-02-29T22:32:57.848928Z Failed to submit order: FfiException(RESULT_ERROR, Another order is already being filled: 1500 contracts Long at 5x leverage, null)
[DEBUG] TIME: 2024-02-29T22:33:14.536693Z r: Updating prices prices: {BtcUsd: Price { bid: Some(61321.5), ask: Some(61278) }}
@holzeis
Copy link
Contributor Author

holzeis commented Mar 3, 2024

Maybe reproducible with

execution_price: 62323
leverage: 4
direction: Long
quantity: 1450

[DEBUG] TIME: 2024-03-02T01:01:19.170642Z r: Filling order filled: FilledWith { order_id: 4f2abdc0-d240-4708-986e-b835b9c834a8, expiry_timestamp: 2024-03-10 15:00:00.0 +00:00:00, oracle_pk: XOnlyPublicKey(d09cba02bcd6169ac860a331e3e257486d439c13852a496547dbeffe541f05936e717851071a65cb6524ec35eeb35122473de57ed3986607af5e059678253d4a), matches: [Match { id: 65751a78-ed8d-4e54-89bd-6a25690597fb, order_id: 46a408cc-e882-4adc-bdb3-a202e41ca239, quantity: 1450, pubkey: PublicKey(f62a2af288af5c5d822f7b32534855399eb5bf6d36f8f02df260e042982239424f9b0b51420c0bc6549343bded9b0e3322d0f82c8fa46e87e7640c1fac71577c), execution_price: 62323 }] },order: Order { id: 4f2abdc0-d240-4708-986e-b835b9c834a8, leverage: 4.0, quantity: 1450.0, contract_symbol: BtcUsd, direction: Long, order_type: Market, state: Open, creation_timestamp: 2024-03-02 1:01:18.0 +00:00:00, order_expiry_timestamp: 2024-03-02 1:02:18.0 +00:00:00, reason: Manual, stable: false, failure_reason: None }
[DEBUG] TIME: 2024-03-02T01:01:19.170710Z r: Found channel-opening parameters channel_opening_params: ChannelOpeningParams { order_id: 4f2abdc0-d240-4708-986e-b835b9c834a8, coordinator_reserve: Amount(184467440737.09552002 BTC), trader_reserve: Amount(184467440737.09552002 BTC) }

@bonomat
Copy link
Contributor

bonomat commented Mar 4, 2024

lol, look at the coordinator reserve

 coordinator_reserve: Amount(184467440737.09552002 BTC)

@bonomat
Copy link
Contributor

bonomat commented Mar 4, 2024

It seems to come from an overflow caused by this calculation

final coordinatorReserve =
channelOpeningParams.coordinatorCollateral.sub(coordinatorCollateral);

will result in a negative number.

When past into

pub async fn submit_channel_opening_order(
order: NewOrder,
coordinator_reserve: u64,
trader_reserve: u64,
) -> Result<String> {

we get a nice overflow because the function expects a u64 but in dart we have an int

@holzeis holzeis assigned holzeis and unassigned holzeis Mar 4, 2024
@bonomat
Copy link
Contributor

bonomat commented Mar 5, 2024

Reproducible in release mode.

  1. checkout d86a3f3
  2. just gen ios-release run
  3. open a new channel
  4. check cli for flutter: [DEBUG] TIME: 2024-03-05T00:35:30.722910Z r: Found channel-opening parameters channel_opening_params: ChannelOpeningParams { order_id: 61f7378e-e468-4614-8873-5b9ec4f42b54, coordinator_reserve: Amount(184467440737.09542847 BTC), trader_reserve: Amount(0.00000000 BTC) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prod-environment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants