Skip to content

Add a running mode to PSR - #154

Merged
adithyaov merged 1 commit into
mainfrom
back-supp
Mar 6, 2026
Merged

adithyaov merged 1 commit into
mainfrom
back-supp

Conversation

@adithyaov

Copy link
Copy Markdown
Member
  • Test

@tweag-ev-ak tweag-ev-ak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGMT 👍

Comment thread lib/PSR/Streaming.hs
Comment on lines +368 to +371
res <- Stream.uncons (streamBlocks metrics events cm points)
case res of
Nothing -> pure ()
Just ((previousChainPt, Block _ sbe _), blkStream) -> void $ do

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

for_ might be an option here

Comment thread lib/PSR/ContextBuilder.hs
Comment on lines +179 to +186
interestingScripts =
Map.restrictKeys cmScripts $
Set.unions
[ getMintPolicies tx
, getInputScriptAddrs inpUtxoMap tx
, getCertifyingScriptHashes tx
, getRewardingScriptHashes tx
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this ever get computed again? Just wondering if it's worth having this just return the set and call not . null where the bool is needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

At the moment it is never computed again. We may want to change it later though depending on how it evolves.

Comment thread lib/PSR/Streaming.hs
Comment on lines +292 to +295
observeDuration metrics.mainLoop_consumeBlock_runtime $ do
case proveAlonzoEraOnwards sbe of
Nothing -> pure ()
Just era -> withAlonzoEra era bh previousChainPt txList

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we move the observeDuration inside the case statement? No point measuring the time for the Nothing case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We could do that. That said, the metric is called "mainLoop_consumeBlock_runtime"

Comment thread lib/PSR/Streaming.hs
Comment on lines +341 to +344
observeDuration metrics.mainLoop_consumeBlock_runtime $ do
case proveAlonzoEraOnwards sbe of
Nothing -> pure prevUtxoMap
Just era -> withAlonzoEra era bh prevUtxoMap previousChainPt txList

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same thing here.

Comment thread lib/PSR/Streaming.hs
-- 1. The block has transactions that involve script executions
-- 2. These scripts have a non-empty intersection with the configured
-- scripts
when (not (null selectedTxs)) $ do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
when (not (null selectedTxs)) $ do
unless (null selectedTxs) $ do

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

unless always confuses me for some reason.

Comment thread dev-local/Main.hs
writeFile
(env_LOCAL_CONFIG_DIR </> "scripts.yaml")
[str|
running_mode: sync_initial_local_state

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personally I'd prefer PascalCase here, but not a big deal one way or the other. Just makes finding the appropriate code a bit easier when the enum and its representation are the same.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll track this in an issue.

@adithyaov
adithyaov merged commit 7e5fd82 into main Mar 6, 2026
2 checks passed
@adithyaov
adithyaov deleted the back-supp branch March 6, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants