Linked list offchain implementation#429
Conversation
This reverts commit d620a1f.
…ffchain-structure
keyan-m
left a comment
There was a problem hiding this comment.
Thanks Suganya, nice work so far.
| @@ -150,10 +159,16 @@ export const incompleteActiveOperatorInitTxProgram = ( | |||
| Effect.gen(function* () { | |||
| const rootData = "00"; | |||
There was a problem hiding this comment.
The underlying root_data for all operator Elements is now an empty bytearray (defined under onchain/aiken/lib/midgard/common/constants.ak and types.ak, and also operator-directory.ak).
| export const RegisteredElementDataSchema = Data.Enum([ | ||
| Data.Object({ Root: Data.Bytes() }), | ||
| Data.Object({ Node: RegisteredNodeDataSchema }), | ||
| ]); | ||
| export type RegisteredElementData = Data.Static< | ||
| typeof RegisteredElementDataSchema | ||
| >; | ||
| export const RegisteredElementData = | ||
| RegisteredElementDataSchema as unknown as RegisteredElementData; | ||
|
|
||
| export const RegisteredElementSchema = Data.Object({ | ||
| data: RegisteredElementDataSchema, | ||
| link: Data.Nullable(Data.Bytes()), | ||
| }); | ||
| export type RegisteredElement = Data.Static<typeof RegisteredElementSchema>; | ||
| export const RegisteredElement = | ||
| RegisteredElementSchema as unknown as RegisteredElement; |
There was a problem hiding this comment.
The issue with redefining these is that if Element ends up changing at some point, it won't automatically reflect here (we'd have to manually update this definition to keep the two in sync).
If you manage to find a way to define these such that they are derived from Element, it would be perfect. Otherwise, a similar approach to what we have in state-queue.ts would be preferrable. That is, the datum equals the generic Element (with no added info on its root and node data types), where internal helper functions are defined to extract the underlying data with proper types.
There was a problem hiding this comment.
Perhaps we can move some of the functions here to operator-directory/internals.ts?
| export const OperatorNodeDataSchema = Data.Object({ | ||
| bond_unlock_time: Data.Nullable(POSIXTimeSchema), | ||
| }); | ||
| export type OperatorNodeData = Data.Static<typeof OperatorNodeDataSchema>; | ||
| export const OperatorNodeData = | ||
| OperatorNodeDataSchema as unknown as OperatorNodeData; | ||
|
|
||
| export const OperatorElementDataSchema = Data.Enum([ | ||
| Data.Object({ Root: Data.Bytes() }), | ||
| Data.Object({ Node: OperatorNodeDataSchema }), | ||
| ]); | ||
| export type OperatorElementData = Data.Static<typeof OperatorElementDataSchema>; | ||
| export const OperatorElementData = | ||
| OperatorElementDataSchema as unknown as OperatorElementData; |
There was a problem hiding this comment.
In recent changes I've made to introduce a penalty mechanism for inactive operators, the datums of retired and active operators have diverged. While there is a chance they may converge again, I think it'd generally be better if we keep their datum definitions distinct.
We can abstract any shared logic in operator-directory/internals.ts.
|
|
||
| const redeemer: StateQueueMintRedeemer = { | ||
| MergeToConfirmedState: { | ||
| headerNodeKey: firstBlockUTxO.assetName, // TODO: is the confirmedUTxO or firstBlockUTxO |
There was a problem hiding this comment.
firstBlockUTxO is correct. But note that node keys are not the same as their asset names (node keys don't carry the prefixes).
Did you consider defining an ElementUTxO which derives from your AuthenticatedUTxO? In there it might make sense to define an optional key field, as root elements won't need it.
Aligns the off-chain TypeScript implementation with the on-chain Aiken validators for the state queue, active operators, retired operators, and registered operators modules, following the migration to the new aiken_design_patterns/linked_list structure.
Files changed:
operator-directoryand moved the filesactive-operator.ts,retired-operator.tsandregistered-operator.tsunder itstate-queue.tsmodified to hold latest mint and spend redeemers w.r.t on-chain code.