Skip to content

Commit e07e59d

Browse files
fix: mina aligned integration (#375)
* bump alfred to point to lambdaclass sync-mina latest commit * update proving system id commitments in contracts because of new aligned_sdk version * fix makefile target submit_account incorrect form of receiving params * retrieve nonce from batcher instead of having it hardcoded to 0 * mention public nodes in mina node setup section * point to aligned-sdk to actual aligned repo instead of lambda fork * Update README.md Co-authored-by: Gabriel Bosio <38794644+gabrielbosio@users.noreply.github.com> --------- Co-authored-by: Gabriel Bosio <38794644+gabrielbosio@users.noreply.github.com>
1 parent 4f60b6f commit e07e59d

21 files changed

Lines changed: 355 additions & 107 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ submit_devnet_state:
77
@cargo run --manifest-path core/Cargo.toml --release -- submit-state --devnet
88

99
submit_account:
10-
@cargo run --manifest-path core/Cargo.toml --release -- submit-account ${PUBLIC_KEY} ${STATE_HASH}
10+
@cargo run --manifest-path core/Cargo.toml --release -- submit-account $(PUBLIC_KEY) $(STATE_HASH)
1111

1212
gen_contract_abis:
1313
forge build --root contract/

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ This repo also includes example contracts that show how to interact with Aligned
8181
- If you want the Bridge to use Mina Devnet then use a node that runs a Devnet instance corresponding to the commit `599a76d` [of the Mina repo](https://github.com/MinaProtocol/mina/tree/599a76dd47be99183d2102d9eb93eda679dd46ec) or a newer one (e.g.: [this Docker image](https://console.cloud.google.com/gcr/images/o1labs-192920/GLOBAL/mina-daemon:3.0.1-compatible-599a76d-bullseye-devnet/details)). See [how to connect to Mina Devnet](https://docs.minaprotocol.com/node-operators/block-producer-node/connecting-to-devnet#docker) if you want to run an instance yourself.
8282
- If you want the Bridge to use Mina Mainnet use a node that runs a Mainnet instance corresponding to the commit `65c84ad` [of the Mina repo](https://github.com/MinaProtocol/mina/tree/65c84adacd55272160d9f77c31063d94a942afb6) or a newer one (e.g.: [this Docker image](http://gcr.io/o1labs-192920/mina-daemon:3.0.1-beta1-sai-query-snarked-ledger-c439ce5-bullseye-mainnet)). See [how to connect to Mina Mainnet](https://docs.minaprotocol.com/node-operators/block-producer-node/connecting-to-the-network#docker) if you want to run an instance yourself.
8383

84+
Alternatively, you can try with Mina public nodes:
85+
- Devnet: https://api.minascan.io/node/devnet/v1/graphql
86+
- Mainnet: https://api.minascan.io/node/mainnet/v1/graphql
87+
88+
8489
### Setup Aligned Devnet infrastructure locally
8590

8691
1. Start Docker

contract/src/MinaAccountValidationExample.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ error MinaAccountProvingSystemIdIsNotValid(bytes32); // c1872967
99
/// NEVER use this contract in a production environment.
1010
contract MinaAccountValidationExample {
1111
/// @notice The commitment to Mina Account proving system ID.
12-
bytes32 constant PROVING_SYSTEM_ID_COMM = 0xd0591206d9e81e07f4defc5327957173572bcd1bca7838caa7be39b0c12b1873;
12+
bytes32 constant PROVING_SYSTEM_ID_COMM = 0xee2a4bc7db81da2b7164e56b3649b1e2a09c58c455b15dabddd9146c7582cebc;
1313

1414
struct AlignedArgs {
1515
bytes32 proofCommitment;

contract/src/MinaStateSettlementExample.sol

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ error AccountIsNotValid(bytes32 accountIdHash);
1414
/// NEVER use this contract in a production environment.
1515
contract MinaStateSettlementExample {
1616
/// @notice The commitment to Mina proving system ID.
17-
bytes32 constant PROVING_SYSTEM_ID_COMM =
18-
0xdbb8d0f4c497851a5043c6363657698cb1387682cac2f786c731f8936109d795;
17+
bytes32 constant PROVING_SYSTEM_ID_COMM = 0xd0591206d9e81e07f4defc5327957173572bcd1bca7838caa7be39b0c12b1873;
1918

2019
/// @notice The length of the verified state chain (also called the bridge's transition
2120
/// frontier) to store.
@@ -33,8 +32,7 @@ contract MinaStateSettlementExample {
3332
/// @notice Reference to the AlignedLayerServiceManager contract.
3433
AlignedLayerServiceManager aligned;
3534

36-
constructor(address payable _alignedServiceAddr, bytes32 _tipStateHash, bool _devnetFlag
37-
) {
35+
constructor(address payable _alignedServiceAddr, bytes32 _tipStateHash, bool _devnetFlag) {
3836
aligned = AlignedLayerServiceManager(_alignedServiceAddr);
3937
chainStateHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1] = _tipStateHash;
4038
devnetFlag = _devnetFlag;
@@ -51,24 +49,19 @@ contract MinaStateSettlementExample {
5149
}
5250

5351
/// @notice Returns the latest verified chain state hashes.
54-
function getChainStateHashes() external view returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory)
55-
{
52+
function getChainStateHashes() external view returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory) {
5653
return chainStateHashes;
5754
}
5855

5956
/// @notice Returns the latest verified chain ledger hashes.
60-
function getChainLedgerHashes() external view returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory)
61-
{
57+
function getChainLedgerHashes() external view returns (bytes32[BRIDGE_TRANSITION_FRONTIER_LEN] memory) {
6258
return chainLedgerHashes;
6359
}
6460

6561
/// @notice Returns true if this snarked ledger hash was bridged.
6662
function isLedgerVerified(bytes32 ledgerHash) external view returns (bool) {
6763
for (uint256 i = 0; i < BRIDGE_TRANSITION_FRONTIER_LEN; i++) {
68-
if (
69-
chainLedgerHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1 - i] ==
70-
ledgerHash
71-
) {
64+
if (chainLedgerHashes[BRIDGE_TRANSITION_FRONTIER_LEN - 1 - i] == ledgerHash) {
7265
return true;
7366
}
7467
}
@@ -129,10 +122,7 @@ contract MinaStateSettlementExample {
129122
// the next BRIDGE_TRANSITION_FRONTIER_LEN sets of 32 bytes are state hashes.
130123
let addr_states := add(pubInput, 65)
131124
// the next BRIDGE_TRANSITION_FRONTIER_LEN sets of 32 bytes are ledger hashes.
132-
let addr_ledgers := add(
133-
addr_states,
134-
mul(32, BRIDGE_TRANSITION_FRONTIER_LEN)
135-
)
125+
let addr_ledgers := add(addr_states, mul(32, BRIDGE_TRANSITION_FRONTIER_LEN))
136126

137127
for { let i := 0 } lt(i, BRIDGE_TRANSITION_FRONTIER_LEN) { i := add(i, 1) } {
138128
sstore(slot_states, mload(addr_states))

contract_deployer/Cargo.lock

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

contract_deployer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
mina_bridge_core = { path = "../core/" }
8-
aligned-sdk = { git = "https://github.com/lambdaclass/aligned_layer.git", rev = "220546afa12c035a508529224f5148cd6af4ca78" }
8+
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer.git", rev = "11d1801a86bedb375c8ccdd0d77074a7134a7427" }
99
tokio = "1.39.1"
1010
env_logger = "0.11.5"
1111
bincode = "1.3.3"

contract_deployer/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use aligned_sdk::core::types::Network;
1+
use aligned_sdk::common::types::Network;
22
use log::{debug, error, info};
33
use mina_bridge_core::{
44
eth::{

0 commit comments

Comments
 (0)