Skip to content

Commit

Permalink
fix(indexer): block identifier error (#952)
Browse files Browse the repository at this point in the history
* fix kakarot call in indexer

* fix comments

* fix docs
  • Loading branch information
greged93 authored Apr 10, 2024
1 parent 9544e5b commit 3191864
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

## About

Kakarot RPC fits in the three-part architecture of the Kakarot zkEVM rollup ([Kakarot EVM Cairo Programs](https://github.com/kkrt-labs/kakarot), Kakarot RPC, [Kakarot Indexer](https://github.com/kkrt-labs/kakarot-indexer)). It is the implementation of the Ethereum JSON-RPC specification made to interact with Kakarot zkEVM in a fully Ethereum-compatible way.
Kakarot RPC fits in the three-part architecture of the Kakarot zkEVM rollup ([Kakarot EVM Cairo Programs](https://github.com/kkrt-labs/kakarot), Kakarot RPC, [Kakarot Indexer](indexer/README.md)). It is the implementation of the Ethereum JSON-RPC specification made to interact with Kakarot zkEVM in a fully Ethereum-compatible way.

![Kakarot zkEVM architecture](./docs/images/Kakarot%20zkEVM.png)

Expand Down Expand Up @@ -107,7 +107,7 @@ TL;DR:

### Setup the project

To set up the repository (pulling git submodule and building Cairo dependencies), run:
To set up the repository (pulling git submodule and building Cairo dependencies),run:

```console
make setup
Expand Down
21 changes: 9 additions & 12 deletions indexer/src/types/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ export async function toEthHeader({
let coinbase;
let baseFee;
let blockGasLimit;
const blockIdentifier = isPendingBlock ? "pending" : blockHash;

try {
const response = (await KAKAROT.call("get_coinbase", [], {
// ⚠️ StarknetJS: blockIdentifier is a block hash if value is BigInt or HexString, otherwise it's a block number.
blockIdentifier: BigInt(blockNumber).toString(),
// ⚠️ StarknetJS: blockIdentifier is a block hash if value is BigInt or String, otherwise it's a block number.
blockIdentifier,
})) as {
coinbase: bigint;
};
Expand All @@ -79,8 +80,8 @@ export async function toEthHeader({

try {
const response = (await KAKAROT.call("get_base_fee", [], {
// ⚠️ StarknetJS: blockIdentifier is a block hash if value is BigInt or HexString, otherwise it's a block number.
blockIdentifier: BigInt(blockNumber).toString(),
// ⚠️ StarknetJS: blockIdentifier is a block hash if value is BigInt or String, otherwise it's a block number.
blockIdentifier,
})) as {
base_fee: bigint;
};
Expand All @@ -93,14 +94,10 @@ export async function toEthHeader({
}

try {
const response = (await KAKAROT.call(
"get_block_gas_limit",
[],
{
// ⚠️ StarknetJS: blockIdentifier is a block hash if value is BigInt or HexString, otherwise it's a block number.
blockIdentifier: BigInt(blockNumber).toString(),
},
)) as {
const response = (await KAKAROT.call("get_block_gas_limit", [], {
// ⚠️ StarknetJS: blockIdentifier is a block hash if value is BigInt or String, otherwise it's a block number.
blockIdentifier,
})) as {
block_gas_limit: bigint;
};
blockGasLimit = response.block_gas_limit;
Expand Down

0 comments on commit 3191864

Please sign in to comment.