dydxprotocol / dydx-v3-python

Python client for dYdX (API v3)
Apache License 2.0
306 stars 176 forks source link

Onboarding on Sepolia failes #220

Closed kgoderis closed 9 months ago

kgoderis commented 9 months ago

I have a non-python client (i.e. java) implementation that I have upgraded to Sepolia, which in fact just requires a change of the network id and the colleteral assed id. AFAIK there is no change in procedures besides these changes mentioned.

When onboarding a new Ethereum private key a HTTP 500 error is thrown by the server. Restarting the client again with the newly generated Ethereum private key the result is different in the sense that the server seemingly has created the user the first time around, as it reports it does exist, but it does report that the API key is unknown. This makes me believe that something is fishy at the server side

Here is the excerpt with all the keys so that you can potentially verify in your logs:

1st run:

javaclient - 2023-12-11 20:08:17,028 [INFO ] [main] b.a.t.xchange.dydx.dydxExchange : No Ethereum Private Key is provided. We will generate one for you 
javaclient - 2023-12-11 20:08:17,185 [INFO ] [main] b.a.t.xchange.dydx.dydxExchange : Your new Ethereum Private Key is 'c2f3fa7cf3fa9bfaacb2b9e0c53083b80ed839226896035b0b270eb461bf7ef2'. Store this safely 
javaclient - 2023-12-11 20:08:17,185 [INFO ] [main] b.a.t.xchange.dydx.dydxExchange : The matching Ethereum Public Key and Address are 'f3e38c20127569339b4ae6ba6ce6227bad6926405555defda6de4467264565035734afc6287f70021c77ef0867084600c71fe1fba0b7fac3b41daeba605e6677' and '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:08:17,187 [WARN ] [main] b.a.t.xchange.dydx.dydxExchange : The API Key is missing in the Exchange Specification. We will derive the default API Key 
javaclient - 2023-12-11 20:08:17,188 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The matching Ethereum Public Key and Address for the Ethereum Private Key provided are 'f3e38c20127569339b4ae6ba6ce6227bad6926405555defda6de4467264565035734afc6287f70021c77ef0867084600c71fe1fba0b7fac3b41daeba605e6677' and '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:08:17,188 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Ethereum Address required for Ethereum Key Private Endpoints is '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3'. Store this safely 
javaclient - 2023-12-11 20:08:17,200 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Derived API Key for required API Key Private Endpoints is '90d4d41e-813a-a18b-5385-7da981324e0c'. Store this safely 
javaclient - 2023-12-11 20:08:17,200 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Derived API Key Passphrase required for API Key Private Endpoints is 'UfL5c0MSxQ_tK-RuD3n2'. Store this safely 
javaclient - 2023-12-11 20:08:17,200 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Derived API Key Secret required for API Key Private Endpoints is 'i2UMKMdfWSB-oGvsci60YLlhOdhz8TAiE36wzMKf'. Store this safely 
javaclient - 2023-12-11 20:08:17,201 [WARN ] [main] b.a.t.xchange.dydx.dydxExchange : The Stark Key is missing in the Exchange Specification. We will derive the default Stark Key 
javaclient - 2023-12-11 20:08:17,202 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The matching Ethereum Public Key and Address for the Ethereum Private Key provided are 'f3e38c20127569339b4ae6ba6ce6227bad6926405555defda6de4467264565035734afc6287f70021c77ef0867084600c71fe1fba0b7fac3b41daeba605e6677' and '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:08:17,202 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Ethereum Address required for Ethereum Key Private Endpoints is '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3'. Store this safely 
javaclient - 2023-12-11 20:08:17,204 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Stark Private Key is '0x69e0a62bbe4b384cc661547aa1cef3da0520383aee8ed4699ba8710366af281'. Store this safely 
javaclient - 2023-12-11 20:08:17,227 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The coordinates of the Stark Public Key are '56665114f2192025a2e70bc30f2e5e43e9ec683a773098ae08274995667d7b7'/'4a95ad23ae23ab63505b24c6c5aefc25cb67b1713971463d9b256f35d8b0fb0' 
javaclient - 2023-12-11 20:08:17,228 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : Checking if an user exists for Ethereum address '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:08:17,229 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Executing GET request at https://api.stage.dydx.exchange/v3/users/exists?ethereumAddress=0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3 
javaclient - 2023-12-11 20:08:17,545 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Request http status = 200 
javaclient - 2023-12-11 20:08:17,546 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Http call returned 200; response body:
{**"exists":false,**"isProxySigner":false,"contractAddress":""} 
javaclient - 2023-12-11 20:08:17,550 [WARN ] [main] b.a.t.xchange.dydx.dydxExchange : The dydxUser is missing in the Exchange Specification. We will onboard to create a dydxUser 
javaclient - 2023-12-11 20:08:17,551 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The matching Ethereum Public Key and Address for the Ethereum Private Key provided are 'f3e38c20127569339b4ae6ba6ce6227bad6926405555defda6de4467264565035734afc6287f70021c77ef0867084600c71fe1fba0b7fac3b41daeba605e6677' and '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:08:17,551 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Ethereum Address required for Ethereum Key Private Endpoints is '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3'. Store this safely 
javaclient - 2023-12-11 20:08:17,551 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Stark Private Key is '0x69e0a62bbe4b384cc661547aa1cef3da0520383aee8ed4699ba8710366af281'. Store this safely 
javaclient - 2023-12-11 20:08:17,581 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The coordinates of the Stark Public Key are '56665114f2192025a2e70bc30f2e5e43e9ec683a773098ae08274995667d7b7'/'4a95ad23ae23ab63505b24c6c5aefc25cb67b1713971463d9b256f35d8b0fb0' 
javaclient - 2023-12-11 20:08:17,594 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Executing POST request at https://api.stage.dydx.exchange/v3/onboarding  body 
{"starkKey":"0x56665114f2192025a2e70bc30f2e5e43e9ec683a773098ae08274995667d7b7","starkKeyYCoordinate":"0x4a95ad23ae23ab63505b24c6c5aefc25cb67b1713971463d9b256f35d8b0fb0"} 
javaclient - 2023-12-11 20:08:19,734 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Request http status = 500 
javaclient - 2023-12-11 20:08:19,735 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Http call returned 500; response body:
{"errors":[{"msg":"**Internal Server Error**"}]} 

