Skip to content

Conversation

bmzig
Copy link
Contributor

@bmzig bmzig commented Jul 21, 2025

We need to know the pending root bundle's running balance totals, which is only retrievable by recomputing the pending root bundle's pool rebalance root.

@bmzig bmzig marked this pull request as ready for review July 22, 2025 01:07
@bmzig bmzig requested review from nicholaspai and pxrl July 22, 2025 20:31
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

One q

Signed-off-by: bennett <[email protected]>
@bmzig bmzig requested a review from nicholaspai July 25, 2025 21:52
Signed-off-by: bennett <[email protected]>
Signed-off-by: Bennett <[email protected]>
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

Ok I think this should work... best way to test is to wait until a new root bundle is proposed, then run the proposer locally using the same bundle block ranges.

Then, delete the ExecutedRootBundle events in the HubPoolClient locally so the just-recently executed bundle doesn't look like a "validated root bundle" and I think the running balances should match.

WDYT of this testing plan? I could be wrong

@bmzig
Copy link
Contributor Author

bmzig commented Aug 21, 2025

Ok I think this should work... best way to test is to wait until a new root bundle is proposed, then run the proposer locally using the same bundle block ranges.

Then, delete the ExecutedRootBundle events in the HubPoolClient locally so the just-recently executed bundle doesn't look like a "validated root bundle" and I think the running balances should match.

WDYT of this testing plan? I could be wrong

I think this works. I will try to get some comparisons here and then will bump package one last time.

@bmzig
Copy link
Contributor Author

bmzig commented Aug 26, 2025

Tested this with the above suggestion. I specifically indexed this by this.proposedRootBundles - 2, forced entry into this branch, and then overwrote latestMainnetBlock here to a block behind the l1 pool rebalance leaf execution which preceded the bundle I was trying to match.

Under this setup, I have been able to reproduce identical bundles as the one actually proposed.

}
});
});
const poolRebalanceLeaves: PoolRebalanceLeaf[] = constructPoolRebalanceLeaves(
Copy link
Member

Choose a reason for hiding this comment

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

nit: consider refactoring this constructing leaf section into shared function if its clean, but perhaps you've thought of this

Copy link
Contributor Author

@bmzig bmzig Aug 26, 2025

Choose a reason for hiding this comment

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

I thought the cleanest way would be to make _buildHistorical... and _buildOptimistic... return runningBalances, chainWithRefundsOnly, and realizedLpFees back to _buildPoolRebalanceRoot so that it can centralize the building there, but the issue I ran into was calling _buildHistoricalPoolRebalanceRoot in _buildOptimisticPoolRebalanceRoot since that function actually needs to have the tree/pool rebalance leaves. I think that means we would need this function to be called in both _buildOptimisticPoolRebalanceRoot and _buildHistoricalPoolRebalanceRoot, and the issue with that is we need to pass in everything constructPoolRebalanceLeaves needs to have, so it would really just add to the diff by a decent amount.

Signed-off-by: bennett <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants