KomodoPlatform / komodo-defi-framework

This is the official Komodo DeFi Framework repository
https://komodoplatform.com/en/docs/komodo-defi-framework/
99 stars 89 forks source link

Add support for Energy Web Network and EWT #723

Closed karasugoi closed 1 year ago

karasugoi commented 3 years ago

Energy Web Tokens (EWT) operate on their own network similar to Ethereum. https://www.energyweb.org/technology/energy-web-chain/ The energy industry is likely to go forward with this in our future as it enables VPP (virtual power plants). AtomicDEX should embrace the future and this will help it gain traction and relevancy.

artemii235 commented 3 years ago

@karasugoi Hi! Thanks for opening the issue! As EWT seems to be Ethereum "fork" the task to integrate it might be quite simple: all we need is to deploy the etomic swap smart contract to their network and setup a RPC node (or use community provided). However I'm unsure if we have free resources for this right now, let me clarify it with team.

karasugoi commented 3 years ago

I am willing to pay KMD as a bounty to get this integrated. Please advise what the team thinks. Supporting this may well help the future of our planet. The rewards we will reap can not be overestimated.

artemii235 commented 3 years ago

@karasugoi Thanks for your suggestion!

I've discussed this topic with team and happy to announce that we assign 500 KMD bounty for this task! The requirements are as follows:

  1. Deploy the 1.0 release of EtomicSwap contract to EWT mainnet: https://github.com/artemii235/etomic-swap/releases/tag/1.0.
  2. Setup the EWT full node with public RPC API enabled. Provide detailed instructions how to setup the node. The best way will be create a Dockerfile with all required configuration, but it is not mandatory.
  3. Perform a EWT swap with any other supported coin using AtomicDEX and provide transaction links on explorer.
  4. Provide coins config sample and example of EWT AtomicDEX-API activation command.
dth88 commented 3 years ago

@karasugoi @artemii235 thanks for the awesome task. I'll make it work and in the meantime will do some research on what those virtual power plants are :)

dth88 commented 3 years ago

@artemii235 So... currently, since I do not have any EWT to actually deploy to mainnet, I decided to try all the process on Volta-testnet first (ticker - VT) provided by EWF team (https://github.com/energywebfoundation).

  1. here's deployed smart contract on Volta: https://explorer.anyblock.tools/ethereum/ewf/volta/address/0x6DA66BAEE9aaCE12b9E31F0949a1429f8f70FF6E

  2. This is in the process, parity node is syncing second day already, and it seems like no community run nodes are publicly available. Also, EWC/Volta deploy scripts !of docker imgs! are available here for ubuntu 18.04 LTS https://github.com/energywebfoundation/ewf-rpc deployed without any problems.

  3. Successful swap: d29b54ee-fd67-460e-b6eb-9d02f104c7a7 here's swap status json: https://paste.ubuntu.com/p/2W9P8fhVsf/ tx for VT from volta explorer: https://explorer.anyblock.tools/ethereum/ewf/volta/address/0xd46b40c100edb02940c6b1852b5c81aa85ababe2/ rick tx: https://rick.explorer.dexstats.info/tx/d09682fc26a27890df97aefef52a61cf3bcaa5a9e1df06fa525a9b2614b72b3f

  4. adex activation call and coins config entry:

    
    curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"VT\",\"urls\":[\"https://volta-rpc.energyweb.org\"],\"swap_contract_address\":\"0x6DA66BAEE9aaCE12b9E31F0949a1429f8f70FF6E\"}" | python -mjson.tool

{ "coin": "VT", "name": "volta", "fname": "Volta", "rpcport": 80, "mm2": 1, "required_confirmations": 3, "avg_blocktime": 0.25, "protocol": { "type": "ETH" } }



and ofc will repeat all of that on mainnet as soon as parity node syncs fully and I grab some EWT from somewhere :)
dth88 commented 3 years ago

@karasugoi hi! is there anyway you can share some little amount of EWT for contract deployment?

karasugoi commented 3 years ago

I can, sure. Address?

On Fri, Nov 6, 2020 at 1:36 AM Yaroslav notifications@github.com wrote:

