Skip to content

Commit b3ea280

Browse files
authored
Merge pull request #25 from proveuswrong/fix/struct-packing
fix: struct packing
2 parents e511fbf + 9cf8869 commit b3ea280

File tree

12 files changed

+72
-73922
lines changed

12 files changed

+72
-73922
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_format": "hh-sol-dbg-1",
3-
"buildInfo": "../../../../build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json"
3+
"buildInfo": "../../../../build-info/a2fe62b58fc12c346c5340a7b5bcf8aa.json"
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_format": "hh-sol-dbg-1",
3-
"buildInfo": "../../../../build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json"
3+
"buildInfo": "../../../../build-info/a2fe62b58fc12c346c5340a7b5bcf8aa.json"
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_format": "hh-sol-dbg-1",
3-
"buildInfo": "../../../../build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json"
3+
"buildInfo": "../../../../build-info/a2fe62b58fc12c346c5340a7b5bcf8aa.json"
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_format": "hh-sol-dbg-1",
3-
"buildInfo": "../../../../../build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json"
3+
"buildInfo": "../../../../../build-info/a2fe62b58fc12c346c5340a7b5bcf8aa.json"
44
}

artifacts/build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json

Lines changed: 0 additions & 73847 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_format": "hh-sol-dbg-1",
3-
"buildInfo": "../../build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json"
3+
"buildInfo": "../../build-info/a2fe62b58fc12c346c5340a7b5bcf8aa.json"
44
}

