Skip to content

Commit

Permalink
Merge pull request #33 from svub/submit-pubkey
Browse files Browse the repository at this point in the history
feat: End-to-end request via custom EVM Gateway.sol on Ethereum Local Network to custom Relayer to custom Secret contract on Localsecret with response back and then to NunyaBusiness.sol
  • Loading branch information
ltfschoen authored Jan 3, 2025
2 parents 0c2e638 + ec1f5bb commit d47ef14
Show file tree
Hide file tree
Showing 154 changed files with 17,136 additions and 2,898 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ node_modules
# cli
dist

# logs
logs/
ethlocal.service.log
secret.service.log
secret-docker.log
relayer.service.log
run.log

**/node_modules/
**/yarn-error.log
Expand All @@ -31,11 +37,14 @@ logs/
.nx/cache
tsconfig.tsbuildinfo
.env
packages/secret-upload-contract/.env
packages/secret-contracts-scripts/.env
packages/secret-instantiate-contract/.env

## ignore different deployments while we are in dev (comment this once contracts stable)
packages/nextjs/contracts/deployedContracts.ts

## NB hardhat ignores are in packages/hardhat/.gitignore

# yq files
yq.1
install-man-page.sh
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "relayer"]
path = packages/relayer/SecretPath
url = [email protected]:ltfschoen/SecretPath.git
branch = nunya
894 changes: 0 additions & 894 deletions .yarn/releases/yarn-4.2.2.cjs

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.5.3.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ nmHoistingLimits: workspaces

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.2.2.cjs
yarnPath: .yarn/releases/yarn-4.5.3.cjs
2 changes: 0 additions & 2 deletions _DEMO_AND_VIDEO.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
* Video of Nunya.business compile, upload, and instantiate a SecretPath Public Gateway Contract to Sepolia Ethereum Testnet.
[YouTube Link](https://youtu.be/O0unCWsrKA4)
* It successfully also deploys NunyaBusiness contract since we added `secretContract = IGateway(gateway);` to use an interface based on Gateway.sol instead of the old DummyGatewayContract interface file.
* Note: The Gateway was deployed with tx: 0x848763e137d97ea53000f360fa27db943f47a13e4e03982320d72dec33478e36 to address 0x41E52332e76988AFBc38280583a7A02492177C65
* Note: The NunyaContract was deployed with tx:

* Video of Nunya.business frontend integration [video](./assets/demo.mp4)
36 changes: 36 additions & 0 deletions _MAINTAINER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Maintainer Only

Note applicable if you do not maintain the repository.

### Setup Github SSH Keys
* Generate Github SSH keys on remote machine. Copy the output to Github SSH Keys https://github.com/settings/keys
```bash
apt-get install -y xclip && \
ssh-keygen -y -t rsa -f ~/.ssh/id_rsa -P "" && \
cat ~/.ssh/id_rsa.pub
```

### Remove Gitsubmodule

* Remove submodule from ./.git/config
* Other changes
```bash
git rm -r --cached ./packages/relayer
rm -rf ./.git/modules/
rm -rf ./packages/relayer/
rm ./.gitmodules
git restore --staged .gitmodules
git ls-files --stage | grep 160000
```

### Setup Gitsubmodule

* Note: The path argument must match the output of `git ls-files --stage | grep 160000`, and it should include the repository name at the end

```bash
git config --local --add checkout.defaultRemote origin
git config status.submodulesummary 1
git submodule add -b nunya --name relayer -- [email protected]:ltfschoen/SecretPath.git packages/relayer/SecretPath
git submodule status
git ls-files --stage | grep 160000
```
500 changes: 359 additions & 141 deletions _SETUP.md

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions _UNSORTED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
## Unsorted

The below is unfinished work that may not be necessary anymore.

### WIP - SecretCLI <a id="run-secret-cli"></a>

Enter Secret Development Docker container to interact manually with SecretCLI:

```bash
docker exec -it secretdev /bin/bash
secretcli --help
secretcli keys list
ls /root/.secretd/config
```

* IGNORE - Transfer some Localhost Ethereum tokens from a default account like `Account #0` that is shown when running Ethereum Localhost to an Ethereum wallet address associated with the private key `ETH_DEVELOPMENT_PRIVATE_KEY`.
```
Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000 ETH)
privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
```

* TODO - is this necessary? why not just use the default account?

* Transfer some Localhost Secret tokens from a default account that is shown when running Secret Localhost (e.g. secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03) to that Secret wallet address (e.g. secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg).
* Reference: https://docs.scrt.network/secret-network-documentation/infrastructure/secret-cli/configuration

```
docker exec -it secretdev /bin/bash
secretcli config view
secretcli config set client node tcp://localhost:26657
secretcli config set client chain-id secretdev-1
secretcli config set client output json
secretcli config set client keyring-backend test
secretcli config view client --output-format json
secretcli config home
secretcli query bank balances secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03 | jq
secretcli query bank balances secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg | jq
```
* Note: Configuration is stored in /root/.secretd/config/client.toml
* Note: `keyring-backend` is where the keys are stored from possible options including: (os|file|kwallet|pass|test|memory)
* Note: We need the 300000uscrt to process the broadcast the `submitRequestValue` transaction from the relayer, so give them more than that.
* Note: If you forget to do this before running the relayer, then you might get error `[SCRT Interface: ERROR] Failed to fetch account info: HTTP 404`
```
secretcli tx bank send secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03 secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg 100000000000000000uscrt -y
secretcli query bank balances secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg | jq
```

* Note: This is necessary because the default account only has a mnemonic phrase, not a private key.

* IGNORE
```
a_mnemonic="grant rice replace explain federal release fix clever romance raise often wild taxi quarter soccer fiber love must tape steak together observe swap guitar"
echo $a_mnemonic | secretcli keys add account --recover
secretcli keys show account
# it should output `secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03`
b_mnemonic="jelly shadow frog dirt dragon use armed praise universe win jungle close inmate rain oil canvas beauty pioneer chef soccer icon dizzy thunder meadow"
echo $b_mnemonic | secretcli keys add account2 --recover
secretcli keys show account2
# it should output `secret1fc3fzy78ttp0lwuujw7e52rhspxn8uj52zfyne`
custom_mnemonic="<INSERT_MNEMONIC_PHRASE>"
echo $custom_mnemonic | secretcli keys add custom --hd-path="m/44'/60'/0'/0" --recover
secretcli keys show custom
```
* IGNORE
* TODO - why doesn't the wallet address recovered with `custom_mnemonic` match the one that was generated with MyCrypto when recovering it with that mnemonic phrase? is it possible to recover with the private key instead so it recovers the correct wallet address?
* Note: Used `m/44'/60'/0'/0` since that was the default HD path chosen when generating the wallet in MyCrypto for use with Metamask that uses BIP44 derivation, where the HD path is defined as `m / purpose' / coin_type' / account' / change / address_index`
References:
* https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
* https://ethereum.stackexchange.com/questions/19055/what-is-the-difference-between-m-44-60-0-0-and-m-44-60-0
* Note: The `coin_type` is `529` for Secret Network by default, but we generated it using MyCrypto for Ether, which is `60`
References:
* https://help.keplr.app/articles/how-to-set-a-custom-derivation-path
* TODO
* https://github.com/scrtlabs/SecretNetwork/issues/1690
* https://github.com/scrtlabs/SecretNetwork/issues/1689
59 changes: 59 additions & 0 deletions deployed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"data": {
"relayer": {
"path": "/root/nunya/packages/relayer"
},
"evm": {
"network": "localhost",
"localhost": {
"chainId": "31337",
"endpoint": "http://127.0.0.1:8545",
"nunyaBusinessContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"gatewayContractAddress": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
},
"sepolia": {
"chainId": "11155111",
"endpoint": "",
"nunyaBusinessContractAddress": "0xAFFF311821C3F3AF863C7103BB17BDC1Ba04603D",
"gatewayContractAddress": "0x1E4B12A9F82b33DA1127B27861EFf5E652de7a6F"
}
},
"secret": {
"network": "localhost",
"testnet": {
"chainId": "",
"endpoint": "",
"secretNunya": {
"nunyaContractCodeId": "",
"nunyaContractCodeHash": "",
"nunyaContractAddress": ""
},
"secretGateway": {
"gatewayContractCodeId": "",
"gatewayContractAddress": "",
"gatewayContractCodeHash": "",
"gatewayContractAdminAddress": "",
"gatewayContractPublicKey": "",
"gatewayContractEncryptionKeyForChaChaPoly1305": ""
}
},
"localhost": {
"chainId": "secretdev-1",
"endpoint": "http://127.0.0.1:1317",
"secretNunya": {
"nunyaContractCodeId": "2",
"nunyaContractCodeHash": "57f4f72804e180100c7108282fc46fa6275bee92829a3faa9e18526c9105948e",
"nunyaContractAddress": "secret1gyruqan6yxf0q423t8z5zce3x7np35uw8s8wqc"
},
"secretGateway": {
"gatewayContractCodeId": "1",
"gatewayContractAddress": "secret1mfk7n6mc2cg6lznujmeckdh4x0a5ezf6hx6y8q",
"gatewayContractCodeHash": "be3db4b4c42d33300eee7801769a4176ed3046f23c08812fc2a85bc76075e1d5",
"gatewayContractAdminAddress": "secret1glfedwlusunwly7q05umghzwl6nf2vj6wr38fg",
"gatewayContractPublicKey": "0x047c4f7a52a10c051639ec0edd3e2d44fef02d993de6b8412273a78ca67f9c10c66069161d67278de0c74c501de435335163d6b7c5a22abae70e49d83a2b3debbd",
"gatewayContractEncryptionKeyForChaChaPoly1305": "A3xPelKhDAUWOewO3T4tRP7wLZk95rhBInOnjKZ/nBDG"
}
}
}
}
}
87 changes: 0 additions & 87 deletions logs/instantiateOutput.log

