Open trajan0x opened 3 months ago
To address the redundant ChainID calls in handleBridgeRequestedLog
, follow these steps:
Modify NewChain
to accept a ChainID parameter:
func NewChain(client *ethclient.Client, chainID *big.Int) (*Chain, error) {
// existing code
}
Update the call to NewChain
in chainIDToChain
to pass the ChainID:
func chainIDToChain(chainID *big.Int) (*Chain, error) {
client, err := ethclient.Dial(url)
if err != nil {
return nil, err
}
return NewChain(client, chainID)
}
Ensure handleBridgeRequestedLog
retrieves and passes the ChainID:
func handleBridgeRequestedLog(log types.Log) error {
chainID := getChainIDFromLog(log) // Implement this function to extract ChainID from log
chain, err := chainIDToChain(chainID)
if err != nil {
return err
}
// existing code
}
These changes will eliminate the redundant ChainID RPC calls.
/services/scribe/config/chain.go /packages/sdk-router/src/sdk.test.ts /agents/contracts/test/attestationharness/generate.go /services/rfq/tools/rfqdecoder /services/scribe/config/config.go /packages/contracts-rfq/deployments/base_sepolia /packages/contracts-rfq/deployments/op_sepolia /services/rfq /services/omnirpc/chainmanager/mocks /ethergo/chain/logger.go /services/rfq/tools/rfqdecoder/main.go /agents/contracts/test/snapshotharness/generate.go /packages/contracts-rfq/deployments/eth_sepolia /services/rfq/api/model/response.go /contrib/screener-api/chainalysis/doc.go /services/explorer/backfill /services/rfq/relayer/service/statushandler.go /services/rfq/tools /packages/contracts-rfq/deployments/base /services/scribe/service/chain.go /services/rfq/guard/service/handlers.go /services/rfq/relayer/chain /packages/contracts-rfq/deployments/optimism /ethergo/chaindata/chaindata.go /ethergo/chain/chain.go
I was drilling down into the performance of handleBridgeRequestedLog and noticed we could probably shave almost half a second off by removing some redundant calls:
chain.NewChain
does not know it's own chainID and must do an RPC call to get it. By passing this in, we could get rid of these calls.This calls presence has two deleterious effects:
chainIDToChain
and therefore ends up getting called twice on every singel request (although only once when forwarding is in use):