Skip to content

Commit a90d5f7

Browse files
authored
fix: prevent xnet call messages with non-zero value from inflating child subnet circulating supply (#1353)
1 parent a826853 commit a90d5f7

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

contracts/contracts/gateway/router/CheckpointingFacet.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ contract CheckpointingFacet is GatewayActorModifiers {
116116
uint256 crossMsgLength = msgs.length;
117117

118118
for (uint256 i; i < crossMsgLength; ) {
119-
if (msgs[i].kind != IpcMsgKind.Call) {
120-
totalValue += msgs[i].value;
121-
}
119+
totalValue += msgs[i].value;
122120
unchecked {
123121
++i;
124122
}

contracts/test/integration/GatewayDiamond.t.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ contract GatewayActorDiamondTest is Test, IntegrationTestBase, SubnetWithNativeT
11631163
(, subnetInfo) = gatewayDiamond.getter().getSubnet(subnetId);
11641164
require(subnetInfo.circSupply == DEFAULT_COLLATERAL_AMOUNT, "unexpected circulation supply after funding");
11651165

1166+
uint256 totalAmount = 0;
11661167
IpcEnvelope[] memory msgs = new IpcEnvelope[](10);
11671168
for (uint64 i = 0; i < 10; i++) {
11681169
msgs[i] = TestUtils.newXnetCallMsg(
@@ -1174,6 +1175,8 @@ contract GatewayActorDiamondTest is Test, IntegrationTestBase, SubnetWithNativeT
11741175
amount,
11751176
i
11761177
);
1178+
1179+
totalAmount += amount;
11771180
}
11781181

11791182
BottomUpCheckpoint memory checkpoint = BottomUpCheckpoint({
@@ -1189,8 +1192,7 @@ contract GatewayActorDiamondTest is Test, IntegrationTestBase, SubnetWithNativeT
11891192
gatewayDiamond.checkpointer().commitCheckpoint(checkpoint);
11901193

11911194
(, subnetInfo) = gatewayDiamond.getter().getSubnet(subnetId);
1192-
// cross net messages with Call kind does not affect the circulating supply
1193-
require(subnetInfo.circSupply == DEFAULT_COLLATERAL_AMOUNT, "unexpected circulating supply");
1195+
require(subnetInfo.circSupply == DEFAULT_COLLATERAL_AMOUNT - totalAmount, "unexpected circulating supply");
11941196
}
11951197

11961198
function testGatewayDiamond_listIncompleteCheckpoints() public {

0 commit comments

Comments
 (0)