@karasugoi https://github.com/karasugoi hi! is there anyway you can share some little amount of EWT for contract deployment?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KomodoPlatform/atomicDEX-API/issues/723#issuecomment-722979606, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJM57IQSAKHR5QJYFQBKK5TSOO7Q3ANCNFSM4RUACJTQ .

dth88 commented 3 years ago

@karasugoi awesome, thanks! here's the address: 0xa6f5b46bD6543447FcCBCC41D87B3dba73B8FF3e parity node is still syncing btw (about 70-80% done) will probably take another day or two.

dth88 commented 3 years ago

@artemii235 Finally found a public node for EWC.

By the time of writing their main explorer seems to be down so transactions might appear in a "pending" state, I found an alternative one which seems to display everything correctly, will add the corresponding links below.

1) Contract address: https://explorer.energyweb.org/address/0x6DA66BAEE9aaCE12b9E31F0949a1429f8f70FF6E/transactions alt: https://explorer.anyblock.tools/ethereum/ewf/ewc/address/0x6DA66BAEE9aaCE12b9E31F0949a1429f8f70FF6E

2) My node is still in the sync process and honestly not sure what causes it to be that slow. Should I continue this or you would prefer for someone else to set it up? Deploy for Ubuntu 18.04 LTS: https://github.com/energywebfoundation/ewf-rpc

3) Successful swap: 157a9be2-a323-4af0-806d-984eb57c4f6a swap.json --> https://paste.ubuntu.com/p/7Db7F3M25R/ Transactions on main explorer: https://explorer.energyweb.org/tx/0xa6e9898f10798a418e652144a7666953fe6f2248c39101deb15b430b175a4646/internal-transactions https://explorer.energyweb.org/tx/0xa8420342eb19d7f7e9b457ac36e46039b953cbdc310a360081da68d9e098b3b1/internal-transactions alt: https://explorer.anyblock.tools/ethereum/ewf/ewc/transaction/0xa8420342eb19d7f7e9b457ac36e46039b953cbdc310a360081da68d9e098b3b1 https://explorer.anyblock.tools/ethereum/ewf/ewc/transaction/0xa6e9898f10798a418e652144a7666953fe6f2248c39101deb15b430b175a4646

4) activation and coins config:

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"EWT\",\"urls\":[\"https://rpc.energyweb.org\"],\"swap_contract_address\":\"0x6DA66BAEE9aaCE12b9E31F0949a1429f8f70FF6E\"}"

{
        "coin": "EWT",
        "name": "energywebtoken",
        "fname": "EnergyWebToken",
        "rpcport": 443,
        "mm2": 1,
        "required_confirmations": 3,
        "avg_blocktime": 0.25,
        "protocol": {
                "type": "ETH"
        }
}

They closed parity API on port 80, so only SSL one works on their public node.

artemii235 commented 3 years ago

My node is still in the sync process and honestly not sure what causes it to be that slow. Should I continue this or you would prefer for someone else to set it up?

It is mandatory requirement to learn how to setup such node to be able to teach someone else from team too.

I recommend to play with node startup arguments, as I understand the EWT network is based on OpenEthereum client that should support warp sync so initial sync should be very fast. It might be that EWT doesn't support warp at all or maybe there're just some startup args that prevent the node from warp syncing.

And looks like here it is: https://github.com/energywebfoundation/ewf-rpc/blob/master/ewc-rpc/install-rpc-ubuntu-server-18.04-ewc.bash#L204, what is the reason to explicitly turn the warp sync off?

dth88 commented 3 years ago

@artemii235 was playing around with arguments for a while last week, I should be able to get it done this week as soon as some free time comes along. FYI, just general observation, the installation script is really weird, to say the least, they seem to try to block users from syncing full nodes. Here's the docker-Nginx setup for example which basically was limiting my sync process with 128kbps, maybe I'm mistaking though since I have not had time to explore everything, but seems weird:

location / {
            proxy_connect_timeout   150;
            proxy_send_timeout      100;
            proxy_read_timeout      100;
            proxy_buffers           4 32k;
            client_max_body_size    8m;
            client_body_buffer_size 128k;
            proxy_pass http://parity:8545;
    }

