Skip to content

Commit

Permalink
Port the bnb chain to be integrated as a second chain.
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitryhil committed Jan 31, 2023
1 parent 255e7ca commit 338605b
Show file tree
Hide file tree
Showing 39 changed files with 1,106 additions and 1,037 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/automated-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./orchestrator/target/x86_64-unknown-linux-musl/release/gbt
asset_name: gbt
asset_name: arcbnbbt
asset_content_type: application/bin

- name: Upload Rust test runner
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
# because of https://github.com/cross-rs/cross/issues/724
# we have to run `cargo clean` between targets

- name: Build GBT ARM64
- name: Build ARCBNBBT ARM64
run: |
cd orchestrator
cargo clean
Expand All @@ -232,10 +232,10 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./orchestrator/target/aarch64-unknown-linux-musl/release/gbt
asset_name: gbt-arm
asset_name: arcbnbbt-arm
asset_content_type: application/bin

- name: Build GBT Windows
- name: Build ARCBNBBT Windows
run: |
cd orchestrator
cargo clean
Expand All @@ -249,10 +249,10 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./orchestrator/target/x86_64-pc-windows-gnu/release/gbt.exe
asset_name: gbt.exe
asset_name: arcbnbbt.exe
asset_content_type: application/bin

- name: Build GBT Mac
- name: Build ARCBNBBT Mac
run: |
sudo apt install \
clang \
Expand Down Expand Up @@ -289,5 +289,5 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./orchestrator/target/x86_64-apple-darwin/release/gbt
asset_name: gbt-mac-amd64
asset_name: arcbnbbt-mac-amd64
asset_content_type: application/bin
75 changes: 75 additions & 0 deletions module-porting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Overview

That instructions describe the steps to port the original arc module to a different chain to make it possible to use
multiple module in the same chain.

This doc is written for the `bnb` chain integration, if you use another, replace the `bnb` to `your-chain` in that doc.

# Steps

## Module

* Change the module name in the `module/x/gravity/types/keys.go` `ModuleName = "gravity"` to `ModuleName = "arcbnb"`.

* Rename the folder `module/proto/gravity` to `module/proto/arcbnb`.

* Replace string `package gravity.v1;` to `package arcbnb.v1;` in folder `module/proto/arcbnb`.

* Replace string `gravity/v1` to `arcbnb/v1` in folder in folder `module/proto/arcbnb`.

* Open the `module` in the CLI and execute `make proto-gen`.

* Run the tests if the `module`, open the `moduel` in the CLI and execute `make test`.

* Update `proto-check-breaking` goal in the `Makefile`, updated the `#branch=main` to `#branch=bnb`

## Solidity

* Replace `/custom/gravity` to `/custom/arcbnb` in the `solidity` folder.

## Orchestrator

* Replace `.gbt` to `.arcbnbbt` in `orchestrator` folder (!!! Case sensitive !!!).

* Replace `proto/gravity` to `proto/arcbnb` in the `orchestrator` folder.

* Open `orchestrator/proto_build` in CLI and run `cargo run` to generate new rust proto client.

* Add `gravity_proto/src/prost/arcbnb.v1.rs` to git.

* Replace `prost/gravity.v1.rs` to `prost/arcbnb.v1.rs` in the `orchestrator/gravity_proto/lib.rs`

* Replace `gravity.v1` to `arcbnb.v1` in the all `orchestrator` files.

* Replace `subspace: "gravity"` to `subspace: "arcbnb"` in the all `orchestrator` files.

* Open `orchestrator` in the CLI and run `cargo fmt --all` to format the code.

* Open `orchestrator` in the CLI and run `cargo build --all && cargo test --all` to check the unit tests.

## Denom prefixes

* Update `pub const GRAVITY_DENOM_PREFIX: &str = "eth"` to `pub const GRAVITY_DENOM_PREFIX: &str = "bnb"` in
the `orchestrator/gravity_utils/src/lib.rs`

* Update `GravityDenomPrefix = "eth"` to `GravityDenomPrefix = "bnb"` in the `module/x/gravity/types/ethereum.go`

## Run tests

Open `tests` in the CLI and execute `USE_LOCAL_ARTIFACTS=1 bash all-up-test.sh HAPPY_PATH_V2`. If the happy path passes
you can run all tests `USE_LOCAL_ARTIFACTS=1 bash run-all-tests.sh`.

## Workflows

* Replace `GBT` to `ARCBNBBT` (!!! Case sensitive !!!) in
the [automated-release.yml](.github/workflows/automated-release.yml).

