Skip to content

Commit

Permalink
chore bump kakarot (#833)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Eikix authored Mar 8, 2024
1 parent 8e7f129 commit 36fb575
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/kakarot_rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 27 additions & 3 deletions docker-compose.sepolia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 8 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ services:
networks:
- internal
restart: on-failure
depends_on:
starknet:
condition: service_started

### MongoDB with Mongo Express
mongo:
Expand Down Expand Up @@ -134,24 +131,30 @@ 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
- MONGO_DATABASE_NAME=kakarot-local
- 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:
clone-repo:
condition: service_completed_successfully
starknet:
condition: service_started
deployments-parser:
condition: service_completed_successfully

networks:
internal:
Expand Down
3 changes: 2 additions & 1 deletion docker/hive/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/bin/hive_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))?;
Expand All @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/eth_provider/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/eth_provider/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -604,7 +605,7 @@ where
let data = request.input.into_input().unwrap_or_default();
let calldata: Vec<FieldElement> = 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());
Expand Down
4 changes: 3 additions & 1 deletion src/test_utils/eoa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: Provider + Send + Sync> {
Expand Down Expand Up @@ -182,7 +184,7 @@ impl<P: Provider + Send + Sync> KakarotEOA<P> {
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(),
Expand Down
6 changes: 4 additions & 2 deletions src/test_utils/evm_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompactContractBytecode, eyre::Error> {
let dot_sol = format!("{contract_name}.sol");
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions src/test_utils/katana/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ impl KatanaGenesisBuilder<Loaded> {
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(
Expand All @@ -216,6 +218,7 @@ impl KatanaGenesisBuilder<Loaded> {
eoa_class_hash,
proxy_class_hash,
precompiles_class_hash,
block_gas_limit,
],
));
// Cache the address for later use.
Expand All @@ -229,6 +232,9 @@ impl KatanaGenesisBuilder<Loaded> {
(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::<HashMap<_, _>>();
Expand Down

0 comments on commit 36fb575

Please sign in to comment.