Skip to content

Commit

Permalink
feat: resolve PR comments
Browse files Browse the repository at this point in the history
1. Removes unnecessary TODO comments
2. Replaces `starknet-core` with `starknet-ff` to minimize deps
3. Fixes expensive `transaction` clone
4. Other misc changes
  • Loading branch information
xJonathanLEI committed Sep 29, 2023
1 parent 95e6f83 commit 7dbd2f0
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 193 deletions.
166 changes: 4 additions & 162 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion chain/starknet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ hex = { version = "0.4.3", features = ["serde"] }
prost = { workspace = true }
prost-types = { workspace = true }
serde = "1.0"
starknet-core = "0.6.0"
sha3 = "0.10.8"
starknet-ff = "0.3.4"

graph-runtime-wasm = { path = "../../runtime/wasm" }
graph-runtime-derive = { path = "../../runtime/derive" }
5 changes: 0 additions & 5 deletions chain/starknet/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ use crate::{
Chain,
};

// Currently `TriggerFilter` is useless, as it doesn't really filter anything from the block
// stream, and the complete stream is always consumed, regardless of what the subgraph is indexing.
// This is very bad for indexing performance and must be implemented for it to be considered
// production-ready.
// TODO: implement trigger filter for much better performance
#[derive(Default, Clone)]
pub struct TriggerFilter;

Expand Down
16 changes: 2 additions & 14 deletions chain/starknet/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ pub struct FirehoseMapper {

pub struct TriggersAdapter;

// impl Chain {
// pub fn new(
// logger_factory: LoggerFactory,
// name: String,
// registry: Arc<dyn MetricsRegistry>,
// firehose_endpoints: FirehoseEndpoints,
// chain_store: Arc<dyn ChainStore>,
// block_stream_builder: Arc<dyn BlockStreamBuilder<Self>>,
// ) -> Self {
impl BlockchainBuilder<Chain> for BasicBlockchainBuilder {
fn build(self, _config: &Arc<EnvVars>) -> Chain {
Chain {
Expand Down Expand Up @@ -383,31 +374,28 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
panic!("Should never be called since not used by FirehoseBlockStream")
}

// Used for reprocessing blocks when creating a data source.
#[allow(unused)]
async fn triggers_in_block(
&self,
logger: &Logger,
block: codec::Block,
filter: &crate::adapter::TriggerFilter,
) -> Result<BlockWithTriggers<Chain>, Error> {
// We can't do any filtering here as `TriggerFilter` is useless.
// TODO: implement trigger filtering once `TriggerFilter` actually does something.

let shared_block = Arc::new(block.clone());

let mut triggers: Vec<_> = shared_block
.transactions
.iter()
.flat_map(|transaction| -> Vec<StarknetTrigger> {
let transaction = Arc::new(transaction.clone());
transaction
.events
.iter()
.map(|event| {
StarknetTrigger::Event(StarknetEventTrigger {
event: Arc::new(event.clone()),
block: shared_block.clone(),
transaction: Arc::new(transaction.clone()),
transaction: transaction.clone(),
})
})
.collect()
Expand Down
3 changes: 1 addition & 2 deletions chain/starknet/src/codec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#[allow(clippy::all)]
#[rustfmt::skip]
#[path = "protobuf/zklend.starknet.r#type.v1.rs"]
pub mod pbcodec;
mod pbcodec;

use graph::blockchain::{Block as BlockchainBlock, BlockHash, BlockPtr};

Expand Down
Loading

0 comments on commit 7dbd2f0

Please sign in to comment.