Skip to content

Commit 0b717a0

Browse files
brandonilesBrandon Iles
andauthored
Certik Audit Recommendations (#151)
* Exhibit 1 * Exhibit 2 * Exhibit 5 * Exhibit 6 * Exhibit 7 * Exhibit 9 Co-authored-by: Brandon Iles <[email protected]>
1 parent fb6eab6 commit 0b717a0

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

contracts/Orchestrator.sol

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import "./UFragmentsPolicy.sol";
1313
contract Orchestrator is Ownable {
1414

1515
struct Transaction {
16+
bool enabled;
1617
address destination;
1718
bytes data;
18-
bool enabled;
1919
}
2020

2121
event TransactionFailed(address indexed destination, uint index, bytes data);
@@ -52,7 +52,7 @@ contract Orchestrator is Ownable {
5252
Transaction storage t = transactions[i];
5353
if (t.enabled) {
5454
bool result =
55-
externalCall(t.destination, 0, t.data.length, t.data);
55+
externalCall(t.destination, t.data);
5656
if (!result) {
5757
emit TransactionFailed(t.destination, i, t.data);
5858
}
@@ -70,9 +70,9 @@ contract Orchestrator is Ownable {
7070
onlyOwner
7171
{
7272
transactions.push(Transaction({
73+
enabled: true,
7374
destination: destination,
74-
data: data,
75-
enabled: true
75+
data: data
7676
}));
7777
}
7878

@@ -90,7 +90,6 @@ contract Orchestrator is Ownable {
9090
transactions[index] = transactions[transactions.length - 1];
9191
}
9292

93-
delete transactions[transactions.length - 1];
9493
transactions.length--;
9594
}
9695

@@ -109,7 +108,7 @@ contract Orchestrator is Ownable {
109108
/**
110109
* @return Number of transactions, both enabled and disabled, in transactions list.
111110
*/
112-
function transactionsLength()
111+
function transactionsSize()
113112
external
114113
view
115114
returns (uint256)
@@ -120,12 +119,10 @@ contract Orchestrator is Ownable {
120119
/**
121120
* @dev wrapper to call the encoded transactions on downstream consumers.
122121
* @param destination Address of destination contract.
123-
* @param transferValueWei ETH value to send, in wei.
124-
* @param dataLength Size of data param.
125122
* @param data The encoded data payload.
126123
* @return True on success
127124
*/
128-
function externalCall(address destination, uint transferValueWei, uint dataLength, bytes data)
125+
function externalCall(address destination, bytes data)
129126
internal
130127
returns (bool)
131128
{
@@ -147,9 +144,9 @@ contract Orchestrator is Ownable {
147144

148145

149146
destination,
150-
transferValueWei,
147+
0, // transfer value in wei
151148
dataAddress,
152-
dataLength, // Size of the input (in bytes). This is what fixes the padding problem
149+
mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
153150
outputAddress,
154151
0 // Output is ignored, therefore the output size is zero
155152
)

contracts/UFragmentsPolicy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ contract UFragmentsPolicy is Ownable {
8383
uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
8484

8585
// This module orchestrates the rebase execution and downstream notification.
86-
address public orchestrator = address(0x0);
86+
address public orchestrator;
8787

8888
modifier onlyOrchestrator() {
8989
require(msg.sender == orchestrator);

test/unit/Orchestrator.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ contract('Orchestrator', function (accounts) {
6161
});
6262

6363
it('should have no transactions', async function () {
64-
(await orchestrator.transactionsLength.call()).should.be.bignumber.eq(0);
64+
(await orchestrator.transactionsSize.call()).should.be.bignumber.eq(0);
6565
});
6666

6767
it('should call rebase on policy', async function () {
@@ -84,7 +84,7 @@ contract('Orchestrator', function (accounts) {
8484
});
8585

8686
it('should have 1 transaction', async function () {
87-
(await orchestrator.transactionsLength.call()).should.be.bignumber.eq(1);
87+
(await orchestrator.transactionsSize.call()).should.be.bignumber.eq(1);
8888
});
8989

9090
it('should call rebase on policy', async function () {
@@ -120,7 +120,7 @@ contract('Orchestrator', function (accounts) {
120120
});
121121

122122
it('should have 2 transactions', async function () {
123-
(await orchestrator.transactionsLength.call()).should.be.bignumber.eq(2);
123+
(await orchestrator.transactionsSize.call()).should.be.bignumber.eq(2);
124124
});
125125

126126
it('should call rebase on policy', async function () {
@@ -168,7 +168,7 @@ contract('Orchestrator', function (accounts) {
168168
});
169169

170170
it('should have 2 transactions', async function () {
171-
(await orchestrator.transactionsLength.call()).should.be.bignumber.eq(2);
171+
(await orchestrator.transactionsSize.call()).should.be.bignumber.eq(2);
172172
});
173173

174174
it('should call rebase on policy', async function () {
@@ -203,7 +203,7 @@ contract('Orchestrator', function (accounts) {
203203
});
204204

205205
it('should have 1 transaction', async function () {
206-
(await orchestrator.transactionsLength.call()).should.be.bignumber.eq(1);
206+
(await orchestrator.transactionsSize.call()).should.be.bignumber.eq(1);
207207
});
208208

209209
it('should call rebase on policy', async function () {
@@ -238,7 +238,7 @@ contract('Orchestrator', function (accounts) {
238238
});
239239

240240
it('should have 0 transactions', async function () {
241-
(await orchestrator.transactionsLength.call()).should.be.bignumber.eq(0);
241+
(await orchestrator.transactionsSize.call()).should.be.bignumber.eq(0);
242242
});
243243

244244
it('should call rebase on policy', async function () {
@@ -267,7 +267,7 @@ contract('Orchestrator', function (accounts) {
267267
});
268268

269269
it('should have 3 transactions', async function () {
270-
(await orchestrator.transactionsLength.call()).should.be.bignumber.eq(3);
270+
(await orchestrator.transactionsSize.call()).should.be.bignumber.eq(3);
271271
});
272272

273273
it('should call rebase on policy', async function () {
@@ -337,7 +337,7 @@ contract('Orchestrator', function (accounts) {
337337

338338
describe('setTransactionEnabled', async function () {
339339
it('should be callable by owner', async function () {
340-
(await orchestrator.transactionsLength.call()).should.be.bignumber.gt(0);
340+
(await orchestrator.transactionsSize.call()).should.be.bignumber.gt(0);
341341
expect(
342342
await chain.isEthException(
343343
orchestrator.setTransactionEnabled(0, true, {from: deployer})
@@ -346,7 +346,7 @@ contract('Orchestrator', function (accounts) {
346346
});
347347

348348
it('should be not be callable by others', async function () {
349-
(await orchestrator.transactionsLength.call()).should.be.bignumber.gt(0);
349+
(await orchestrator.transactionsSize.call()).should.be.bignumber.gt(0);
350350
expect(
351351
await chain.isEthException(
352352
orchestrator.setTransactionEnabled(0, true, {from: user})
@@ -357,7 +357,7 @@ contract('Orchestrator', function (accounts) {
357357

358358
describe('removeTransaction', async function () {
359359
it('should be not be callable by others', async function () {
360-
(await orchestrator.transactionsLength.call()).should.be.bignumber.gt(0);
360+
(await orchestrator.transactionsSize.call()).should.be.bignumber.gt(0);
361361
expect(
362362
await chain.isEthException(
363363
orchestrator.removeTransaction(0, {from: user})
@@ -366,7 +366,7 @@ contract('Orchestrator', function (accounts) {
366366
});
367367

368368
it('should be callable by owner', async function () {
369-
(await orchestrator.transactionsLength.call()).should.be.bignumber.gt(0);
369+
(await orchestrator.transactionsSize.call()).should.be.bignumber.gt(0);
370370
expect(
371371
await chain.isEthException(
372372
orchestrator.removeTransaction(0, {from: deployer})

0 commit comments

Comments
 (0)