From 36fb57590b7f112b53a7b78e0ea5f9b3de50160e Mon Sep 17 00:00:00 2001 From: Elias Tazartes <66871571+Eikix@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:25:30 +0100 Subject: [PATCH] chore bump kakarot (#833) * chore bump kakarot * make sure tx gas limit is below block gas limit * add max fee * add max fee to respect eip1559 validation from kakarot * final fix * fix max fee * add timeout * add constants for tx gas limit * update docker compose to fit new indexer' * feat bump indexer * fix branch of dockerfile --- .github/workflows/kakarot_rpc.yml | 2 +- docker-compose.sepolia.yaml | 30 +++++++++++++++++++++++++++--- docker-compose.yaml | 13 ++++++++----- docker/hive/Dockerfile | 3 ++- lib/kakarot | 2 +- src/bin/hive_chain.rs | 3 +++ src/eth_provider/constant.rs | 2 ++ src/eth_provider/provider.rs | 3 ++- src/test_utils/eoa.rs | 4 +++- src/test_utils/evm_contract.rs | 6 ++++-- src/test_utils/katana/genesis.rs | 6 ++++++ 11 files changed, 59 insertions(+), 15 deletions(-) diff --git a/.github/workflows/kakarot_rpc.yml b/.github/workflows/kakarot_rpc.yml index 04224d4e9..9781d634a 100644 --- a/.github/workflows/kakarot_rpc.yml +++ b/.github/workflows/kakarot_rpc.yml @@ -23,7 +23,7 @@ jobs: - platform: linux/arm64 STARKNET_BIN_DIR: f7va4mjqww1kkpp4il6y295dgcwq147v SINK_BIN_DIR: 3iqnrcirqpg4s7zdy1wdh0dq17jwzmlc - timeout-minutes: 45 + timeout-minutes: 85 steps: - uses: actions/checkout@v3 - name: Set up QEMU diff --git a/docker-compose.sepolia.yaml b/docker-compose.sepolia.yaml index 5461403ad..50b6564c4 100644 --- a/docker-compose.sepolia.yaml +++ b/docker-compose.sepolia.yaml @@ -108,9 +108,33 @@ services: service: clone-repo indexer: - extends: - file: docker-compose.yaml - service: indexer + image: quay.io/apibara/sink-mongo + command: + - run + - /code/kakarot-indexer/src/main.ts + environment: + # Whitelist environment variables + - ALLOW_ENV_FROM_ENV=DEBUG,APIBARA_AUTH_TOKEN,STARTING_BLOCK,STREAM_URL,SINK_TYPE,MONGO_CONNECTION_STRING,MONGO_DATABASE_NAME,STARKNET_NETWORK,KAKAROT_ADDRESS,ALLOW_NET + - DEBUG="" + - APIBARA_AUTH_TOKEN="" + - MONGO_CONNECTION_STRING=mongodb://mongo:mongo@mongo:27017 + - MONGO_DATABASE_NAME=kakarot-local + - STARTING_BLOCK=0 + - STREAM_URL=http://apibara-dna:7171 + - SINK_TYPE=mongo + - STARKNET_NETWORK=http://starknet:6060 + - ALLOW_NET= + - KAKAROT_ADDRESS=0x1a18210c20241ea7a06224246264a59add11c8358d69826e8bd51f4ba6d3be7 + restart: on-failure + volumes: + - indexer_code:/code + networks: + - internal + depends_on: + clone-repo: + condition: service_completed_successfully + starknet: + condition: service_started networks: internal: diff --git a/docker-compose.yaml b/docker-compose.yaml index 7e450a74a..0cdae19fa 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -98,9 +98,6 @@ services: networks: - internal restart: on-failure - depends_on: - starknet: - condition: service_started ### MongoDB with Mongo Express mongo: @@ -134,7 +131,7 @@ services: - /code/kakarot-indexer/src/main.ts environment: # Whitelist environment variables - - ALLOW_ENV_FROM_ENV=DEBUG,APIBARA_AUTH_TOKEN,STARTING_BLOCK,STREAM_URL,SINK_TYPE,MONGO_CONNECTION_STRING,MONGO_DATABASE_NAME + - ALLOW_ENV_FROM_ENV=DEBUG,APIBARA_AUTH_TOKEN,STARTING_BLOCK,STREAM_URL,SINK_TYPE,MONGO_CONNECTION_STRING,MONGO_DATABASE_NAME,STARKNET_NETWORK,KAKAROT_ADDRESS,ALLOW_NET - DEBUG="" - APIBARA_AUTH_TOKEN="" - MONGO_CONNECTION_STRING=mongodb://mongo:mongo@mongo:27017 @@ -142,9 +139,13 @@ services: - STARTING_BLOCK=0 - STREAM_URL=http://apibara-dna:7171 - SINK_TYPE=mongo + - STARKNET_NETWORK=http://starknet:5050 + - ALLOW_NET= + - ALLOW_ENV=/deployments/.env restart: on-failure volumes: - - "indexer_code:/code" + - indexer_code:/code + - deployments:/deployments networks: - internal depends_on: @@ -152,6 +153,8 @@ services: condition: service_completed_successfully starknet: condition: service_started + deployments-parser: + condition: service_completed_successfully networks: internal: diff --git a/docker/hive/Dockerfile b/docker/hive/Dockerfile index 7248f7121..9a00677f5 100644 --- a/docker/hive/Dockerfile +++ b/docker/hive/Dockerfile @@ -113,7 +113,7 @@ RUN apt-get update && apt-get install -y tini curl jq libssl-dev ca-certificates ############# ### Indexer environment variables #### Indexer environment variables -ENV ALLOW_ENV_FROM_ENV=DEBUG,APIBARA_AUTH_TOKEN,STARTING_BLOCK,STREAM_URL,SINK_TYPE,MONGO_CONNECTION_STRING,MONGO_DATABASE_NAME +ENV ALLOW_ENV_FROM_ENV=DEBUG,APIBARA_AUTH_TOKEN,STARTING_BLOCK,STREAM_URL,SINK_TYPE,MONGO_CONNECTION_STRING,MONGO_DATABASE_NAME,STARKNET_NETWORK,KAKAROT_ADDRESS,ALLOW_NET ENV DEBUG="" ENV APIBARA_AUTH_TOKEN="" ENV MONGO_CONNECTION_STRING=mongodb://localhost:27017 @@ -123,6 +123,7 @@ ENV STREAM_URL=http://localhost:7171 ENV SINK_TYPE=mongo ENV KATANA_ACCOUNT_ADDRESS=0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca ENV KATANA_PRIVATE_KEY=0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a +ENV ALLOW_NET="" ### Kakarot RPC environment variables ### Port 8545: https://github.com/ethereum/hive/blob/master/simulators/ethereum/rpc/helper.go#L50 ENV KAKAROT_RPC_URL=0.0.0.0:8545 diff --git a/lib/kakarot b/lib/kakarot index 08c3268de..01a8adcb3 160000 --- a/lib/kakarot +++ b/lib/kakarot @@ -1 +1 @@ -Subproject commit 08c3268de71f5aefc1692b343a7ae375d2948651 +Subproject commit 01a8adcb3f075b4354d9c42e9a24cc6e14a1e4a9 diff --git a/src/bin/hive_chain.rs b/src/bin/hive_chain.rs index 4a4a58b89..6b4ba7791 100644 --- a/src/bin/hive_chain.rs +++ b/src/bin/hive_chain.rs @@ -60,6 +60,8 @@ async fn main() -> eyre::Result<()> { tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; } + // TODO(HIVE): Set the block gas limit in kakarot + for transaction in body.transactions { let signer = transaction.recover_signer().ok_or(eyre!("Failed to recover signer"))?; let chain_id = transaction.chain_id().ok_or(eyre!("Failed to recover chain id"))?; @@ -69,6 +71,7 @@ async fn main() -> eyre::Result<()> { assert_eq!(starknet_tx.nonce, current_nonce); provider.add_invoke_transaction(BroadcastedInvokeTransaction::V1(starknet_tx)).await?; + tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; current_nonce += 1u8.into(); } diff --git a/src/eth_provider/constant.rs b/src/eth_provider/constant.rs index be71acad7..b8cb7d0e7 100644 --- a/src/eth_provider/constant.rs +++ b/src/eth_provider/constant.rs @@ -4,6 +4,8 @@ lazy_static! { pub static ref MAX_PRIORITY_FEE_PER_GAS: u64 = 0; } +pub const CALL_REQUEST_GAS_LIMIT: u64 = 5_000_000; + #[cfg(feature = "hive")] use { crate::config::KakarotRpcConfig, diff --git a/src/eth_provider/provider.rs b/src/eth_provider/provider.rs index 29b351fdb..f275ad285 100644 --- a/src/eth_provider/provider.rs +++ b/src/eth_provider/provider.rs @@ -31,6 +31,7 @@ use starknet::core::types::ValueOutOfRangeError; use starknet::core::utils::get_storage_var_address; use starknet_crypto::FieldElement; +use super::constant::CALL_REQUEST_GAS_LIMIT; use super::database::types::log::StoredLog; use super::database::types::{ header::StoredHeader, receipt::StoredTransactionReceipt, transaction::StoredTransaction, @@ -604,7 +605,7 @@ where let data = request.input.into_input().unwrap_or_default(); let calldata: Vec = data.into_iter().map_into().collect(); - let gas_limit = into_via_try_wrapper!(request.gas.unwrap_or_else(|| U256::from(u64::MAX))); + let gas_limit = into_via_try_wrapper!(request.gas.unwrap_or_else(|| U256::from(CALL_REQUEST_GAS_LIMIT))); let gas_price = into_via_try_wrapper!(request.gas_price.unwrap_or_default()); let value = into_via_try_wrapper!(request.value.unwrap_or_default()); diff --git a/src/test_utils/eoa.rs b/src/test_utils/eoa.rs index 153a45319..d108ab232 100644 --- a/src/test_utils/eoa.rs +++ b/src/test_utils/eoa.rs @@ -18,6 +18,8 @@ use crate::test_utils::evm_contract::EvmContract; use crate::test_utils::evm_contract::KakarotEvmContract; use crate::test_utils::tx_waiter::watch_tx; +pub const TX_GAS_LIMIT: u64 = 5_000_000; + /// EOA is an Ethereum-like Externally Owned Account (EOA) that can sign transactions and send them to the underlying Starknet provider. #[async_trait] pub trait Eoa { @@ -182,7 +184,7 @@ impl KakarotEOA

{ nonce, max_priority_fee_per_gas: Default::default(), max_fee_per_gas: Default::default(), - gas_limit: u64::MAX, + gas_limit: TX_GAS_LIMIT, to: TransactionKind::Call(to), value: value.into(), input: Bytes::default(), diff --git a/src/test_utils/evm_contract.rs b/src/test_utils/evm_contract.rs index 86b0e982b..35eaec5fd 100644 --- a/src/test_utils/evm_contract.rs +++ b/src/test_utils/evm_contract.rs @@ -10,6 +10,8 @@ use starknet_crypto::FieldElement; use crate::models::felt::Felt252Wrapper; use crate::root_project_path; +use super::eoa::TX_GAS_LIMIT; + pub trait EvmContract { fn load_contract_bytecode(contract_name: &str) -> Result { let dot_sol = format!("{contract_name}.sol"); @@ -48,7 +50,7 @@ pub trait EvmContract { Ok(Transaction::Eip1559(TxEip1559 { chain_id, nonce, - gas_limit: u64::MAX, + gas_limit: TX_GAS_LIMIT, to: TransactionKind::Create, value: 0u64.into(), input: deploy_data.into(), @@ -101,7 +103,7 @@ impl EvmContract for KakarotEvmContract { Ok(Transaction::Eip1559(TxEip1559 { chain_id, nonce, - gas_limit: u64::MAX, + gas_limit: TX_GAS_LIMIT, to: TransactionKind::Call(evm_address.try_into()?), value: value.into(), input: data.into(), diff --git a/src/test_utils/katana/genesis.rs b/src/test_utils/katana/genesis.rs index 888db5de3..e9508e701 100644 --- a/src/test_utils/katana/genesis.rs +++ b/src/test_utils/katana/genesis.rs @@ -203,6 +203,8 @@ impl KatanaGenesisBuilder { let proxy_class_hash = self.proxy_class_hash()?; let precompiles_class_hash = self.precompiles_class_hash()?; + let block_gas_limit = FieldElement::from(20_000_000u64); + // Construct the kakarot contract address. Based on the constructor args from // https://github.com/kkrt-labs/kakarot/blob/main/src/kakarot/kakarot.cairo#L23 let kakarot_address = ContractAddress::new(get_udc_deployed_address( @@ -216,6 +218,7 @@ impl KatanaGenesisBuilder { eoa_class_hash, proxy_class_hash, precompiles_class_hash, + block_gas_limit, ], )); // Cache the address for later use. @@ -229,6 +232,9 @@ impl KatanaGenesisBuilder { (storage_addr("account_proxy_class_hash")?, proxy_class_hash), (storage_addr("precompiles_class_hash")?, precompiles_class_hash), (storage_addr("coinbase")?, coinbase_address), + (storage_addr("base_fee")?, FieldElement::ZERO), + (storage_addr("prev_randao")?, FieldElement::ZERO), + (storage_addr("block_gas_limit")?, block_gas_limit), ] .into_iter() .collect::>();