2nd run:

javaclient - 2023-12-11 20:09:42,628 [WARN ] [main] b.a.t.xchange.dydx.dydxExchange : The API Key is missing in the Exchange Specification. We will derive the default API Key 
javaclient - 2023-12-11 20:09:42,628 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The matching Ethereum Public Key and Address for the Ethereum Private Key provided are 'f3e38c20127569339b4ae6ba6ce6227bad6926405555defda6de4467264565035734afc6287f70021c77ef0867084600c71fe1fba0b7fac3b41daeba605e6677' and '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:09:42,628 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Ethereum Address required for Ethereum Key Private Endpoints is '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3'. Store this safely 
javaclient - 2023-12-11 20:09:42,644 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Derived API Key for required API Key Private Endpoints is '90d4d41e-813a-a18b-5385-7da981324e0c'. Store this safely 
javaclient - 2023-12-11 20:09:42,644 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Derived API Key Passphrase required for API Key Private Endpoints is 'UfL5c0MSxQ_tK-RuD3n2'. Store this safely 
javaclient - 2023-12-11 20:09:42,644 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Derived API Key Secret required for API Key Private Endpoints is 'i2UMKMdfWSB-oGvsci60YLlhOdhz8TAiE36wzMKf'. Store this safely 
javaclient - 2023-12-11 20:09:42,645 [WARN ] [main] b.a.t.xchange.dydx.dydxExchange : The Stark Key is missing in the Exchange Specification. We will derive the default Stark Key 
javaclient - 2023-12-11 20:09:42,645 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The matching Ethereum Public Key and Address for the Ethereum Private Key provided are 'f3e38c20127569339b4ae6ba6ce6227bad6926405555defda6de4467264565035734afc6287f70021c77ef0867084600c71fe1fba0b7fac3b41daeba605e6677' and '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:09:42,645 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Ethereum Address required for Ethereum Key Private Endpoints is '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3'. Store this safely 
javaclient - 2023-12-11 20:09:42,647 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The Stark Private Key is '0x69e0a62bbe4b384cc661547aa1cef3da0520383aee8ed4699ba8710366af281'. Store this safely 
javaclient - 2023-12-11 20:09:42,676 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : The coordinates of the Stark Public Key are '56665114f2192025a2e70bc30f2e5e43e9ec683a773098ae08274995667d7b7'/'4a95ad23ae23ab63505b24c6c5aefc25cb67b1713971463d9b256f35d8b0fb0' 
javaclient - 2023-12-11 20:09:42,678 [INFO ] [main] b.a.t.x.d.s.dydxOnboardingService : Checking if an user exists for Ethereum address '0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3' 
javaclient - 2023-12-11 20:09:42,679 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Executing GET request at https://api.stage.dydx.exchange/v3/users/exists?ethereumAddress=0x20b1a3e5b958b663bc7cd9d7103c701d64c488e3 
javaclient - 2023-12-11 20:09:43,050 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Request http status = 200 
javaclient - 2023-12-11 20:09:43,051 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Http call returned 200; response body:
{**"exists":true**,"isProxySigner":false,"contractAddress":""} 
javaclient - 2023-12-11 20:09:43,065 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Executing GET request at https://api.dydx.exchange/v3/time 
javaclient - 2023-12-11 20:09:43,316 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Request http status = 200 
javaclient - 2023-12-11 20:09:43,316 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Http call returned 200; response body:
{"iso":"2023-12-11T19:09:43.201Z","epoch":1702321783.201} 
javaclient - 2023-12-11 20:09:43,325 [DEBUG] [main] b.a.t.x.dydx.dydxTimestampFactory : deltaServerTime: 2023-12-11 20:09:43:201 - 2023-12-11 20:09:43:324 => -123 
javaclient - 2023-12-11 20:09:43,329 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Executing GET request at https://api.stage.dydx.exchange/v3/users 
javaclient - 2023-12-11 20:09:43,570 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Request http status = 400 
javaclient - 2023-12-11 20:09:43,571 [DEBUG] [main] si.mazi.rescu.HttpTemplate : Http call returned 400; response body:
{"errors":[{"msg":"**API key not found**"}]} 
prd-tuong-nguyen commented 9 months ago

