Skip to content

tx-generator: reusable API and library #4460

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

Merged
merged 18 commits into from
Nov 14, 2022

Conversation

mgmeier
Copy link
Contributor

@mgmeier mgmeier commented Sep 21, 2022

No description provided.

@mgmeier mgmeier added the WIP Work In Progress (cannot be merged yet) label Sep 21, 2022
@mgmeier mgmeier force-pushed the tx-generator/4174-reusable-api-and-library branch 2 times, most recently from 727f7db to 2d0f5e6 Compare September 29, 2022 08:00
@mgmeier mgmeier force-pushed the tx-generator/4174-reusable-api-and-library branch 2 times, most recently from 4f9de53 to 3d1700d Compare October 6, 2022 16:35
mgmeier and others added 18 commits November 11, 2022 11:48
* hide-env

Get some more privacy around the environment passed around in Action.
This wraps the Env type alias in a discriminated union to generate type
errors on usage, then moves direct accesses to Env and wraps the original
usage in an API or moves the code to the Env module.

* SetKeyVal exposes an inextricable precursor to the Generic usage in the
Env DMap via a Generic in the Set case of Action. So this limits usage
of the SetKeyVal type alias to the Types module momentarily to limit
exposure of the Generic that packages key-value pairs for insertion
into the DMap.

* Hide usage of Action Set case in setConst.

This moves the access to the Set case of action exposing SetKeyVal into
Types.hs; the wrapper may move again, but the caller will be insulated.

* Monomorphise the User case of the Store type.

This splits it up into SNetworkId and SSocketPath and removes the old
User constructor. A sweep is done and accessors in Env likewise changed.

* Remove Tag, Setters

This monomorphises Action's Set case in order to remove the last
dependencies on Setters.Tag via SetKeyVal. The Setters file is
removed from the tree and the cabal file as well.

* Remove unSet & consumeName

There are no callers outside Env.

* Fold Name into Store

This trades in the Named case of Store for the various cases of Name.
getName & setName are bypassed in favour of get/set of the Store
directly.

* Remove [gs]et(NetworkId|SocketPath) accessors.

They're not abstracting much as the approach is from a different
direction. They don't save much typing, either. It saves a few
lines & saves some module dependencies.

* Remove LoggingLayer case of Store.

Searching revealed no use cases of the LoggingLayer case. This reduces
the number of distinct cases needed to remove from the Env DMap.

* Remove ProtocolParameterMode case from Store

It largely represents a sort of individual state variable, so the
corresponding dmap entry in Env is replaced with an additional
record field. Accessors replace the usage of the case of Store.

* Remove BenchTracers case from Store

A pair of get & set accessors is coupled with a record field in Env
to replace the usage of the Store case in the Env DMap.

* Remove Genesis case of Store

This adds an Env record field to replace the Genesis DMap entry and
sweeps uses of the Store case/constructor replacing with accessors.

* Share Env accessor code

The Env accessors were duplicating a lot of code, so this just does
some lambda lifting across the minor differences. The subroutines for
the shared code are likely worth using to replace the accessors
outright given an audit of record field names for name clashes &
renaming for more brevity.

* Remove Protocol case of Store

It's replaced with a record field in Env and accessors to get & set it.

* Env hlint warning cleanup

I inadvertently introduced hlint warnings in this branch by dint of some
cut & paste of unnecessary $'s. This should hopefully dispose of them,
but I'll have to find out how to run hlint in the build system to be
sure.

* Fix extraneous parentheses flagged by hlint

* Remove SNetworkId case of Store

This replaces the SNetworkId case of Store with a monomorphic NetworkId
record field of Env.

* Remove SSocketPath from Store

This folds the socket's FilePath into a record field of Env.

* Remove KeyName case from Store

This replaces the KeyName case with a monomorphic Map in Env. Helpers
are set up to help subsequent wallet & thread patches. Some testing will
be needed to ensure there's no impact on Aeson's JSON formatting.

* Remove ThreadName from Store

This removes the ThreadName constructor from Store and replaces it with
a monomorphic Map in the Env structure and accessors.

* Remove Store altogether

This removes the use of the WalletName type alias, WalletName
constructor, and the entire Store module, moving its remainder to
Script/Types. At the end of this, the use of the Generic DMap is also
removed altogether in Env. The cabal file is updated to reflect the
removal of the Store.hs source file.

Co-authored-by: Michael Karg <[email protected]>
@mgmeier mgmeier force-pushed the tx-generator/4174-reusable-api-and-library branch from 34b5a7d to c2e8693 Compare November 11, 2022 13:07
@mgmeier mgmeier removed the WIP Work In Progress (cannot be merged yet) label Nov 14, 2022
@mgmeier
Copy link
Contributor Author

mgmeier commented Nov 14, 2022

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 14, 2022

👎 Rejected by too few approved reviews

@deepfire deepfire marked this pull request as ready for review November 14, 2022 14:46
@deepfire deepfire self-requested a review as a code owner November 14, 2022 14:46
Copy link
Contributor

@deepfire deepfire left a comment

Choose a reason for hiding this comment

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

Thank you @mgmeier !

This is an important first step towards the pure API.

@mgmeier
Copy link
Contributor Author

mgmeier commented Nov 14, 2022

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 14, 2022

Build succeeded:

@iohk-bors iohk-bors bot merged commit 32e0470 into master Nov 14, 2022
@iohk-bors iohk-bors bot deleted the tx-generator/4174-reusable-api-and-library branch November 14, 2022 15:43
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