Skip to content

Commit b1161ef

Browse files
committed
chore: make compiler happy when optimizer is off
Somehow if we adding 'require' inside 'buildParams' in BondSize and use that in our Routers during their constructor, the compile would fail with the exception of "Assembly exception for bytecode". However, this would be fine if the optimizer is turned on. After a few tries, by making it being called in a non-constructor solves the compile issue. Thus, this commit changes the constructor for Routers to become a 'init' function instead. This was found because solidity coverage would force turning off the optimizer, see: sc-forks/solidity-coverage#417
1 parent cee1be7 commit b1161ef

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

plasma_framework/contracts/mocks/exits/payment/routers/PaymentInFlightExitRouterMock.sol

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ contract PaymentInFlightExitRouterMock is PaymentInFlightExitRouter {
2121
SpendingConditionRegistry spendingConditionRegistry,
2222
IStateTransitionVerifier stateTransitionVerifier,
2323
ITxFinalizationVerifier txFinalizationVerifier,
24-
uint256 supportedTxType
24+
uint256 supportTxType
2525
)
2626
public
27-
PaymentInFlightExitRouter(
28-
plasmaFramework,
27+
{
28+
PaymentInFlightExitRouter.init(
29+
framework,
2930
ethVault,
3031
erc20Vault,
3132
outputGuardHandlerRegistry,
3233
spendingConditionRegistry,
3334
stateTransitionVerifier,
3435
txFinalizationVerifier,
35-
supportedTxType
36-
)
37-
{
36+
supportTxType
37+
);
3838
framework = plasmaFramework;
3939
}
4040

plasma_framework/contracts/mocks/exits/payment/routers/PaymentStandardExitRouterMock.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ contract PaymentStandardExitRouterMock is PaymentStandardExitRouter {
1818
ITxFinalizationVerifier txFinalizationVerifier
1919
)
2020
public
21-
PaymentStandardExitRouter(
22-
plasmaFramework,
21+
{
22+
PaymentStandardExitRouter.init(
23+
framework,
2324
ethVault,
2425
erc20Vault,
2526
outputGuardHandlerRegistry,
2627
spendingConditionRegistry,
2728
txFinalizationVerifier
28-
)
29-
{
29+
);
3030
framework = plasmaFramework;
3131
}
3232

plasma_framework/contracts/mocks/utils/BitsWrapper.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ contract BitsWrapper {
2020
{
2121
return Bits.bitSet(_self, _index);
2222
}
23-
}
23+
}

plasma_framework/contracts/src/exits/payment/PaymentExitGame.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ contract PaymentExitGame is IExitProcessor, PaymentStandardExitRouter, PaymentIn
3030
uint256 supportTxType
3131
)
3232
public
33-
PaymentStandardExitRouter(
33+
{
34+
PaymentStandardExitRouter.init(
3435
framework,
3536
ethVault,
3637
erc20Vault,
3738
outputGuardHandlerRegistry,
3839
spendingConditionRegistry,
3940
txFinalizationVerifier
40-
)
41-
PaymentInFlightExitRouter(
41+
);
42+
PaymentInFlightExitRouter.init(
4243
framework,
4344
ethVault,
4445
erc20Vault,
@@ -47,8 +48,7 @@ contract PaymentExitGame is IExitProcessor, PaymentStandardExitRouter, PaymentIn
4748
stateTransitionVerifier,
4849
txFinalizationVerifier,
4950
supportTxType
50-
)
51-
{
51+
);
5252
plasmaFramework = framework;
5353
}
5454

plasma_framework/contracts/src/exits/payment/routers/PaymentInFlightExitRouter.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ contract PaymentInFlightExitRouter is IExitProcessor, Operated, OnlyWithValue {
5151
event IFEBondUpdated(uint128 bondSize);
5252
event PiggybackBondUpdated(uint128 bondSize);
5353

54-
constructor(
54+
function init(
5555
PlasmaFramework framework,
5656
EthVault ethVault,
5757
Erc20Vault erc20Vault,
@@ -105,6 +105,7 @@ contract PaymentInFlightExitRouter is IExitProcessor, Operated, OnlyWithValue {
105105
ethVault: ethVault,
106106
erc20Vault: erc20Vault
107107
});
108+
108109
startIFEBond = BondSize.buildParams(INITIAL_IFE_BOND_SIZE, BOND_LOWER_BOUND_DIVISOR, BOND_UPPER_BOUND_MULTIPLIER);
109110
piggybackBond = BondSize.buildParams(INITIAL_PB_BOND_SIZE, BOND_LOWER_BOUND_DIVISOR, BOND_UPPER_BOUND_MULTIPLIER);
110111
}

plasma_framework/contracts/src/exits/payment/routers/PaymentStandardExitRouter.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ contract PaymentStandardExitRouter is
4242

4343
event StandardExitBondUpdated(uint128 bondSize);
4444

45-
constructor(
45+
function init(
4646
PlasmaFramework framework,
4747
EthVault ethVault,
4848
Erc20Vault erc20Vault,

plasma_framework/contracts/src/exits/utils/BondSize.sol

+5-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ library BondSize {
3131
pure
3232
returns (Params memory)
3333
{
34-
require(initialBondSize > 0, "initialBondSize cannot be 0");
35-
require(lowerBoundDivisor > 0, "lowerBoundDivisor cannot be 0");
36-
require(upperBoundMultiplier > 0, "upperBoundMultiplier cannot be 0");
37-
3834
// Set the initial value to far in the future
3935
uint128 initialEffectiveUpdateTime = 2 ** 63;
36+
37+
require(initialBondSize != 0, "initialBondSize cannot be 0");
38+
require(lowerBoundDivisor != 0, "lowerBoundDivisor cannot be 0");
39+
require(upperBoundMultiplier != 0, "upperBoundMultiplier cannot be 0");
40+
4041
return Params({
4142
previousBondSize: initialBondSize,
4243
updatedBondSize: 0,

0 commit comments

Comments
 (0)