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 SDK version #360

Merged
merged 7 commits into from
Oct 21, 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
8 changes: 4 additions & 4 deletions contract/src/MinaAccountValidation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pragma solidity ^0.8.12;

import "aligned_layer/contracts/src/core/AlignedLayerServiceManager.sol";

error MinaAccountProvingSystemIdIsNotValid(); // c1872967
error MinaAccountProvingSystemIdIsNotValid(bytes32); // c1872967

contract MinaAccountValidation {
/// @notice The commitment to Mina Account proving system ID.
bytes32 constant PROVING_SYSTEM_ID_COMM = 0xd33e25809fcaa2b6900567812852539da8559dc8b76a7ce3fc5ddd77e8d19a69;
bytes32 constant PROVING_SYSTEM_ID_COMM = 0xd0591206d9e81e07f4defc5327957173572bcd1bca7838caa7be39b0c12b1873;

struct AlignedArgs {
bytes32 proofCommitment;
Expand All @@ -29,7 +29,7 @@ contract MinaAccountValidation {

function validateAccount(AlignedArgs calldata args) external view returns (bool) {
if (args.provingSystemAuxDataCommitment != PROVING_SYSTEM_ID_COMM) {
revert MinaAccountProvingSystemIdIsNotValid();
revert MinaAccountProvingSystemIdIsNotValid(args.provingSystemAuxDataCommitment);
}

bytes32 pubInputCommitment = keccak256(args.pubInput);
Expand All @@ -48,7 +48,7 @@ contract MinaAccountValidation {

function validateAccountAndReturn(AlignedArgs calldata args) external view returns (Account memory) {
if (args.provingSystemAuxDataCommitment != PROVING_SYSTEM_ID_COMM) {
revert MinaAccountProvingSystemIdIsNotValid();
revert MinaAccountProvingSystemIdIsNotValid(args.provingSystemAuxDataCommitment);
}

bytes32 pubInputCommitment = keccak256(args.pubInput);
Expand Down
22 changes: 16 additions & 6 deletions contract/src/MinaStateSettlement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ error AccountIsNotValid(bytes32 accountIdHash);
/// @title Mina to Ethereum Bridge's smart contract for verifying and storing a valid state chain.
contract MinaStateSettlement {
/// @notice The commitment to Mina proving system ID.
bytes32 constant PROVING_SYSTEM_ID_COMM = 0xee2a4bc7db81da2b7164e56b3649b1e2a09c58c455b15dabddd9146c7582cebc;
bytes32 constant PROVING_SYSTEM_ID_COMM =
0xdbb8d0f4c497851a5043c6363657698cb1387682cac2f786c731f8936109d795;

/// @notice The length of the verified state chain (also called the bridge's transition
/// frontier) to store.
Expand All @@ -30,7 +31,8 @@ contract MinaStateSettlement {
/// @notice Reference to the AlignedLayerServiceManager contract.
AlignedLayerServiceManager aligned;

constructor(address payable _alignedServiceAddr, bytes32 _tipStateHash, bool _devnetFlag) {
constructor(address payable _alignedServiceAddr, bytes32 _tipStateHash, bool _devnetFlag
) {
aligned = AlignedLayerServiceManager(_alignedServiceAddr);
chainStateHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1] = _tipStateHash;
devnetFlag = _devnetFlag;
Expand All @@ -47,19 +49,24 @@ contract MinaStateSettlement {
}

/// @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;
}

/// @notice Returns true if this snarked ledger hash was bridged.
function isLedgerVerified(bytes32 ledgerHash) external view returns (bool) {
for (uint256 i = 0; i < BRIDGE_TRANSITION_FRONTIER_LEN; i++) {
if (chainLedgerHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1 - i] == ledgerHash) {
if (
chainLedgerHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1 - i] ==
ledgerHash
) {
return true;
}
}
Expand Down Expand Up @@ -123,7 +130,10 @@ contract MinaStateSettlement {
// the next BRIDGE_TRANSITION_FRONTIER_LEN sets of 32 bytes are state hashes.
let addr_states := add(pubInput, 65)
// 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))
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))
Expand Down
Loading