Skip to content

Commit 880a671

Browse files
authored
fix: use abi.encode for hashing arrays (XMTP-10) (#165)
Change hashing of nodeIds_ to use abi.encode in PayerReportManager to address XMTP-10 This pull request updates the hashing logic in the PayerReportManager contract to use abi.encode for nodeIds_ when computing the keccak256 that combines endSequenceId_, endMinuteSinceEpoch_, payersMerkleRoot_, and the nodeIds_ hash. It also updates unit tests to reflect the new computed values. Modify PayerReportManager to replace abi.encodePacked(nodeIds_) with abi.encode(nodeIds_) in the hash computation in PayerReportManager.sol Update three expected bytes32 constants in tests to match the new hash results in PayerReportManager.t.sol
1 parent ca2248a commit 880a671

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/settlement-chain/PayerReportManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ contract PayerReportManager is IPayerReportManager, Initializable, Migratable, E
374374
endSequenceId_,
375375
endMinuteSinceEpoch_,
376376
payersMerkleRoot_,
377-
keccak256(abi.encodePacked(nodeIds_))
377+
keccak256(abi.encode(nodeIds_))
378378
)
379379
)
380380
);

test/unit/PayerReportManager.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ contract PayerReportManagerTests is Test {
11861186
payersMerkleRoot_: bytes32(uint256(5)),
11871187
nodeIds_: new uint32[](6)
11881188
}),
1189-
0xe95b9352b7afb9da83952cce75aba1d466ed7daeafc009c1964b85b8fe08bc09
1189+
0xdde54243da83f4b7c3fa535080f6cd0441fda0649edb15d95551f895a3529dfc
11901190
);
11911191

11921192
assertEq(
@@ -1198,7 +1198,7 @@ contract PayerReportManagerTests is Test {
11981198
payersMerkleRoot_: bytes32(uint256(50)),
11991199
nodeIds_: new uint32[](60)
12001200
}),
1201-
0x1dcb9deef4cebf9e13169296e27dee6166ed09af01b62f5c65dff9b3a9afb82d
1201+
0xb70f0c64254571c8cc5f6a84339bae9a135744d1f8059a3908121c95b40529f7
12021202
);
12031203
}
12041204

@@ -1222,7 +1222,7 @@ contract PayerReportManagerTests is Test {
12221222
payersMerkleRoot_: payersMerkleRoot_,
12231223
nodeIds_: nodeIds_
12241224
}),
1225-
0x79f316f2836745161f3020e431db382ce57aab339df1429de068a62bf940295b
1225+
0x68e2a926d1e4309c70d546f976fc17eacc87d245862ad8a5d9c80b86e1dd4d61
12261226
);
12271227
}
12281228

0 commit comments

Comments
 (0)