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

dev: update Madara genesis loading #484

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
10 changes: 5 additions & 5 deletions crates/hive-utils/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TODO: Use official madara image when https://github.com/keep-starknet-strange/madara/issues/982 is closed
# FROM ghcr.io/keep-starknet-strange/madara:v0.1.0.experimental.3 as madara
FROM fredtupas/madara as madara
FROM fredtupas/madara-fixed as madara
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: will update pr to official image once this pr in Madara is merged keep-starknet-strange/madara#1018


FROM ghcr.io/kkrt-labs/kakarot-rpc/node:latest

Expand All @@ -16,14 +16,14 @@ COPY --from=madara /madara-bin /madara-bin

# Madara Path
ENV MADARA_PATH=/root/.madara
ENV MADARA_CONFIG_PATH=${MADARA_PATH}/configs
ENV KAKAROT_CONTRACTS_PATH=${MADARA_PATH}/cairo-contracts/kakarot
ENV MADARA_GENESIS_ASSETS_PATH=${MADARA_PATH}/configs/genesis-assets
ENV KAKAROT_CONTRACTS_PATH=${MADARA_GENESIS_ASSETS_PATH}/kakarot

# Download Madara genesis config to source path
RUN svn export https://github.com/keep-starknet-strange/madara/trunk/configs ${MADARA_CONFIG_PATH}
RUN svn export https://github.com/d-roak/madara/branches/feat/configs-index/configs/genesis-assets ${MADARA_GENESIS_ASSETS_PATH}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Update to Madara's main branch


# Copy combined genesis.json to source path
COPY .hive/genesis.json ${MADARA_CONFIG_PATH}/genesis-assets/genesis.json
COPY .hive/genesis.json ${MADARA_GENESIS_ASSETS_PATH}/genesis.json

