Skip to content

Commit 5b93b8b

Browse files
authored
[evm]: introduce support for tron (#652)
1 parent e9cf98d commit 5b93b8b

75 files changed

Lines changed: 8384 additions & 959 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ target
44
!target/release/tesseract
55
!target/release/telemetry-server
66
!target/release/hyperbridge
7+
!target/release/polyhedron
78

89
.github
910
.cargo

.github/workflows/evm.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
- uses: actions/checkout@v3
3838
with:
3939
submodules: recursive
40+
token: ${{ secrets.GH_TOKEN }}
41+
ref: ${{ github.event.pull_request.head.sha }}
4042

4143
- uses: pnpm/action-setup@v2
4244
with:
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Polyhedron Docker Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "polyhedron-v[0-9]+.[0-9]+.[0-9]+"
7+
8+
concurrency:
9+
group: release-polyhedron-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
TELEMETRY_SECRET_KEY: ${{ secrets.TELEMETRY_SECRET_KEY }}
14+
15+
jobs:
16+
build_and_publish:
17+
runs-on: release-runner
18+
steps:
19+
- name: Checkout sources
20+
uses: actions/checkout@v3
21+
with:
22+
token: ${{ secrets.GH_TOKEN }}
23+
submodules: recursive
24+
25+
- name: Download SVM Releases List
26+
run: |
27+
wget -O /tmp/svm_releases_list.json https://raw.githubusercontent.com/nikitastupin/solc/2287d4326237172acf91ce42fd7ec18a67b7f512/linux/aarch64/list.json
28+
echo "SVM_RELEASES_LIST_JSON=/tmp/svm_releases_list.json" >> $GITHUB_ENV
29+
30+
- uses: webfactory/ssh-agent@v0.5.4
31+
with:
32+
ssh-private-key: "${{ secrets.SSH_KEY }}"
33+
34+
- name: Install toolchain
35+
uses: dtolnay/rust-toolchain@nightly
36+
with:
37+
toolchain: stable
38+
39+
- name: Install dependencies
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y clang netcat wget curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config libsnappy-dev
43+
44+
- name: Build polyhedron
45+
run: |
46+
cargo build --release --bin polyhedron
47+
48+
- name: Install Cargo get
49+
run: cargo install cargo-get
50+
51+
- name: Login to Docker Hub
52+
uses: docker/login-action@v3
53+
with:
54+
username: ${{ secrets.DOCKER_USERNAME }}
55+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
56+
57+
- name: Build the Docker image
58+
run: docker build -t polytopelabs/polyhedron:v$(cargo get package.version --entry ./tesseract/consensus/relayer) -t polytopelabs/polyhedron:latest -f ./scripts/docker/polyhedron.Dockerfile .
59+
60+
- name: Docker Push
61+
run: |
62+
docker push polytopelabs/polyhedron:v$(cargo get package.version --entry ./tesseract/consensus/relayer)
63+
docker push polytopelabs/polyhedron:latest

Cargo.lock

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ members = [
9595
"tesseract/messaging/substrate",
9696
"tesseract/messaging/relayer",
9797
"tesseract/messaging/evm",
98+
"tesseract/messaging/tron",
9899
"tesseract/messaging/evm-tendermint",
99100
"tesseract/messaging/substrate-evm",
100101
"tesseract/messaging/fees",
@@ -313,6 +314,7 @@ tesseract-fisherman = { path = "tesseract/messaging/fisherman" }
313314
tesseract-substrate = { path = "tesseract/messaging/substrate" }
314315
tesseract-substrate-evm = { path = "tesseract/messaging/substrate-evm" }
315316
tesseract-evm = { path = "tesseract/messaging/evm" }
317+
tesseract-tron = { path = "tesseract/messaging/tron" }
316318
tesseract-evm-tendermint = { path = "tesseract/messaging/evm-tendermint" }
317319
tesseract = { path = "tesseract/messaging/relayer" }
318320
transaction-fees = { path = "tesseract/messaging/fees" }

docs/content/developers/evm/contract-addresses/testnet.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@ The current testnet environment for the Hyperbridge network.
138138
| `ConsensusStateId` | `SEI0` |
139139
| `StateMachine` | `EVM-1328` |
140140

141+
### Tron Nile
142+
143+
144+
| `TronHost` | [`TNduR7v184pMWv2oTamRxxzsmz7oHrKqJc`](https://nile.tronscan.org/#/contract/TNduR7v184pMWv2oTamRxxzsmz7oHrKqJc) |
145+
|:------------|:-----|
146+
| `HandlerV1` | [`TVu5adsYw2CRHrgXwKKdfPR1qYdtA4hFRG`](https://nile.tronscan.org/#/contract/TVu5adsYw2CRHrgXwKKdfPR1qYdtA4hFRG) |
147+
| `ConsensusRouter` | [`TPXBv4ALJKKRPSVDKygPja4EoE25e96yew`](https://nile.tronscan.org/#/contract/TPXBv4ALJKKRPSVDKygPja4EoE25e96yew) |
148+
| `BeefyV1FiatShamir` | [`TH8oxJmHaLSXVHxvM7s4bEEED1yHPG9PYy`](https://nile.tronscan.org/#/contract/TH8oxJmHaLSXVHxvM7s4bEEED1yHPG9PYy) |
149+
| `HostManager` | [`TUyim7389oUZVyZBz1cpFJ63BBWwBEeFKe`](https://nile.tronscan.org/#/contract/TUyim7389oUZVyZBz1cpFJ63BBWwBEeFKe) |
150+
| `CallDispatcher` | [`TA9XyBPuXL9ecXcLpcFV1g778fzstke2Eh`](https://nile.tronscan.org/#/contract/TA9XyBPuXL9ecXcLpcFV1g778fzstke2Eh) |
151+
| `IntentGatewayV2` | [`TT4CjjHw7QgLbE9wKtYEopid1YqePkbAfb`](https://nile.tronscan.org/#/contract/TT4CjjHw7QgLbE9wKtYEopid1YqePkbAfb) |
152+
| `ConsensusStateId` | `TRX0` |
153+
| `StateMachine` | `EVM-3448148188` |
141154

142155

143156
## Gargantua V2 (Paseo) (Deprecated)

evm/script/DeployHostUpdates.s.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import "../src/core/HandlerV1.sol";
1212

1313
import {SP1Beefy} from "../src/consensus/SP1Beefy.sol";
1414
import {SP1Verifier} from "@sp1-contracts/v5.0.0/SP1VerifierGroth16.sol";
15-
import {MultiProofClient} from "../src/consensus/MultiProofClient.sol";
15+
import {ConsensusRouter} from "../src/consensus/ConsensusRouter.sol";
1616
import {IConsensus} from "@hyperbridge/core/interfaces/IConsensus.sol";
1717

1818
contract DeployScript is BaseScript {
@@ -31,8 +31,9 @@ contract DeployScript is BaseScript {
3131
SP1Beefy sp1 = new SP1Beefy{salt: salt}(verifier, sp1VerificationKey);
3232
console.log("SP1Beefy deployed at:", address(sp1));
3333

34-
MultiProofClient consensusClient = new MultiProofClient{salt: salt}(IConsensus(sp1), IConsensus(beefyV1));
35-
console.log("MultiProofClient deployed at:", address(consensusClient));
34+
ConsensusRouter consensusClient =
35+
new ConsensusRouter{salt: salt}(IConsensus(sp1), IConsensus(beefyV1), IConsensus(address(0)));
36+
console.log("ConsensusRouter deployed at:", address(consensusClient));
3637

3738
// Update host params if not mainnet
3839
bool isMainnet = config.get("is_mainnet").toBool();

evm/script/DeployIsmp.s.sol

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "../src/core/EvmHost.sol";
99
import "../src/core/HostManager.sol";
1010

1111
import "../src/consensus/BeefyV1.sol";
12-
import "../src/consensus/MultiProofClient.sol";
12+
import "../src/consensus/ConsensusRouter.sol";
1313
import "../src/hosts/Ethereum.sol";
1414
import "../src/hosts/Arbitrum.sol";
1515
import "../src/hosts/Optimism.sol";
@@ -31,7 +31,7 @@ import {PolkadotHost} from "../src/hosts/Polkadot.sol";
3131
import {SP1Verifier} from "@sp1-contracts/v5.0.0/SP1VerifierGroth16.sol";
3232
import {SP1Beefy} from "../src/consensus/SP1Beefy.sol";
3333
import {BeefyV1} from "../src/consensus/BeefyV1.sol";
34-
import {MultiProofClient} from "../src/consensus/MultiProofClient.sol";
34+
import {ConsensusRouter} from "../src/consensus/ConsensusRouter.sol";
3535
import {IConsensus} from "@hyperbridge/core/interfaces/IConsensus.sol";
3636
import {StateMachine} from "@hyperbridge/core/libraries/StateMachine.sol";
3737
import {FeeToken} from "../test/FeeToken.sol";
@@ -69,12 +69,11 @@ contract DeployScript is BaseScript {
6969
// Deploy BeefyV1 naive consensus client
7070
BeefyV1 beefyV1Client = new BeefyV1{salt: salt}();
7171

72-
// Deploy MultiProofClient wrapping both consensus clients
73-
MultiProofClient multiProofClient = new MultiProofClient{salt: salt}(
74-
IConsensus(address(sp1BeefyClient)),
75-
IConsensus(address(beefyV1Client))
72+
// Deploy ConsensusRouter wrapping both consensus clients
73+
ConsensusRouter consensusRouter = new ConsensusRouter{salt: salt}(
74+
IConsensus(address(sp1BeefyClient)), IConsensus(address(beefyV1Client)), IConsensus(address(address(0)))
7675
);
77-
consensusClient = address(multiProofClient);
76+
consensusClient = address(consensusRouter);
7877

7978
if (isMainnet) {
8079
// use feeToken configured in environment variables

evm/src/consensus/BeefyV1.sol

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,31 @@
1414
// limitations under the License.
1515
pragma solidity ^0.8.17;
1616

17-
import "./Codec.sol";
17+
import {Codec} from "./Codec.sol";
18+
import {Header, HeaderImpl} from "./Header.sol";
19+
import {
20+
Vote,
21+
RelayChainProof,
22+
BeefyConsensusProof,
23+
Commitment,
24+
BeefyConsensusState,
25+
PartialBeefyMmrLeaf,
26+
Parachain,
27+
ParachainProof
28+
} from "./Types.sol";
1829
import {StateMachine} from "@hyperbridge/core/libraries/StateMachine.sol";
1930
import {IConsensus, IntermediateState, StateCommitment} from "@hyperbridge/core/interfaces/IConsensus.sol";
2031

2132
import {MerkleMultiProof} from "@polytope-labs/solidity-merkle-trees/src/MerkleMultiProof.sol";
2233
import {MerkleMountainRange} from "@polytope-labs/solidity-merkle-trees/src/MerkleMountainRange.sol";
2334
import {MerklePatricia} from "@polytope-labs/solidity-merkle-trees/src/MerklePatricia.sol";
24-
import {StorageValue, MmrLeaf} from "@polytope-labs/solidity-merkle-trees/src/Types.sol";
35+
import {Node, StorageValue, MmrLeaf} from "@polytope-labs/solidity-merkle-trees/src/Types.sol";
2536
import {ScaleCodec} from "@polytope-labs/solidity-merkle-trees/src/trie/substrate/ScaleCodec.sol";
2637
import {Bytes} from "@polytope-labs/solidity-merkle-trees/src/trie/Bytes.sol";
2738

2839
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
2940
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
3041

31-
struct Vote {
32-
// secp256k1 signature from a member of the authority set
33-
bytes signature;
34-
// This member's index in the set
35-
uint256 authorityIndex;
36-
}
37-
38-
// The signed commitment holds a commitment to the latest
39-
// finalized state as well as votes from a supermajority
40-
// of the authority set which confirms this state
41-
struct SignedCommitment {
42-
// A commitment to the finalized state
43-
Commitment commitment;
44-
// The confirming votes
45-
Vote[] votes;
46-
}
47-
48-
struct RelayChainProof {
49-
// Signed commitment
50-
SignedCommitment signedCommitment;
51-
// Latest leaf added to mmr
52-
BeefyMmrLeaf latestMmrLeaf;
53-
// Proof for the latest mmr leaf
54-
bytes32[] mmrProof;
55-
// Proof for authorities in current/next session
56-
Node[][] proof;
57-
}
58-
59-
struct BeefyConsensusProof {
60-
// The proof items for the relay chain consensus
61-
RelayChainProof relay;
62-
// Proof items for parachain headers
63-
ParachainProof parachain;
64-
}
65-
6642
/**
6743
* @title The BEEFY Consensus Client.
6844
* @author Polytope Labs (hello@polytope.technology)

0 commit comments

Comments
 (0)