On the plus side though, I'm learning a lot trying to figure this out, so thanks for insisting on it :)

artemii235 commented 3 years ago

@dathbezumniy The Nginx config shouldn't be related to syncing process, it works as proxy for node RPC API. The separate network connection is used for sync and other P2P communications.

So this config presumably prevents some abuse of node RPC API, but should have no relation to slow syncing process.

dth88 commented 3 years ago

@artemii235 nevermind :) I was way off base with my conclusions before. Turns out just another rookie networking mistake, forgot to forward 30303 xD with warp = true, sync is pretty fast, should be ready soon.

dth88 commented 3 years ago

@artemii235 ok, done. So... warp does not work on this network in an expected way. Alternatively, they just publish DB snapshots which you can extract to an empty node and sync in about 10-15 minutes. https://energyweb.atlassian.net/wiki/spaces/EWF/pages/1013153839/How+to+use+ready-to-go+chain+backup

I have uploaded such DB backup to google cloud (eu-west, Netherlands) and incorporated it into the installation script so it would populate empty DB on startup, now node setup takes somewhere from 30min to an hour depending on bandwidth allocation on the dedicated VM.

I have left one of the nodes running --> http://34.90.173.134:80 And here are the installation instructions --> https://github.com/dathbezumniy/ewc-rpc-node For now, just tested with HTTP, doubt that there are going to be any problems with the SSL. Well... except for the manual generation of the certificate after which we should restart Nginx. Let me know if I can help with anything else here.

dth88 commented 3 years ago

@artemii235 btw, still unclear here, should I leave it on? are we going to move this forward? and most importantly, the bounty? would very much like that 5% interest ;)

artemii235 commented 3 years ago

@dathbezumniy All conditions are met, thanks a lot for working on this! Please DM me your KMD address and I will send you the bounty ASAP. Could you please also submit a PR adding EWT to the coins repo?

@cipig Could you please add EWT nodes following the guides provided by @dathbezumniy?

artemii235 commented 3 years ago

Ah, and 1 more request: @dathbezumniy please verify the swap smart contract on EWT explorer: https://explorer.energyweb.org/address/0x6DA66BAEE9aaCE12b9E31F0949a1429f8f70FF6E/contract_verifications/new.

dth88 commented 3 years ago

@cipig I recently removed the bootstrap of EWT mainnet from my gcloud since it's a bit outdated already, let me update it so you could deploy it without a hassle. @artemii235 will verify the contract and then submit PR into the coins repo, thanks!

cipig commented 3 years ago

I have 2 questions:

dth88 commented 3 years ago

@cipig Parity version is PARITY_VERSION="parity/parity:v2.5.13-stable" (docker img) cache_size = 4092 I suppose you can change it as you prefer but they mentioned that 4GB RAM is minimum requirement.

Here's the script that I've used https://github.com/dathbezumniy/ewc-rpc-node but have not yet uploaded db bootstrap up to gcloud, so you can wait a bit or follow this guide: https://energyweb.atlassian.net/wiki/spaces/EWF/pages/1013153839/How+to+use+ready-to-go+chain+backup

@artemii235 I might need to redeploy current contract, cant find some info to verify it properly.

dth88 commented 3 years ago

updated db bootstrap, please use https://github.com/dathbezumniy/ewc-rpc-node just tested on fresh install of ubuntu 18.04, should work without any problem, deploy of one instance takes around 1 hour.

dth88 commented 3 years ago

redeployed and verified contract: 0x304896fc2F242f13dd852b412E7B60C5F495B79c transactions: https://explorer.energyweb.org/address/0x304896fc2F242f13dd852b412E7B60C5F495B79c/transactions PR: https://github.com/KomodoPlatform/coins/pull/78

dth88 commented 3 years ago

Bounty received, tyvm!

smk762 commented 1 year ago

@dth88 it appears EWT was not added to coins repo. Please resubmit a PR or contact me in Discord to assist. Closing this issue as it appears the integration was completed.

cipig commented 1 year ago

https://chainlist.org/chain/246

cipig commented 1 year ago

https://github.com/KomodoPlatform/coins/pull/740 https://github.com/KomodoPlatform/atomicDEX-Desktop/pull/2272