artifacts/contracts/ITruthPost.sol/ITruthPost.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,9 @@
453453
{
454454
"inputs": [
455455
{
456-
"internalType": "uint80",
456+
"internalType": "uint72",
457457
"name": "_articleStorageAddress",
458-
"type": "uint80"
458+
"type": "uint72"
459459
}
460460
],
461461
"name": "challenge",
@@ -466,9 +466,9 @@
466466
{
467467
"inputs": [
468468
{
469-
"internalType": "uint80",
469+
"internalType": "uint72",
470470
"name": "_articleStorageAddress",
471-
"type": "uint80"
471+
"type": "uint72"
472472
}
473473
],
474474
"name": "challengeFee",
@@ -550,9 +550,9 @@
550550
{
551551
"inputs": [
552552
{
553-
"internalType": "uint80",
553+
"internalType": "uint72",
554554
"name": "_searchPointer",
555-
"type": "uint80"
555+
"type": "uint72"
556556
}
557557
],
558558
"name": "findVacantStorageSlot",
@@ -752,9 +752,9 @@
752752
{
753753
"inputs": [
754754
{
755-
"internalType": "uint80",
755+
"internalType": "uint72",
756756
"name": "_articleStorageAddress",
757-
"type": "uint80"
757+
"type": "uint72"
758758
}
759759
],
760760
"name": "increaseBounty",
@@ -775,9 +775,9 @@
775775
"type": "uint8"
776776
},
777777
{
778-
"internalType": "uint80",
778+
"internalType": "uint72",
779779
"name": "_searchPointer",
780-
"type": "uint80"
780+
"type": "uint72"
781781
}
782782
],
783783
"name": "initializeArticle",
@@ -788,9 +788,9 @@
788788
{
789789
"inputs": [
790790
{
791-
"internalType": "uint80",
791+
"internalType": "uint72",
792792
"name": "_articleStorageAddress",
793-
"type": "uint80"
793+
"type": "uint72"
794794
}
795795
],
796796
"name": "initiateWithdrawal",
@@ -826,9 +826,9 @@
826826
{
827827
"inputs": [
828828
{
829-
"internalType": "uint80",
829+
"internalType": "uint72",
830830
"name": "_articleStorageAddress",
831-
"type": "uint80"
831+
"type": "uint72"
832832
},
833833
{
834834
"internalType": "address payable",
@@ -857,9 +857,9 @@
857857
{
858858
"inputs": [
859859
{
860-
"internalType": "uint80",
860+
"internalType": "uint72",
861861
"name": "_articleStorageAddress",
862-
"type": "uint80"
862+
"type": "uint72"
863863
}
864864
],
865865
"name": "withdraw",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_format": "hh-sol-dbg-1",
3-
"buildInfo": "../../build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json"
3+
"buildInfo": "../../build-info/a2fe62b58fc12c346c5340a7b5bcf8aa.json"
44
}

artifacts/contracts/TruthPost.sol/TruthPost.json

Lines changed: 22 additions & 22 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_format": "hh-sol-dbg-1",
3-
"buildInfo": "../../../build-info/42210c8f6ff26f1f3fc53ec8f01b8487.json"
3+
"buildInfo": "../../../build-info/a2fe62b58fc12c346c5340a7b5bcf8aa.json"
44
}

contracts/ITruthPost.sol

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ abstract contract ITruthPost {
7070
event TreasuryUpdate(address indexed _newTreasury);
7171
event TreasuryBalanceUpdate(uint256 indexed _byAmount);
7272

73-
7473
/// @notice Submit an evidence.
7574
/// @param _disputeID The dispute ID as in arbitrator.
7675
/// @param _evidenceURI IPFS path to evidence, example: '/ipfs/Qmarwkf7C9RuzDEJNnarT3WZ7kem5bk8DZAzx78acJjMFH/evidence.json'
@@ -91,48 +90,48 @@ abstract contract ITruthPost {
9190
function initializeArticle(
9291
string calldata _articleID,
9392
uint8 _category,
94-
uint80 _searchPointer
93+
uint72 _searchPointer
9594
) external payable virtual;
9695

9796
/// @notice Increase bounty.
9897
/// @dev Lets author to increase a bounty of a live article. Emits BalanceUpdate.
9998
/// @param _articleStorageAddress The address of the article in the storage.
100-
function increaseBounty(uint80 _articleStorageAddress) external payable virtual;
99+
function increaseBounty(uint72 _articleStorageAddress) external payable virtual;
101100

102101
/// @notice Initiate unpublishing process.
103102
/// @dev Lets an author to start unpublishing process. Emits TimelockStarted.
104103
/// @param _articleStorageAddress The address of the article in the storage.
105-
function initiateWithdrawal(uint80 _articleStorageAddress) external virtual;
104+
function initiateWithdrawal(uint72 _articleStorageAddress) external virtual;
106105

107106
/// @notice Execute unpublishing.
108107
/// @dev Executes unpublishing of an article. Emits Withdrew.
109108
/// @param _articleStorageAddress The address of the article in the storage.
110-
function withdraw(uint80 _articleStorageAddress) external virtual;
109+
function withdraw(uint72 _articleStorageAddress) external virtual;
111110

112111
/// @notice Challenge article.
113112
/// @dev Challenges the article at the given storage address. Emits Challenge.
114113
/// @param _articleStorageAddress The address of the article in the storage.
115-
function challenge(uint80 _articleStorageAddress) external payable virtual;
114+
function challenge(uint72 _articleStorageAddress) external payable virtual;
116115

117116
/// @notice Transfer ownership of an article.
118-
/// @dev Lets you to transfer ownership of an article.
119-
/// This is useful when you want to change owner account without withdrawing and resubmitting.
117+
/// @dev Lets you to transfer ownership of an article.
118+
/// This is useful when you want to change owner account without withdrawing and resubmitting.
120119
/// Emits OwnershipTransfer.
121120
/// @param _articleStorageAddress The address of article in the storage.
122121
/// @param _newOwner The new owner of the article which resides in the storage address, provided by the previous parameter.
123-
function transferOwnership(uint80 _articleStorageAddress, address payable _newOwner) external virtual;
122+
function transferOwnership(uint72 _articleStorageAddress, address payable _newOwner) external virtual;
124123

125124
/// @notice Update the arbitration cost for the winner.
126-
/// @dev Sets the multiplier of the arbitration cost that the winner has to pay as fee stake to a new value.
125+
/// @dev Sets the multiplier of the arbitration cost that the winner has to pay as fee stake to a new value.
127126
/// Emits WinnerStakeMultiplierUpdate.
128127
/// @param _newWinnerStakeMultiplier The new value of WINNER_STAKE_MULTIPLIER.
129128
function changeWinnerStakeMultiplier(uint256 _newWinnerStakeMultiplier) external virtual;
130129

131130
/// @notice Update the arbitration cost for the loser.
132-
/// @dev Sets the multiplier of the arbitration cost that the loser has to pay as fee stake to a new value.
131+
/// @dev Sets the multiplier of the arbitration cost that the loser has to pay as fee stake to a new value.
133132
/// Emits LoserStakeMultiplierUpdate.
134133
/// @param _newLoserStakeMultiplier The new value of LOSER_STAKE_MULTIPLIER.
135-
134+
136135
function changeLoserStakeMultiplier(uint256 _newLoserStakeMultiplier) external virtual;
137136

138137
/// @notice Update the appeal window for the loser.
@@ -141,20 +140,20 @@ abstract contract ITruthPost {
141140
function changeLoserAppealPeriodMultiplier(uint256 _newLoserAppealPeriodMultiplier) external virtual;
142141

143142
/// @notice Update the timelock for the article withdtrawal.
144-
/// @dev Sets the timelock before an author can initiate the withdrawal of an article to a new value.
143+
/// @dev Sets the timelock before an author can initiate the withdrawal of an article to a new value.
145144
/// Emits ArticleWithdrawalTimelockUpdate.
146145
/// @param _newArticleWithdrawalTimelock The new value of ARTICLE_WITHDRAWAL_TIMELOCK.
147146
function changeArticleWithdrawalTimelock(uint256 _newArticleWithdrawalTimelock) external virtual;
148147

149148
/// @notice Find a vacant storage slot for an article.
150149
/// @dev Helper function to find a vacant slot for article. Use this function before calling initialize to minimize your gas cost.
151150
/// @param _searchPointer Starting point of the search. If you do not have a guess, just pass 0.
152-
function findVacantStorageSlot(uint80 _searchPointer) external view virtual returns (uint256 vacantSlotIndex);
151+
function findVacantStorageSlot(uint72 _searchPointer) external view virtual returns (uint256 vacantSlotIndex);
153152

154153
/// @notice Get required challenge fee.
155154
/// @dev Returns the total amount needs to be paid to challenge an article, including taxes if any.
156155
/// @param _articleStorageAddress The address of article in the storage.
157-
function challengeFee(uint80 _articleStorageAddress) public view virtual returns (uint256 challengeFee);
156+
function challengeFee(uint72 _articleStorageAddress) public view virtual returns (uint256 challengeFee);
158157

159158
/// @notice Get required appeal fee and deposit.
160159
/// @dev Returns the total amount needs to be paid to appeal a dispute, including fees and stake deposit.

contracts/TruthPost.sol

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
3131
RulingOptions outcome;
3232
uint8 articleCategory;
3333
bool resolved; // To remove dependency to disputeStatus function of arbitrator. This function is likely to be removed in Kleros v2.
34-
uint80 articleStorageAddress; // 2^16 is sufficient. Just using extra available space.
34+
uint72 articleStorageAddress; // 2^16 is sufficient. Just using extra available space.
3535
Round[] rounds; // Tracks each appeal round of a dispute.
3636
}
3737

@@ -51,7 +51,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
5151

5252
bytes[64] public categoryToArbitratorExtraData;
5353

54-
mapping(uint80 => Article) public articleStorage; // Key: Storage address of article. Articles are not addressed with their identifiers, to enable reusing a storage slot.
54+
mapping(uint72 => Article) public articleStorage; // Key: Storage address of article. Articles are not addressed with their identifiers, to enable reusing a storage slot.
5555
mapping(uint256 => DisputeData) public disputes; // Key: Dispute ID as in arbitrator.
5656

5757
constructor(
@@ -71,7 +71,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
7171
function initializeArticle(
7272
string calldata _articleID,
7373
uint8 _category,
74-
uint80 _searchPointer
74+
uint72 _searchPointer
7575
) external payable override {
7676
require(_category < categoryCounter, "This category does not exist");
7777

@@ -100,7 +100,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
100100
}
101101

102102
/// @inheritdoc ITruthPost
103-
function increaseBounty(uint80 _articleStorageAddress) external payable override {
103+
function increaseBounty(uint72 _articleStorageAddress) external payable override {
104104
Article storage article = articleStorage[_articleStorageAddress];
105105
require(msg.sender == article.owner, "Only author can increase bounty of an article.");
106106
// To prevent mistakes.
@@ -114,7 +114,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
114114
}
115115

116116
/// @inheritdoc ITruthPost
117-
function initiateWithdrawal(uint80 _articleStorageAddress) external override {
117+
function initiateWithdrawal(uint72 _articleStorageAddress) external override {
118118
Article storage article = articleStorage[_articleStorageAddress];
119119
require(msg.sender == article.owner, "Only author can withdraw an article.");
120120
require(article.withdrawalPermittedAt == 0, "Withdrawal already initiated or there is a challenge.");
@@ -124,7 +124,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
124124
}
125125

126126
/// @inheritdoc ITruthPost
127-
function withdraw(uint80 _articleStorageAddress) external override {
127+
function withdraw(uint72 _articleStorageAddress) external override {
128128
Article storage article = articleStorage[_articleStorageAddress];
129129

130130
require(msg.sender == article.owner, "Only author can withdraw an article.");
@@ -144,7 +144,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
144144
}
145145

146146
/// @inheritdoc ITruthPost
147-
function challenge(uint80 _articleStorageAddress) external payable override {
147+
function challenge(uint72 _articleStorageAddress) external payable override {
148148
Article storage article = articleStorage[_articleStorageAddress];
149149
require(article.bountyAmount > 0, "Nothing to challenge.");
150150
require(article.withdrawalPermittedAt != type(uint32).max, "There is an ongoing challenge.");
@@ -164,7 +164,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
164164

165165
disputes[disputeID].challenger = payable(msg.sender);
166166
disputes[disputeID].rounds.push();
167-
disputes[disputeID].articleStorageAddress = uint80(_articleStorageAddress);
167+
disputes[disputeID].articleStorageAddress = uint72(_articleStorageAddress);
168168
disputes[disputeID].articleCategory = article.category;
169169

170170
// Evidence group ID is dispute ID.
@@ -275,7 +275,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
275275
RulingOptions actualRuling = wonByDefault != RulingOptions.Tied ? wonByDefault : RulingOptions(_ruling);
276276
dispute.outcome = actualRuling;
277277

278-
uint80 articleStorageAddress = dispute.articleStorageAddress;
278+
uint72 articleStorageAddress = dispute.articleStorageAddress;
279279

280280
Article storage article = articleStorage[articleStorageAddress];
281281

@@ -418,14 +418,13 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
418418
LOSER_APPEAL_PERIOD_MULTIPLIER = _newLoserAppealPeriodMultiplier;
419419
emit LoserAppealPeriodMultiplierUpdate(_newLoserAppealPeriodMultiplier);
420420
}
421-
421+
422422
/// @inheritdoc ITruthPost
423423
function changeArticleWithdrawalTimelock(uint256 _newArticleWithdrawalTimelock) external override onlyAdmin {
424424
ARTICLE_WITHDRAWAL_TIMELOCK = _newArticleWithdrawalTimelock;
425425
emit ArticleWithdrawalTimelockUpdate(_newArticleWithdrawalTimelock);
426426
}
427427

428-
429428
/// @notice Initialize a category.
430429
/// @param _metaevidenceIpfsUri IPFS content identifier for metaevidence.
431430
/// @param _arbitratorExtraData Extra data of Kleros arbitrator, signaling subcourt and jury size selection.
@@ -438,15 +437,15 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
438437
}
439438

440439
/// @inheritdoc ITruthPost
441-
function transferOwnership(uint80 _articleStorageAddress, address payable _newOwner) external override {
440+
function transferOwnership(uint72 _articleStorageAddress, address payable _newOwner) external override {
442441
Article storage article = articleStorage[_articleStorageAddress];
443442
require(msg.sender == article.owner, "Only author can transfer ownership.");
444443
article.owner = _newOwner;
445444
emit OwnershipTransfer(_newOwner);
446445
}
447446

448447
/// @inheritdoc ITruthPost
449-
function challengeFee(uint80 _articleStorageAddress) public view override returns (uint256) {
448+
function challengeFee(uint72 _articleStorageAddress) public view override returns (uint256) {
450449
Article storage article = articleStorage[_articleStorageAddress];
451450

452451
uint256 arbitrationFee = ARBITRATOR.arbitrationCost(categoryToArbitratorExtraData[article.category]);
@@ -463,7 +462,7 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
463462
}
464463

465464
/// @inheritdoc ITruthPost
466-
function findVacantStorageSlot(uint80 _searchPointer) external view override returns (uint256 vacantSlotIndex) {
465+
function findVacantStorageSlot(uint72 _searchPointer) external view override returns (uint256 vacantSlotIndex) {
467466
Article storage article;
468467
do {
469468
article = articleStorage[_searchPointer++];
@@ -603,5 +602,4 @@ contract TruthPost is ITruthPost, IArbitrable, IEvidence {
603602

604603
return totalCost - raisedSoFar;
605604
}
606-
607605
}

0 commit comments

Comments
 (0)