* Replace `eth2` to `bnb` (!!! Case sensitive !!!) in
the [automated-release.yml](.github/workflows/automated-release.yml).

* Replace `asset_name: gbt` to `asset_name: arcbnbbt` (!!! Case sensitive !!!) in
the [automated-release.yml](.github/workflows/automated-release.yml).

* Update the `main` branch to `bnb` in all `.github` workflows.

* Create PR to the `bnb` branch. (The `breakage` test will fail first time, that is expected).
2 changes: 1 addition & 1 deletion module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ proto-lint:
@$(DOCKER_BUF) lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against "https://github.com/onomyprotocol/arc.git#branch=main,subdir=module"
@$(DOCKER_BUF) breaking --against "https://github.com/onomyprotocol/arc.git#branch=bnb,subdir=module"

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc3/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package gravity.v1;
package arcbnb.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";
package gravity.v1;
package arcbnb.v1;

import "gogoproto/gogo.proto";
import "gravity/v1/attestation.proto";
import "arcbnb/v1/attestation.proto";

option go_package = "github.com/onomyprotocol/arc/module/x/gravity/types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package gravity.v1;
package arcbnb.v1;
import "gogoproto/gogo.proto";
option go_package = "github.com/onomyprotocol/arc/module/x/gravity/types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";
package gravity.v1;
package arcbnb.v1;

import "gogoproto/gogo.proto";
import "gravity/v1/types.proto";
import "gravity/v1/msgs.proto";
import "gravity/v1/batch.proto";
import "gravity/v1/attestation.proto";
import "arcbnb/v1/types.proto";
import "arcbnb/v1/msgs.proto";
import "arcbnb/v1/batch.proto";
import "arcbnb/v1/attestation.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/onomyprotocol/arc/module/x/gravity/types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
syntax = "proto3";
package gravity.v1;
package arcbnb.v1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "gravity/v1/types.proto";
import "arcbnb/v1/types.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
option go_package = "github.com/onomyprotocol/arc/module/x/gravity/types";

