Skip to content

Linked list offchain implementation#429

Open
SuganyaAK wants to merge 153 commits into
stagingfrom
linked-list-offchain-structure
Open

Linked list offchain implementation#429
SuganyaAK wants to merge 153 commits into
stagingfrom
linked-list-offchain-structure

Conversation

@SuganyaAK

Copy link
Copy Markdown
Contributor

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:

  1. Created a folder operator-directory and moved the files active-operator.ts, retired-operator.ts and registered-operator.ts under it
  2. state-queue.ts modified to hold latest mint and spend redeemers w.r.t on-chain code.

Cauterization and others added 30 commits October 23, 2025 11:51
@SuganyaAK SuganyaAK requested a review from keyan-m March 19, 2026 18:49

@keyan-m keyan-m 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.

Thanks Suganya, nice work so far.

@@ -150,10 +159,16 @@ export const incompleteActiveOperatorInitTxProgram = (
Effect.gen(function* () {
const rootData = "00";

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.

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).

Comment on lines +21 to +37
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;

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.

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.

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.

Perhaps we can move some of the functions here to operator-directory/internals.ts?

Comment thread demo/midgard-sdk/src/common.ts Outdated
Comment on lines +384 to +397
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;

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.

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.

Comment thread demo/midgard-sdk/src/linked-list.ts Outdated
Comment thread demo/midgard-sdk/src/state-queue.ts Outdated
Comment thread demo/midgard-sdk/src/state-queue.ts Outdated

const redeemer: StateQueueMintRedeemer = {
MergeToConfirmedState: {
headerNodeKey: firstBlockUTxO.assetName, // TODO: is the confirmedUTxO or firstBlockUTxO

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.

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.

@keyan-m keyan-m changed the base branch from Preliminary-Off-Chain-for-Tx-Orders to fix-scheduler April 24, 2026 22:03
Base automatically changed from fix-scheduler to staging May 9, 2026 08:20
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