Skip to content

Add Crosschain Batcher contract#747

Closed
hieronx wants to merge 5 commits intoelectisec-v31-fixesfrom
crosschain-batcher
Closed

Add Crosschain Batcher contract#747
hieronx wants to merge 5 commits intoelectisec-v31-fixesfrom
crosschain-batcher

Conversation

@hieronx
Copy link
Contributor

@hieronx hieronx commented Oct 16, 2025

No description provided.

@hieronx hieronx requested a review from lemunozm October 16, 2025 16:11
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Some comments


if (what == "gateway") gateway = IGateway(data);
else if (what == "feeHook") feeHook = IFeeHook(data);
if (what == "feeHook") feeHook = IFeeHook(data);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we allow to set the batcher?

function withBatch(bytes memory data, uint256 value, address refund) public payable {
require(value <= msg.value, NotEnoughValueForCallback());

gateway.startBatching();
Copy link
Contributor

Choose a reason for hiding this comment

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

The previous isBatching was there to be able to nest batches, which I think it's something cool to allow integrators to have integrators on top, so I would keep it.

}

/// @inheritdoc ICrosschainBatcher
function file(bytes32 what, address data) external auth {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to add root to the deployer, and also allow crosschainBatcher to modify gateway stuff through rely

isBatching = true;

function startBatching() external auth {
_batcher = msg.sender;
Copy link
Contributor

Choose a reason for hiding this comment

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

Batcher not needed here, right?

Comment on lines +266 to +269
//----------------------------------------------------------------------------------------------
// View methods
//----------------------------------------------------------------------------------------------

Copy link
Contributor

Choose a reason for hiding this comment

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

Can be removed because there are no view methods?

using MathLib for *;
using CastLib for bytes32;

IGateway public gateway;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not needed, or is it there for integrators?


spoke.crosschainTransferShares{
value: gateway.isBatching() ? 0 : msg.value
value: msgValue()
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

Comment on lines +33 to +47
contract MockGateway {
address internal transient _batcher;

function startBatching() external {
_batcher = msg.sender;
}

function endBatching(address) external payable {
_batcher = address(0);
}

function batcher() external view returns (address) {
return _batcher;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you don't need this here right? Only multicall calls withBatch, and it's already tested under BatchedMulticall

@@ -912,24 +905,30 @@ contract AttackerIntegrationMock is Test {
}

contract GatewayTestWithBatch is GatewayTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test should be moved to CrosschainBatcher.t.sol

@github-actions
Copy link

Coverage after merging crosschain-batcher into electisec-v31-fixes will be

98.91%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src/adapters
   AxelarAdapter.sol97.67%90%100%100%118
   LayerZeroAdapter.sol98.41%90%100%100%124
   RecoveryAdapter.sol100%100%100%100%
   WormholeAdapter.sol97.67%90%100%100%108
src/admin
   OpsGuardian.sol100%100%100%100%
   ProtocolGuardian.sol100%100%100%100%
   Root.sol100%100%100%100%
   TokenRecoverer.sol100%100%100%100%
src/core/hub
   Accounting.sol94.79%88%100%96.61%132, 134, 137, 141, 144
   Holdings.sol97.71%88.89%100%100%116, 237, 82
   Hub.sol93.65%79.25%93.02%97.54%269, 287, 305, 339, 343, 374–375, 413, 497–498, 543, 548, 585, 600, 74, 87
   HubHandler.sol98%90.91%100%100%71
   HubRegistry.sol92.39%76.67%100%100%118, 124, 130, 35, 46, 79, 99
   ShareClassManager.sol100%100%100%100%
src/core/libraries
   PricingLib.sol100%100%100%100%
src/core/messaging
   CrosschainBatcher.sol82.61%80%80%84.62%20–21, 21, 21–23, 28
   GasService.sol97.94%100%100%96.92%106, 116
   Gateway.sol100%100%100%100%
   MessageDispatcher.sol99.60%98.55%100%100%699
   MessageProcessor.sol83.51%60.53%100%99.07%102, 105, 112, 115, 117, 128, 133, 142, 145, 148, 160, 163, 166, 171, 181, 184, 193, 196, 199, 212, 223, 228, 231, 235, 86, 88–89, 92–93, 96–97
   MultiAdapter.sol100%100%100%100%
src/core/messaging/libraries
   MessageLib.sol100%100%100%100%
src/core/spoke
   BalanceSheet.sol99.41%96.15%100%100%63
   PoolEscrow.sol100%100%100%100%
   ShareToken.sol92.41%60%94.44%98.04%100, 112, 144, 146, 32
   Spoke.sol97.40%89.39%100%100%131, 131–132, 132, 134, 91–92
   VaultRegistry.sol95.65%90.32%100%98.11%54, 60–62
src/core/spoke/factories
   PoolEscrowFactory.sol100%100%100%100%
   TokenFactory.sol100%100%100%100%
src/core/utils
   BatchedMulticall.sol100%100%100%100%
   ContractUpdater.sol100%100%100%100%
src/hooks
   BaseTransferHook.sol98.48%100%95.83%98.80%108
   FreelyTransferable.sol92.31%80%100%100%36
   FreezeOnly.sol100%100%100%100%
   FullRestrictions.sol95.24%88.89%100%100%44
   RedemptionRestrictions.sol85.71%50%100%100%36
src/hooks/libraries
   UpdateRestrictionMessageLib.sol90%50%100%100%40, 61, 82
src/managers/hub
   NAVManager.sol100%100%100%100%
   SimplePriceManager.sol100%100%100%100%
src/managers/spoke
   MerkleProofManager.sol97.01%87.50%100%100%103, 110
   OnOfframpManager.sol100%100%100%100%
   QueueManager.sol100%100%100%100%
src/managers/spoke/decoders
   BaseDecoder.sol100%100%100%100%
   CircleDecoder.sol83.33%100%100%75%22
   VaultDecoder.sol100%100%100%100%
src/misc
   Auth.sol100%100%100%100%
   ERC20.sol100%100%100%100%
   Escrow.sol56.25%33.33%100%66.67%17, 19, 23–24, 24, 24, 26
   Multicall.sol83.33%33.33%100%100%19, 19
   Recoverable.sol100%100%100%100%
   ReentrancyProtection.sol90%75%100%100%24
src/misc/libraries
   ArrayLib.sol100%100%100%100%
   BitmapLib.sol100%100%100%100%
   BytesLib.sol90.27%56%100%100%109, 120, 131, 14, 142, 153, 16, 164, 175, 186, 87
   CastLib.sol95.24%66.67%100%100%10, 34
   EIP712Lib.sol100%100%100%100%
   MathLib.sol93.46%76.19%100%97.33%34–35, 44, 46, 48, 50, 52
   MerkleProofLib.sol100%100%100%100%
   SafeTransferLib.sol96.97%92.86%100%100%75
   SignatureLib.sol95.24%80%100%100%17
   StringLib.sol100%100%100%100%
   TransientArrayLib.sol100%100%100%100%
   TransientBytesLib.sol100%100%100%100%
   TransientStorageLib.sol100%100%100%100%
src/valuations
   IdentityValuation.sol100%100%100%100%
   OracleValuation.sol100%100%100%100%
src/vaults
   AsyncRequestManager.sol96.34%84.95%100%99.63%193, 217, 220, 223, 226, 237, 249, 313, 347, 461, 466, 505, 507, 556, 563
   AsyncVault.sol96.25%83.33%95%98.15%147, 48
   BaseVaults.sol92.50%80.77%95.24%93.94%126, 139, 241, 311–312, 398–399, 87–88, 88, 88–90
   BatchRequestManager.sol100%100%100%100%
   RefundEscrow.sol100%100%100%100%
   SyncDepositVault.sol100%100%100%100%
   SyncManager.sol96.45%88.89%100%97.89%103–104, 106, 64, 69
   VaultRouter.sol87.31%52%100%94.19%116, 116, 118–119, 119, 121, 132–133, 152, 152, 164, 207, 79, 82–83, 95–96
src/vaults/factories
   AsyncVaultFactory.sol89.47%50%100%93.33%35, 47
   RefundEscrowFactory.sol100%100%100%100%
   SyncDepositVaultFactory.sol91.30%50%100%94.74%44, 59
src/vaults/libraries
   RequestCallbackMessageLib.sol89.58%50%100%100%104, 139, 38, 57, 77
   RequestMessageLib.sol89.74%50%100%100%37, 55, 72, 89

@hieronx hieronx closed this Oct 16, 2025
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.

2 participants