# Copy compiled Kakarot contracts to destination path of compiled contracts
COPY ./lib/kakarot/build ${KAKAROT_CONTRACTS_PATH}
Expand Down
1 change: 1 addition & 0 deletions crates/hive-utils/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export PROXY_ACCOUNT_CLASS_HASH=$(starkli class-hash ${MADARA_PATH}/cairo-contra
--rpc-external \
--rpc-methods=unsafe \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u can remove --rpc-externaland --rpc-methods=unsafe because they will be enabled when u set the --dev

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks will remove this!

--rpc-cors=all \
--disable-madara-configs \
Copy link
Contributor Author

@ftupas ftupas Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're copying all the genesis assets into the local Madara path, we need to add this flag to use them

--tmp \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are u setting a tmp path for the db? since it's a docker container, u can just let it go to the default madara-path

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this, had to add this flag before in the fork because it was initializing but not including the Kakarot contracts for some reason and it worked when we added it

--dev &

Expand Down
2 changes: 1 addition & 1 deletion crates/hive-utils/src/hive/bin/dump-genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async fn main() {
let madara_loader =
serde_json::from_str::<GenesisLoader>(std::include_str!("../../test_data/madara_genesis.json")).unwrap();
let combined_genesis = Path::new(".hive/genesis.json");
let compiled_path = Path::new("cairo-contracts/kakarot");
let compiled_path = Path::new("genesis-assets/kakarot");

// Dump the genesis
std::fs::create_dir_all(".hive/").expect("Failed to create Hive dump dir");
Expand Down
4 changes: 4 additions & 0 deletions crates/hive-utils/src/hive/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ pub async fn serialize_hive_to_madara_genesis_config(
Felt(*kakarot_contracts.get("OpenzeppelinAccount").expect("Failed to get deployer account class hash")),
));

// Fund the deployer
let deployer_balance = genesis_fund_starknet_address(*DEPLOYER_ACCOUNT_ADDRESS, U256::MAX);
madara_loader.storage.extend(deployer_balance);

// Set storage keys of Kakarot contract
// https://github.com/kkrt-labs/kakarot/blob/main/src/kakarot/constants.cairo
let storage_keys = [
Expand Down
3 changes: 3 additions & 0 deletions crates/hive-utils/src/test_data/hive_genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"c5065c9eeebe6df2c2284d046bfc906501846c51": {
"balance": "0x123450000000000000000"
},
"75454A4CcBb30bE745679F0abA5aB9D55769406a": {
"balance": "0x123450000000000000000"
},
"0000000000000000000000000000000000000314": {
"balance": "0x0",
"code": "0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a223e05d1461006a578063abd1a0cf1461008d578063abfced1d146100d4578063e05c914a14610110578063e6768b451461014c575b610000565b346100005761007761019d565b6040518082815260200191505060405180910390f35b34610000576100be600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506101a3565b6040518082815260200191505060405180910390f35b346100005761010e600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506101ed565b005b346100005761014a600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610236565b005b346100005761017960048080359060200190919080359060200190919080359060200190919050506103c4565b60405180848152602001838152602001828152602001935050505060405180910390f35b60005481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b919050565b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5050565b7f6031a8d62d7c95988fa262657cd92107d90ed96e08d8f867d32f26edfe85502260405180905060405180910390a17f47e2689743f14e97f7dcfa5eec10ba1dff02f83b3d1d4b9c07b206cbbda66450826040518082815260200191505060405180910390a1817fa48a6b249a5084126c3da369fbc9b16827ead8cb5cdc094b717d3f1dcd995e2960405180905060405180910390a27f7890603b316f3509577afd111710f9ebeefa15e12f72347d9dffd0d65ae3bade81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a18073ffffffffffffffffffffffffffffffffffffffff167f7efef9ea3f60ddc038e50cccec621f86a0195894dc0520482abf8b5c6b659e4160405180905060405180910390a28181604051808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a05b5050565b6000600060008585859250925092505b935093509390505600a165627a7a72305820aaf842d0d0c35c45622c5263cbb54813d2974d3999c8c38551d7c613ea2bc1170029",
Expand Down
22 changes: 11 additions & 11 deletions crates/hive-utils/src/test_data/madara_genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
[
"0x0279d77db761fba82e0054125a6fdb5f6baa6286fa3fb73450cc44d193c2d37f",
{
"path": "cairo-contracts/NoValidateAccount.json",
"path": "genesis-assets/NoValidateAccount.json",
"version": 0
}
],
[
"0x06f0d6f6ae72e1a507ff4b65181291642889742dbf8f1a53e9ec1c595d01ba7d",
{
"path": "cairo-contracts/ArgentAccount.json",
"path": "genesis-assets/ArgentAccount.json",
"version": 0
}
],
[
"0x0424b7f61e3c5dfd74400d96fdea7e1f0bf2757f31df04387eaa957f095dd7b9",
{ "path": "cairo-contracts/Proxy.json", "version": 0 }
{ "path": "genesis-assets/Proxy.json", "version": 0 }
],
[
"0x2c2b8f559e1221468140ad7b2352b1a5be32660d0bf1a3ae3a054a4ec5254e4",
Expand All @@ -38,30 +38,30 @@
],
[
"0x3131fa018d520a037686ce3efddeab8f28895662f019ca3ca18a626650f7d1e",
{ "path": "cairo-contracts/Proxy.json", "version": 0 }
{ "path": "genesis-assets/Proxy.json", "version": 0 }
],
[
"0x006280083f8c2a2db9f737320d5e3029b380e0e820fe24b8d312a6a34fdba0cd",
{
"path": "cairo-contracts/OpenzeppelinAccount.json",
"path": "genesis-assets/OpenzeppelinAccount.json",
"version": 0
}
],
[
"0x35ccefcf9d5656da623468e27e682271cd327af196785df99e7fee1436b6276",
{
"path": "cairo-contracts/NoValidateAccount.casm.json",
"path": "genesis-assets/NoValidateAccount.casm.json",
"version": 1
}
],
["0x1000", { "path": "cairo-contracts/test.json", "version": 0 }],
["0x10000", { "path": "cairo-contracts/ERC20.json", "version": 0 }],
["0x20000", { "path": "cairo-contracts/ERC20.json", "version": 0 }],
["0x80000", { "path": "cairo-contracts/ERC721.json", "version": 0 }],
["0x1000", { "path": "genesis-assets/test.json", "version": 0 }],
["0x10000", { "path": "genesis-assets/ERC20.json", "version": 0 }],
["0x20000", { "path": "genesis-assets/ERC20.json", "version": 0 }],
["0x80000", { "path": "genesis-assets/ERC721.json", "version": 0 }],
[
"0x90000",
{
"path": "cairo-contracts/UniversalDeployer.json",
"path": "genesis-assets/UniversalDeployer.json",
"version": 0
}
]
Expand Down
Loading