// Msg defines the state transitions possible within gravity
service Msg {
rpc ValsetConfirm(MsgValsetConfirm) returns (MsgValsetConfirmResponse) {
option (google.api.http).post = "/gravity/v1/valset_confirm";
option (google.api.http).post = "/arcbnb/v1/valset_confirm";
}
rpc SendToEth(MsgSendToEth) returns (MsgSendToEthResponse) {
option (google.api.http).post = "/gravity/v1/send_to_eth";
option (google.api.http).post = "/arcbnb/v1/send_to_eth";
}
rpc RequestBatch(MsgRequestBatch) returns (MsgRequestBatchResponse) {
option (google.api.http).post = "/gravity/v1/request_batch";
option (google.api.http).post = "/arcbnb/v1/request_batch";
}
rpc ConfirmBatch(MsgConfirmBatch) returns (MsgConfirmBatchResponse) {
option (google.api.http).post = "/gravity/v1/confirm_batch";
option (google.api.http).post = "/arcbnb/v1/confirm_batch";
}
rpc ConfirmLogicCall(MsgConfirmLogicCall) returns (MsgConfirmLogicCallResponse) {
option (google.api.http).post = "/gravity/v1/confim_logic";
option (google.api.http).post = "/arcbnb/v1/confim_logic";
}
rpc SendToCosmosClaim(MsgSendToCosmosClaim) returns (MsgSendToCosmosClaimResponse) {
option (google.api.http).post = "/gravity/v1/send_to_cosmos_claim";
option (google.api.http).post = "/arcbnb/v1/send_to_cosmos_claim";
}
rpc BatchSendToEthClaim(MsgBatchSendToEthClaim) returns (MsgBatchSendToEthClaimResponse) {
option (google.api.http).post = "/gravity/v1/batch_send_to_eth_claim";
option (google.api.http).post = "/arcbnb/v1/batch_send_to_eth_claim";
}
rpc ValsetUpdateClaim(MsgValsetUpdatedClaim) returns (MsgValsetUpdatedClaimResponse) {
option (google.api.http).post = "/gravity/v1/valset_updated_claim";
option (google.api.http).post = "/arcbnb/v1/valset_updated_claim";
}
rpc ERC20DeployedClaim(MsgERC20DeployedClaim)
returns (MsgERC20DeployedClaimResponse) {
option (google.api.http).post = "/gravity/v1/erc20_deployed_claim";
option (google.api.http).post = "/arcbnb/v1/erc20_deployed_claim";
}
rpc LogicCallExecutedClaim(MsgLogicCallExecutedClaim)
returns (MsgLogicCallExecutedClaimResponse) {
option (google.api.http).post = "/gravity/v1/logic_call_executed_claim";
option (google.api.http).post = "/arcbnb/v1/logic_call_executed_claim";
}
rpc SetOrchestratorAddress(MsgSetOrchestratorAddress) returns (MsgSetOrchestratorAddressResponse) {
option (google.api.http).post = "/gravity/v1/set_orchestrator_address";
option (google.api.http).post = "/arcbnb/v1/set_orchestrator_address";
}
rpc CancelSendToEth(MsgCancelSendToEth) returns (MsgCancelSendToEthResponse) {
option (google.api.http).post = "/gravity/v1/cancel_send_to_eth";
option (google.api.http).post = "/arcbnb/v1/cancel_send_to_eth";
}
rpc SubmitBadSignatureEvidence(MsgSubmitBadSignatureEvidence) returns (MsgSubmitBadSignatureEvidenceResponse) {
option (google.api.http).post = "/gravity/v1/submit_bad_signature_evidence";
option (google.api.http).post = "/arcbnb/v1/submit_bad_signature_evidence";
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package gravity.v1;
package arcbnb.v1;

import "gogoproto/gogo.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
syntax = "proto3";
package gravity.v1;

import "gravity/v1/genesis.proto";
import "gravity/v1/types.proto";
import "gravity/v1/msgs.proto";
import "gravity/v1/pool.proto";
import "gravity/v1/batch.proto";
import "gravity/v1/attestation.proto";
package arcbnb.v1;

import "arcbnb/v1/genesis.proto";
import "arcbnb/v1/types.proto";
import "arcbnb/v1/msgs.proto";
import "arcbnb/v1/pool.proto";
import "arcbnb/v1/batch.proto";
import "arcbnb/v1/attestation.proto";
import "google/api/annotations.proto";
import "gogoproto/gogo.proto";

Expand All @@ -16,74 +16,74 @@ option go_package = "github.com/onomyprotocol/arc/module/x/gravity/types";
service Query {
// Deployments queries deployments
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/gravity/v1beta/params";
option (google.api.http).get = "/arcbnb/v1beta/params";
}
rpc CurrentValset(QueryCurrentValsetRequest) returns (QueryCurrentValsetResponse) {
option (google.api.http).get = "/gravity/v1beta/valset/current";
option (google.api.http).get = "/arcbnb/v1beta/valset/current";
}
rpc ValsetRequest(QueryValsetRequestRequest) returns (QueryValsetRequestResponse) {
option (google.api.http).get = "/gravity/v1beta/valset";
option (google.api.http).get = "/arcbnb/v1beta/valset";
}
rpc ValsetConfirm(QueryValsetConfirmRequest) returns (QueryValsetConfirmResponse) {
option (google.api.http).get = "/gravity/v1beta/valset/confirm";
option (google.api.http).get = "/arcbnb/v1beta/valset/confirm";
}
rpc ValsetConfirmsByNonce(QueryValsetConfirmsByNonceRequest) returns (QueryValsetConfirmsByNonceResponse) {
option (google.api.http).get = "/gravity/v1beta/confirms/{nonce}";
option (google.api.http).get = "/arcbnb/v1beta/confirms/{nonce}";
}
rpc LastValsetRequests(QueryLastValsetRequestsRequest) returns (QueryLastValsetRequestsResponse) {
option (google.api.http).get = "/gravity/v1beta/valset/requests";
option (google.api.http).get = "/arcbnb/v1beta/valset/requests";
}
rpc LastPendingValsetRequestByAddr(QueryLastPendingValsetRequestByAddrRequest) returns (QueryLastPendingValsetRequestByAddrResponse) {
option (google.api.http).get = "/gravity/v1beta/valset/last";
option (google.api.http).get = "/arcbnb/v1beta/valset/last";
}
rpc LastPendingBatchRequestByAddr(QueryLastPendingBatchRequestByAddrRequest) returns (QueryLastPendingBatchRequestByAddrResponse) {
option (google.api.http).get = "/gravity/v1beta/batch/{address}";
option (google.api.http).get = "/arcbnb/v1beta/batch/{address}";
}
rpc LastPendingLogicCallByAddr(QueryLastPendingLogicCallByAddrRequest) returns (QueryLastPendingLogicCallByAddrResponse) {
option (google.api.http).get = "/gravity/v1beta/logic/{address}";
option (google.api.http).get = "/arcbnb/v1beta/logic/{address}";
}
rpc LastEventNonceByAddr(QueryLastEventNonceByAddrRequest) returns (QueryLastEventNonceByAddrResponse) {
option (google.api.http).get = "/gravity/v1beta/oracle/eventnonce/{address}";
option (google.api.http).get = "/arcbnb/v1beta/oracle/eventnonce/{address}";
}
rpc BatchFees(QueryBatchFeeRequest) returns (QueryBatchFeeResponse) {
option (google.api.http).get = "/gravity/v1beta/batchfees";
option (google.api.http).get = "/arcbnb/v1beta/batchfees";
}
rpc OutgoingTxBatches(QueryOutgoingTxBatchesRequest) returns (QueryOutgoingTxBatchesResponse) {
option (google.api.http).get = "/gravity/v1beta/batch/outgoingtx";
option (google.api.http).get = "/arcbnb/v1beta/batch/outgoingtx";
}
rpc OutgoingLogicCalls(QueryOutgoingLogicCallsRequest) returns (QueryOutgoingLogicCallsResponse) {
option (google.api.http).get = "/gravity/v1beta/batch/outgoinglogic";
option (google.api.http).get = "/arcbnb/v1beta/batch/outgoinglogic";
}
rpc BatchRequestByNonce(QueryBatchRequestByNonceRequest) returns (QueryBatchRequestByNonceResponse) {
option (google.api.http).get = "/gravity/v1beta/batch/{nonce}";
option (google.api.http).get = "/arcbnb/v1beta/batch/{nonce}";
}
rpc BatchConfirms(QueryBatchConfirmsRequest) returns (QueryBatchConfirmsResponse) {
option (google.api.http).get = "/gravity/v1beta/batch/confirms";
option (google.api.http).get = "/arcbnb/v1beta/batch/confirms";
}
rpc LogicConfirms(QueryLogicConfirmsRequest) returns (QueryLogicConfirmsResponse) {
option (google.api.http).get = "/gravity/v1beta/logic/confirms";
option (google.api.http).get = "/arcbnb/v1beta/logic/confirms";
}
rpc ERC20ToDenom(QueryERC20ToDenomRequest) returns (QueryERC20ToDenomResponse) {
option (google.api.http).get = "/gravity/v1beta/cosmos_originated/erc20_to_denom";
option (google.api.http).get = "/arcbnb/v1beta/cosmos_originated/erc20_to_denom";
}
rpc DenomToERC20(QueryDenomToERC20Request) returns (QueryDenomToERC20Response) {
option (google.api.http).get = "/gravity/v1beta/cosmos_originated/denom_to_erc20";
option (google.api.http).get = "/arcbnb/v1beta/cosmos_originated/denom_to_erc20";
}
rpc GetAttestations(QueryAttestationsRequest) returns (QueryAttestationsResponse) {
option (google.api.http).get = "/gravity/v1beta/query_attestations";
option (google.api.http).get = "/arcbnb/v1beta/query_attestations";
}
rpc GetDelegateKeyByValidator(QueryDelegateKeysByValidatorAddress) returns (QueryDelegateKeysByValidatorAddressResponse) {
option (google.api.http).get = "/gravity/v1beta/query_delegate_keys_by_validator";
option (google.api.http).get = "/arcbnb/v1beta/query_delegate_keys_by_validator";
}
rpc GetDelegateKeyByEth(QueryDelegateKeysByEthAddress) returns (QueryDelegateKeysByEthAddressResponse) {
option (google.api.http).get = "/gravity/v1beta/query_delegate_keys_by_eth";
option (google.api.http).get = "/arcbnb/v1beta/query_delegate_keys_by_eth";
}
rpc GetDelegateKeyByOrchestrator(QueryDelegateKeysByOrchestratorAddress) returns (QueryDelegateKeysByOrchestratorAddressResponse) {
option (google.api.http).get = "/gravity/v1beta/query_delegate_keys_by_orchestrator";
option (google.api.http).get = "/arcbnb/v1beta/query_delegate_keys_by_orchestrator";
}

rpc GetPendingSendToEth(QueryPendingSendToEth) returns (QueryPendingSendToEthResponse) {
option (google.api.http).get = "/gravity/v1beta/query_pending_send_to_eth";
option (google.api.http).get = "/arcbnb/v1beta/query_pending_send_to_eth";
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package gravity.v1;
package arcbnb.v1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/bank/v1beta1/bank.proto";
import "gogoproto/gogo.proto";
Expand Down
Loading

0 comments on commit 338605b

Please sign in to comment.