-
Notifications
You must be signed in to change notification settings - Fork 13
[#526] Implement multiple validation modes #548
Conversation
5706b8e
to
bcffa9a
Compare
, Update.ppMaxBlockSize = 748 * pps ^. maxBkSz | ||
, Update.ppMaxHeaderSize = 95 * pps ^. maxHdrSz | ||
, Update.ppMaxBlockSize = 832 * pps ^. maxBkSz | ||
, Update.ppMaxHeaderSize = 569 * pps ^. maxHdrSz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these changes about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to add a comment explaining these. These seem to be the minimum constant multipliers that I can use for elaborating abstract size limits such that all tests still pass without returning "block too large" or "block header too large" errors.
In cardano-ledger-specs
, Size
s are represented differently than they are in the concrete implementation (where they're represented in actual bytes) and I'm unsure as to how we can accurately convert between the two.
bcffa9a
to
0b64a31
Compare
0b64a31
to
d6deeb1
Compare
abstractTxWits | ||
|
||
-- Validate the generated concrete transaction | ||
let pm = Dummy.aProtocolMagic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will address these Dummy.aProtocolMagic
s tomorrow.
I'm a bit confused by this, so sorry for the silly question:
Do we care about these scenarios? I thought this was about checking whether we would perform validation or not when applying a block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so quite a few changes here, but the general structure is good.
4b4445f
to
da3046c
Compare
foldUTxO env utxo blocks = S.foldM_ | ||
(foldUTxOBlock env) | ||
(pure utxo) | ||
pure | ||
(hoist (withExceptT ErrorParseError) blocks) | ||
(pure (hoist (withExceptT ErrorParseError) blocks)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something about pure
and hoist
being used like that strikes me as odd. Its almost as if you need a transformers version of Control.Monad.join
.
foldChainValidationState config chainValState blocks = S.foldM_ | ||
(\cvs block -> | ||
withExceptT (EpochChainValidationError (blockOrBoundarySlot block)) | ||
$ updateChainBlockOrBoundary config cvs block | ||
) | ||
(pure chainValState) | ||
pure $ hoist (withExceptT EpochParseError) blocks | ||
pure (pure (hoist (withExceptT EpochParseError) blocks)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like above, pure . pure . hoist
seems weird.
da3046c
to
ff7c06b
Compare
791ad88
to
bd6b851
Compare
-- | ||
-- If we could find some way to convert the error type in a 'MonadError' then | ||
-- we could re-write 'wrapError' in a more abstract way. | ||
wrapExceptTError :: MonadError e' m => ExceptT e m a -> (e -> e') -> m a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@intricate what about:
wrapErrorWithValidationMode
:: (MonadError e' m, MonadReader ValidationMode m)
=> ReaderT ValidationMode (Either e a)
-> (e -> e')
-> m a
wrapErrorWithValidationMode readerAction = do
validationMode <- ask
runReaderT readerAction validationMode >>= \case
Left err -> throwError $ wrapper err
Right x -> pure x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if there are any type errors with that, but I think it should work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Only had to make a slight change to type sig
wrapErrorWithValidationMode
:: (MonadError e' m, MonadReader ValidationMode m)
=> ReaderT ValidationMode (Either e) a
-> (e -> e')
-> m a
-- | ||
-- If we could find some way to convert the error type in a 'MonadError' then | ||
-- we could re-write 'wrapError' in a more abstract way. | ||
wrapExceptTError :: MonadError e' m => ExceptT e m a -> (e -> e') -> m a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@intricate what about:
wrapErrorWithValidationMode
:: (MonadError e' m, MonadReader ValidationMode m)
=> ReaderT ValidationMode (Either e a)
-> (e -> e')
-> m a
wrapErrorWithValidationMode readerAction = do
validationMode <- ask
runReaderT readerAction validationMode >>= \case
Left err -> throwError $ wrapper err
Right x -> pure x
-- | ||
-- If we could find some way to convert the error type in a 'MonadError' then | ||
-- we could re-write 'wrapError' in a more abstract way. | ||
wrapExceptTError :: MonadError e' m => ExceptT e m a -> (e -> e') -> m a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if there are any type errors with that, but I think it should work
1ec04bb
to
5a0c845
Compare
5a0c845
to
0737b86
Compare
1418098
to
80a4361
Compare
80a4361
to
b764abe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good I think - worth several rounds of review :)
bors r+ |
Build succeeded |
Closes #526