Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 151 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ members = [
"tesseract/consensus/relayer",
"tesseract/consensus/polygon",
"tesseract/consensus/tendermint",
"tesseract/consensus/proof-indexer",


# Airdrop
Expand Down Expand Up @@ -350,6 +351,7 @@ tesseract-grandpa = { path = "tesseract/consensus/grandpa" }
tesseract-consensus = { path = "tesseract/consensus/relayer" }
tesseract-polygon = { path = "tesseract/consensus/polygon" }
tesseract-tendermint = { path = "tesseract/consensus/tendermint" }
proof-indexer = { path = "tesseract/consensus/proof-indexer" }


[workspace.dependencies.codec]
Expand Down
2 changes: 1 addition & 1 deletion evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "ISC",
"description": "",
"dependencies": {
"@hyperbridge/core": "^1.6.0",
"@hyperbridge/core": "file:../sdk/packages/core",
"@openzeppelin/contracts": "^5.4.0",
"@polytope-labs/solidity-merkle-trees": "^0.4.0",
"@uniswap/swap-router-contracts": "^1.3.1",
Expand Down
10 changes: 5 additions & 5 deletions evm/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions evm/src/consensus/BeefyV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from "./Types.sol";
import {StateMachine} from "@hyperbridge/core/libraries/StateMachine.sol";
import {IConsensus, IntermediateState, StateCommitment} from "@hyperbridge/core/interfaces/IConsensus.sol";
import {IConsensusV2} from "@hyperbridge/core/interfaces/IConsensusV2.sol";

import {MerkleMultiProof} from "@polytope-labs/solidity-merkle-trees/src/MerkleMultiProof.sol";
import {MerkleMountainRange} from "@polytope-labs/solidity-merkle-trees/src/MerkleMountainRange.sol";
Expand All @@ -46,7 +47,7 @@ import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
* @notice This verifies secp256k1 signatures and authority set membership merkle proofs
* in order to confirm newly finalized states of the Hyperbridge blockchain.
*/
contract BeefyV1 is IConsensus, ERC165 {
contract BeefyV1 is IConsensus, IConsensusV2, ERC165 {
using HeaderImpl for Header;

// The PayloadId for the mmr root.
Expand Down Expand Up @@ -80,7 +81,25 @@ contract BeefyV1 is IConsensus, ERC165 {
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IConsensus).interfaceId || super.supportsInterface(interfaceId);
return interfaceId == type(IConsensus).interfaceId || interfaceId == type(IConsensusV2).interfaceId
|| super.supportsInterface(interfaceId);
}

function verify(bytes memory previousState, bytes memory proof)
external
pure
returns (bytes memory, IntermediateState[] memory, uint256)
{
BeefyConsensusState memory consensusState = abi.decode(previousState, (BeefyConsensusState));
(RelayChainProof memory relay, ParachainProof memory parachain) =
abi.decode(proof, (RelayChainProof, ParachainProof));

uint256 prevNextAuthoritySetId = consensusState.nextAuthoritySet.id;
(BeefyConsensusState memory newState, IntermediateState[] memory intermediates) =
verifyConsensus(consensusState, BeefyConsensusProof(relay, parachain));

uint256 newEpoch = newState.nextAuthoritySet.id > prevNextAuthoritySetId ? newState.nextAuthoritySet.id : 0;
return (abi.encode(newState), intermediates, newEpoch);
}

function verifyConsensus(bytes memory encodedState, bytes memory encodedProof)
Expand Down
Loading
Loading