Loopring / hello_loopring

hello_loopring
38 stars 33 forks source link

Wrong ECDSA generated for TestNet (uat2) but right one generated for prod (api3) #22

Closed taranasus closed 2 years ago

taranasus commented 2 years ago

Hi, I've been using this example to create a LoopringAPI C# wrapper so that us non-python folk can have some of that Loopring fun. Link here https://github.com/taranasus/LoopringAPI

https://github.com/Loopring/hello_loopring/blob/0f86004f3695eb5296cad51a086bd360ed4cb1b7/tutorials/transfer/transfer_tutorial.py#L108

I've been using this python repo as the basis and test example. Here's the thing. The code works for production just fine, but for uat2 it generates the wrong ECDSA signature. It happens for both the python code linked above and the C# method i've made linked here: https://github.com/taranasus/LoopringAPI/blob/2bf91fb432907ec68662fb31e4dfbe4e1fe45c6d/LoopringAPI/SecureClient.cs#L539

It's been driving me nuts to try and come to this conclusion, as you'd expect the example code in python to work and I was running under the assumption that I was being dumb. but no.

Can you please have a look at this python example and see why it won't work with uat2, so we all know what went wrong.

taranasus commented 2 years ago

It was the domain channel id. Had it hardcoded to 1 when it should have been pulled from the API, sorry about that

saschlac commented 2 years ago

@taranasus can you elaborate on where the domain channel id is hardcoded to 1? Are you referring to the chainId? We were running into a similar issue yesterday.

taranasus commented 2 years ago

Sorry @saschlac I should have been clearer, I did indeed mean the chain ID. On this line you can see it is set:

https://github.com/Loopring/hello_loopring/blob/0f86004f3695eb5296cad51a086bd360ed4cb1b7/tutorials/transfer/transfer_tutorial.py#L101

With the value from here: https://github.com/Loopring/hello_loopring/blob/0f86004f3695eb5296cad51a086bd360ed4cb1b7/tutorials/transfer/transfer_tutorial.py#L18

And you can see it's set to 5 for the goerli network (uat2 and uat3), but it should be 1 for the real network (api3). I had hardcoded it to 1 in my code and because I'm a noob at this, didn't realize its significance / importance at the time.

I'll be closing this now as my own stupidity a bug in python does not make.