same problem

dydx3.errors.DydxApiError: DydxApiError(status_code=400, response={'errors': [{'msg': 'API key not found'}]})
kgoderis commented 9 months ago

For me the issue was resolved around 9AM CET

sirEven commented 9 months ago

same problem


dydx3.errors.DydxApiError: DydxApiError(status_code=400, response={'errors': [{'msg': 'API key not found'}]})

Have you replaced the keys with new ones? They are not the same anymore as on GOERLI.

prd-tuong-nguyen commented 9 months ago

same problem


dydx3.errors.DydxApiError: DydxApiError(status_code=400, response={'errors': [{'msg': 'API key not found'}]})

Have you replaced the keys with new ones? They are not the same anymore as on GOERLI.

Thank you, seem dydx migraing to new network, change API key work for me

sirEven commented 9 months ago

Hello, which scritp are you using to onboard a user, I want to create using API but all API require client and to create client I need STARK Key and API credentials.

There is abundant info online to get the necessary credentials for dydx v3 client out of developer view of your browser when being logged into dydx frontend. Basically you inspect the app storage and copy paste corresponding stark and api credentials out of there - just make sure to not store them somewhere, that is committed to git or shared otherwise!

kgoderis commented 9 months ago

This can be closed. It seems that there was a time gap between the change of the level 2 network and the update (?) of the webservice sitting in front of it