Skip to content

Preliminary Off-Chain for Deposits#342

Open
VenInf wants to merge 286 commits into
mainfrom
basic-deposit
Open

Preliminary Off-Chain for Deposits#342
VenInf wants to merge 286 commits into
mainfrom
basic-deposit

Conversation

@VenInf

@VenInf VenInf commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@keyan-m keyan-m linked an issue Sep 22, 2025 that may be closed by this pull request
4 tasks
@VenInf VenInf marked this pull request as ready for review September 25, 2025 10:10

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

Nice work :) Some of the files need rearrangements.

Comment thread demo/midgard-node/blueprints/always-succeeds/validators/always-succeeds.ak Outdated
Comment thread demo/midgard-node/src/services/always-succeeds.ts Outdated
Comment thread demo/midgard-sdk/src/endpoints/user-events/deposit/fetch.ts Outdated
Comment thread demo/midgard-sdk/src/tx-builder/index.ts Outdated
Comment thread demo/midgard-sdk/src/utils/deposit.ts Outdated
Comment thread demo/midgard-sdk/src/utils/deposit.ts Outdated
Comment thread demo/midgard-sdk/src/utils/index.ts Outdated
@VenInf VenInf requested a review from keyan-m October 7, 2025 15:53

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

Nice progress @VenInf 👍 I'll revise the issue so that it'll detail the pivot to a fiber vs. a worker.

You probably can start adding the table for deposits :)

Comment thread demo/midgard-sdk/src/utils/user-events/deposit.ts Outdated
Comment thread demo/midgard-sdk/src/endpoints/user-events/deposit/fetch.ts Outdated
@keyan-m keyan-m linked an issue Oct 9, 2025 that may be closed by this pull request
4 tasks

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

Looking good 👍 We can start focusing on proper time management next.

Comment on lines +37 to +38
const LATEST_DEPOSIT_FETCH_TIME: Ref.Ref<bigint> = yield* Ref.make(
BigInt(0),

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.

This and LATEST_SYNC_OF_STATE_QUEUE_LENGTH should be of the same type, i.e. either both of type number or both of type bigint.

// TODO?: We might be able to avoid `as` here.
const UNCONFIRMED_SUBMITTED_BLOCK: Ref.Ref<"" | TxHash> = yield* Ref.make(
"" as "" | TxHash,
const UNCONFIRMED_SUBMITTED_BLOCK_HASH: Ref.Ref<"" | TxHash> =

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.

UNCONFIRMED_SUBMITTED_BLOCK_HASH implies this stores the header hash, but this hash is the transaction hash that had submitted the block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wonder, do you have any suggestions for a variable name in mind?
The same goes for LATEST_SYNC_OF_STATE_QUEUE_LENGTH, the name doesn't reflect that it has anything to do with time -- I assumed that it's a queue length.

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.

I think either UNCONFIRMED_SUBMITTED_BLOCK or UNCONFIRMED_SUBMITTED_BLOCK_TX_HASH would be fine.

For LATEST_SYNC_OF_STATE_QUEUE_LENGTH my thinking was that the term "latest" would sufficiently imply its temporal nature. If you prefer a more explicit name perhaps we can go with LATEST_SYNC_TIME_OF_STATE_QUEUE_LENGTH, although I think I prefer the former.

depositUTxO: Deposit.DepositUTxO,
inclusionStartTime: POSIXTime,
inclusionEndTime: POSIXTime,
): Boolean => {

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.

Suggested change
): Boolean => {
): boolean => {

): Boolean => {
const depositData = depositUTxO.datum;
return (
inclusionStartTime <= depositData.inclusionTime &&

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.

Let's make the lower bound exclusive for now.

Suggested change
inclusionStartTime <= depositData.inclusionTime &&
inclusionStartTime < depositData.inclusionTime &&

Comment thread demo/midgard-node/src/database/deposits.ts Outdated
export type SuccessfulSubmissionOutput = {
type: "SuccessfulSubmissionOutput";
submittedTxHash: string;
submittionTime: bigint;

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.

No need to pass back the upper bound of a submitted block. We only care about the upper bound of a submitted block after it's been confirmed on L1 (which we can retrieve from its global variable).

Suggested change
submittionTime: bigint;

Comment thread demo/midgard-node/src/fibers/fetch-and-insert-deposit-utxos.ts
HarunJr and others added 29 commits January 7, 2026 17:51
- Use `Pick` for HubOracleValidators to ensure type consistency.
- Update HubOracleInitParams to nest validators in a dedicated object.
- Remove unnecessary datum parameter from Scheduler initialization.
- Standardize rootData initialization to "00" for Registered and Retired operators.
- Update initialization transaction programs to align with new type definitions.
- refactor(genesis): replace `getGenesisUtxosFromValidators` with `getGenesisScriptInputs` to generate index-to-hash mappings for the validator catalogue
- feat(initialization): update `computeGenesisMptRoot` to use `keyValueMptRoot` with the new catalogue inputs
- chore(mpt): remove unused `computeRootFromUtxos` helper
- fix(listen): update error handling to match new MPT root calculation return types
Maps 4-byte indices to Blake2b-224 validator script hashes per spec §4.1.

Uses concurrent hashing with deterministic ordering defined in VALIDATOR_ORDER.
Tests verify pre-image retrieval, determinism, and 28-byte hash format.

Note: Validator ordering should be verified against on-chain code before production.
- Complete hub oracle schema with all validator addresses and policy IDs
- Rename test file: mpt_roots.test.ts → fraud-proof-catalogue.test.ts
- Remove scheduler initialization datum
- Improve test validation to verify hash correctness
- Clean up test utilities (remove dotenv.config)
Expand the Initialization Process to Include All the Contracts
Failure of submitting a block with 0 tx requests with deposit events did
not revert the changes applied to the ledger trie.

This commit implements the reversal logic as a potentionally temporary
solution.
Also fixed inclusion time inclusivity.
@keyan-m keyan-m changed the title Basic Deposit Preliminary Off-Chain for Deposits Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants