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

feat: L3 support #437

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

feat: L3 support #437

wants to merge 11 commits into from

Conversation

ocdbytes
Copy link
Member

Added support for L3s. Starknet client is added in this PR and tests are added for several client functions. for now we are assuming that the l3 gas prices will be zero only.

Pull Request type

Please add the labels corresponding to the type of changes your PR introduces:

  • Feature
  • Testing

What is the current behavior?

Currently we didn't support the L3 appchain spec.

What is the new behavior?

Included the starknet client and updated the cli arguments for running madara in appchain mode. For now for all the gas prices and metrics we are still using the l1 modules. We can cover this refactoring in another PR.

Does this introduce a breaking change?

No

@apoorvsadana apoorvsadana marked this pull request as draft December 23, 2024 03:40
@@ -68,3 +68,6 @@ tmp/
# Running madara with make and docker compose
.secrets
image.tar.gz

# madara test artifacts for testing l2 clients for appchains
test-artifacts/madara
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be in the root folder?

Copy link
Member Author

Choose a reason for hiding this comment

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

According to me ig test-artifacts folder should be there because we also have a devnet.yaml file in that.

Copy link
Contributor

Choose a reason for hiding this comment

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

but why in root? it should be where the testcase is right

Comment on lines 46 to 50
starknet-accounts = "0.11.0"
starknet-contract = "0.11.0"
starknet-core = { workspace = true }
starknet-providers = { workspace = true }
starknet-signers = { workspace = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

should we put these behind feature flags?

Copy link
Member Author

Choose a reason for hiding this comment

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

So these are workspace dependencies they are already being built. Do you think it will be reducing any build time ?

Copy link
Contributor

Choose a reason for hiding this comment

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

workspace dependencies should not be built unless being used in a crate afaik. this is also a good time to check if we should move starknet/eth into crates btw

crates/client/settlement_client/src/client.rs Outdated Show resolved Hide resolved
crates/client/settlement_client/src/client.rs Outdated Show resolved Hide resolved
crates/client/settlement_client/src/eth/mod.rs Outdated Show resolved Hide resolved
crates/client/settlement_client/src/starknet/utils.rs Outdated Show resolved Hide resolved
crates/client/settlement_client/src/starknet/mod.rs Outdated Show resolved Hide resolved
crates/client/settlement_client/src/starknet/mod.rs Outdated Show resolved Hide resolved

Ok(())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we test listen_for_update_state_events

Copy link
Contributor

Choose a reason for hiding this comment

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

oh ok, I noticed we've a test for this in the common starknet/eth file. can we move it inside eth and starknet because they've different logics?

Copy link
Member Author

Choose a reason for hiding this comment

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

But shouldn't the tests be with the module ?

l1_gas_provider,
chain_id,
gas_price_sync_disabled: !gas_price_sync_enabled,
gas_price_poll,
mempool,
})
}

// Factory method to create the appropriate service
#[allow(clippy::too_many_arguments)]
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make it a struct?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried but lifetime specifier ka issue aa rha h. will try it in next commit.

)
.await?;
// Ensure correct read call : u256 (0, 0)
assert_eq!(call_res.len(), 2, "l1_to_l2_message_cancellations should return only 2 values");
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before

}
}

async fn listen_for_messaging_events(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the flow right now
Screenshot 2024-12-28 at 6 16 49 PM

I think this is how the flow should be like
Screenshot 2024-12-28 at 6 27 02 PM

You should look at this for implementing streams - https://docs.rs/futures/latest/futures/stream/trait.Stream.html

This is what I think alloy is also using fro event streams

Comment on lines +213 to +214
BlockId::Number(starting_block),
BlockId::Number(latest_block_number),
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if the gap is too big between start and end block? do RPCs throw an error? I think there's like a max 10k gap limit but we should confirm

}
}

sleep(Duration::from_secs(5)).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

we can reduce this time to ms I think

} else if latest_block_number < 100 {
0
} else {
latest_block_number - 100
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of looping over last 100 blocks every time, I think we can keep state in memory here. the stream implementation i linked to allows for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants