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

Update Aligned to 0.6.0 #336

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion contract/lib/aligned_layer
Submodule aligned_layer updated 491 files
10 changes: 3 additions & 7 deletions contract/script/MinaBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ contract MinaBridgeDeployer is Script {
vm.startBroadcast();

string memory chain = vm.envString("ETH_CHAIN");
address alignedServiceAddress;
address payable alignedServiceAddress;
if (keccak256(bytes(chain)) == keccak256("devnet")) {
alignedServiceAddress = address(
uint160(0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8)
);
alignedServiceAddress = payable(0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8);
} else if (keccak256(bytes(chain)) == keccak256("holesky")) {
alignedServiceAddress = address(
uint160(0x58F280BeBE9B34c9939C3C39e0890C81f163B623)
);
alignedServiceAddress = payable(0x58F280BeBE9B34c9939C3C39e0890C81f163B623);
} else {
revert UndefinedChain();
}
Expand Down
5 changes: 3 additions & 2 deletions contract/src/MinaAccountValidation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract MinaAccountValidation {
/// @notice Reference to the AlignedLayerServiceManager contract.
AlignedLayerServiceManager aligned;

constructor(address _alignedServiceAddr) {
constructor(address payable _alignedServiceAddr) {
aligned = AlignedLayerServiceManager(_alignedServiceAddr);
}

Expand All @@ -33,7 +33,8 @@ contract MinaAccountValidation {
proofGeneratorAddr,
batchMerkleRoot,
merkleProof,
verificationDataBatchIndex
verificationDataBatchIndex,
address(0)
);

if (isAccountVerified) {
Expand Down
42 changes: 11 additions & 31 deletions contract/src/MinaBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error AccountIsNotValid(bytes32 accountIdHash);
contract MinaBridge {
/// @notice The length of the verified state chain (also called the bridge's transition
/// frontier) to store.
uint public constant BRIDGE_TRANSITION_FRONTIER_LEN = 16;
uint256 public constant BRIDGE_TRANSITION_FRONTIER_LEN = 16;

/// @notice The state hash of the last verified chain of Mina states (also called
/// the bridge's transition frontier).
Expand All @@ -23,7 +23,7 @@ contract MinaBridge {
/// @notice Reference to the AlignedLayerServiceManager contract.
AlignedLayerServiceManager aligned;

constructor(address _alignedServiceAddr, bytes32 _tipStateHash) {
constructor(address payable _alignedServiceAddr, bytes32 _tipStateHash) {
aligned = AlignedLayerServiceManager(_alignedServiceAddr);
chainStateHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1] = _tipStateHash;
}
Expand All @@ -39,20 +39,12 @@ contract MinaBridge {
}

/// @notice Returns the latest verified chain state hashes.
function getChainStateHashes()
external
view
returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory)
{
function getChainStateHashes() external view returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory) {
return chainStateHashes;
}

/// @notice Returns the latest verified chain ledger hashes.
function getChainLedgerHashes()
external
view
returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory)
{
function getChainLedgerHashes() external view returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory) {
return chainLedgerHashes;
}

Expand All @@ -70,14 +62,8 @@ contract MinaBridge {
pubInputBridgeTipStateHash := mload(add(pubInput, 0x20))
}

if (
pubInputBridgeTipStateHash !=
chainStateHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1]
) {
revert TipStateIsWrong(
pubInputBridgeTipStateHash,
chainStateHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1]
);
if (pubInputBridgeTipStateHash != chainStateHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1]) {
revert TipStateIsWrong(pubInputBridgeTipStateHash, chainStateHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1]);
}

bytes32 pubInputCommitment = keccak256(pubInput);
Expand All @@ -89,7 +75,8 @@ contract MinaBridge {
proofGeneratorAddr,
batchMerkleRoot,
merkleProof,
verificationDataBatchIndex
verificationDataBatchIndex,
address(0)
);

if (isNewStateVerified) {
Expand All @@ -103,16 +90,9 @@ contract MinaBridge {
// the next BRIDGE_TRANSITION_FRONTIER_LEN sets of 32 bytes are state hashes.
let addr_states := add(pubInput, 64)
// the next BRIDGE_TRANSITION_FRONTIER_LEN sets of 32 bytes are ledger hashes.
let addr_ledgers := add(
addr_states,
mul(32, BRIDGE_TRANSITION_FRONTIER_LEN)
)

for {
let i := 0
} lt(i, BRIDGE_TRANSITION_FRONTIER_LEN) {
i := add(i, 1)
} {
let addr_ledgers := add(addr_states, mul(32, BRIDGE_TRANSITION_FRONTIER_LEN))

for { let i := 0 } lt(i, BRIDGE_TRANSITION_FRONTIER_LEN) { i := add(i, 1) } {
sstore(slot_states, mload(addr_states))
addr_states := add(addr_states, 32)
slot_states := add(slot_states, 1)
Expand Down
4 changes: 2 additions & 2 deletions contract/test/MinaBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {MinaBridge} from "../src/MinaBridge.sol";

contract MinaBridgeTest is Test {
MinaBridge public bridge;
uint160 alignedServiceAddress = 0x0;
address payable alignedServiceAddress = payable(0x0);

function setUp() public {
// FIXME(xqft): this script may be deprecated, for now we'll
// pass 0x0 as the second constructor argument.
bridge = new MinaBridge(address(alignedServiceAddress), 0x0);
bridge = new MinaBridge(alignedServiceAddress, 0x0);
}
}
Loading