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

embed gravity bridge module #11

Merged
merged 8 commits into from
Aug 20, 2021
Merged

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Aug 16, 2021

Closes #9

  • add gravity module to app
  • verify address format at application level
  • fix pystarport config files
  • replace keyring with patched version extracted to separated PR
  • build orchestrator in nix
  • add a gravity hook implementation template in cronos module.
  • add gravity custom gentx command

Testing will be done in another PR.

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

@yihuang yihuang marked this pull request as draft August 16, 2021 03:40
@yihuang yihuang changed the title embed gravity bridge embed gravity bridge module Aug 16, 2021
// AddrLen is the allowed length (in bytes) for an address.
//
// NOTE: In the SDK, the default value is 255.
AddrLen = 20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why changing this? in 0.43, there are 32-byte addresses (e.g. if one uses a different signing algorithm)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/PeggyJV/gravity-bridge/blob/main/module/app/app.go#L104

gravity seems to require this, not sure if it works without it. I guess it need to map any potential cosmos address to ethereum.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PeggyJV/gravity-bridge#143

Opened issue to gravity, I guess it's possible to only do the verification at module level.

@codecov
Copy link

codecov bot commented Aug 16, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@c29fee3). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##             main     #11   +/-   ##
======================================
  Coverage        ?   3.75%           
======================================
  Files           ?      12           
  Lines           ?    1145           
  Branches        ?       0           
======================================
  Hits            ?      43           
  Misses          ?    1101           
  Partials        ?       1           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c29fee3...106ed59. Read the comment docs.

app/app.go Outdated Show resolved Hide resolved
@yihuang yihuang force-pushed the gravity branch 4 times, most recently from 8881053 to 875eb01 Compare August 16, 2021 06:41
@yihuang yihuang marked this pull request as ready for review August 16, 2021 07:14
@yihuang yihuang requested a review from JayT106 as a code owner August 16, 2021 07:14
go.mod Outdated
@@ -24,3 +25,5 @@ require (
replace google.golang.org/grpc => google.golang.org/grpc v1.33.2

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we expect more dashes in the chain id, then perhaps using this:
https://github.com/crypto-org-chain/keyring/commits/v1.1.6-fixes which includes @leejw51crypto 's patch for the linux secret service in keyring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted the keyring change to standalone PR.

}

aTx, err := clientCtx.TxConfig.TxJSONDecoder()(bz)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might just return aTx, err directly instead of check err here.

Copy link
Collaborator Author

@yihuang yihuang Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks

@@ -1,5 +1,5 @@
chainmaind-777:
cmd: ./build/ethermintd
cronos-777:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing d?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, since it's chain id here, maybe we shouldn't add the d, I removed the d in the other chain-ids.

@yihuang yihuang force-pushed the gravity branch 2 times, most recently from 263e287 to 0c345a1 Compare August 17, 2021 04:57
@@ -11,6 +11,19 @@
"url": "https://github.com/tweag/gomod2nix/archive/67f22dd738d092c6ba88e420350ada0ed4992ae8.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"gravity-bridge": {
"branch": "main",
"description": "A CosmosSDK application for moving assets on and off of EVM based, POW chains",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gravity bridge supports only Cosmos <-> Ethereum at the moment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it means transfer to and from EVM chain?

@yihuang
Copy link
Collaborator Author

yihuang commented Aug 18, 2021

The embed on the cosmos side seems fine, I've managed call set-delegate-keys and deployed gravity contract successfully. The only issue is the address derivation in orchestrator need to use eth style.

In the newer commit I changed the gentx command back to the one from cosmos-sdk, the reason is:

  • it works with existing tools like pystarport
  • there is standalone set-delegate-keys command, we can call that after cosmos network is up and running

I also added scripts to help to setup gravity locally, the procedure is roughly like this:

  • start up cronos network as usual: pystarport serve --config scripts/devnet.yaml
  • in another terminal run: ./scripts/set-delegate-keys.sh, it'll add and initialize the delegator keys.
  • clone gravity bridge repo and enter solidity directory
    • start ethereum network: npm run evm
    • build gravity contract: npm run typechain
    • deploy gravity contract, run:
      npx ts-node contract-deployer.ts \
        --cosmos-node="http://localhost:26657" \
        --eth-node="http://localhost:8545" \
        --eth-privkey="0xb1bab011e03a9862664706fc3bbaa1b16651528e5f0e7fbfcbfdd8be302a13e7" \
        --contract=./artifacts/contracts/Gravity.sol/Gravity.json \
        --test-mode=true
      
    • send some ether to the validator ethereum accounts
  • start orchestrator
    orchestrator --cosmos-phrase="mnemonic words" --ethereum-key=$ETH_ADDR --cosmos-grpc=http://localhost:26653 --address-prefix=eth --ethereum-rpc=http://localhost:8545 --fees=basetcro --contract-address=0xB48095a68501bC157654d338ce86fdaEF4071B24
    

Closes #9

- add gravity module to app
- verify address format at application level
- fix pystarport config files
- build orchestrator in nix
- add a gravity hook implementation template in cronos module
- add gravity custom gentx command

fix chain id and err handling code

add eth_keys command
since we can always do set-delegate-keys later
@yihuang
Copy link
Collaborator Author

yihuang commented Aug 20, 2021

Simulation test succeed, the module embedding itself should be good, I'm merging this one now.
Orchestrator almost runs, there are still some errors need to investigate, will do that integration test in another PR.
PeggyJV/gravity-bridge#150

@yihuang yihuang merged commit 1b05e10 into crypto-org-chain:main Aug 20, 2021
@yihuang yihuang deleted the gravity branch August 20, 2021 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: gravity bridge module is not embed
5 participants