This file was deleted.

16 changes: 16 additions & 0 deletions logs_secret/deployGatewayEthereumLocalhost.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Generating typings for: 9 artifacts in dir: typechain-types for target: ethers-v6
Successfully generated 20 typings!
Compiled 9 Solidity files successfully (evm target: paris).
network: localhost
chain id: 31337
deployerAddress: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Deployer account balance: 10000.0 ETH
deploying "NunyaBusiness" (tx: 0x932f4c98ac26557cf674d48ae941d2d5d4b402bdf05a2e54ab8f25bbc61ed5c0)...: deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3 with 2871810 gas
Successfully deployed NunyaBusiness to address: 0x5FbDB2315678afecb367f032d93F642f64180aa3
deploying "Gateway" (tx: 0x21d9641b416d1a45d6d7454155129f258c66ed4dd74276f9494f9d608fa78162)...: deployed at 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 with 3337714 gas
Successfully deployed Gateway to address: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
setGatewayAddressTx tx hash: 0xe87ded4e0e64d7a0872e7120a2cea2e1be91190d7ac1d762f6e0d13e69aa4caf
👋 Nunya contract: 0x5FbDB2315678afecb367f032d93F642f64180aa3
NunyaBusiness balance: 0.000500000000021
Gateway balance: 0.000099999999979
📝 Updated TypeScript contract definition file on ../nextjs/contracts/deployedContracts.ts
16 changes: 16 additions & 0 deletions logs_secret/deployGatewayEthereumSepolia.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Generating typings for: 9 artifacts in dir: typechain-types for target: ethers-v6
Successfully generated 20 typings!
Compiled 9 Solidity files successfully (evm target: paris).
network: sepolia
chain id: 11155111
hre.network.name: sepolia
deployerAddress: 0x83De04f1aad8ABF1883166B14A29c084b7B8AB59
Deployer account balance: 6.938448757518362804 ETH
deploying "NunyaBusiness" (tx: 0x95ce8c146374df85ce0f0f5425e65a2e33092a74b972495c005fa038fe094d33)...: deployed at 0xAFFF311821C3F3AF863C7103BB17BDC1Ba04603D with 2871810 gas
Successfully deployed NunyaBusiness to address: 0xAFFF311821C3F3AF863C7103BB17BDC1Ba04603D
deploying "Gateway" (tx: 0x0c5c2b097801afec5518d3714095569b7df2a53dcde0802c192d036dbd95a66a)...: deployed at 0x1E4B12A9F82b33DA1127B27861EFf5E652de7a6F with 3337833 gas
Successfully deployed Gateway to address: 0x1E4B12A9F82b33DA1127B27861EFf5E652de7a6F
setGatewayAddressTx tx hash: 0xefc300507bbddb3ca95dc178d95b857a3771fd0a0334626f036edfe6ffda4343
👋 Nunya contract: 0xAFFF311821C3F3AF863C7103BB17BDC1Ba04603D
NunyaBusiness balance: 0.0005
Gateway balance: 0.0
Loading

0 comments on commit d47ef14

Please sign in to comment.