Skip to content

Commit

Permalink
chore: make compiler happy when optimizer is off
Browse files Browse the repository at this point in the history
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
  • Loading branch information
boolafish committed Oct 2, 2019
1 parent cee1be7 commit 256d913
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ contract PaymentInFlightExitRouterMock is PaymentInFlightExitRouter {
SpendingConditionRegistry spendingConditionRegistry,
IStateTransitionVerifier stateTransitionVerifier,
ITxFinalizationVerifier txFinalizationVerifier,
uint256 supportedTxType
uint256 supportTxType
)
public
PaymentInFlightExitRouter(
{
PaymentInFlightExitRouter.init(
plasmaFramework,
ethVault,
erc20Vault,
outputGuardHandlerRegistry,
spendingConditionRegistry,
stateTransitionVerifier,
txFinalizationVerifier,
supportedTxType
)
{
supportTxType
);
framework = plasmaFramework;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ contract PaymentStandardExitRouterMock is PaymentStandardExitRouter {
ITxFinalizationVerifier txFinalizationVerifier
)
public
PaymentStandardExitRouter(
{
PaymentStandardExitRouter.init(
plasmaFramework,
ethVault,
erc20Vault,
outputGuardHandlerRegistry,
spendingConditionRegistry,
txFinalizationVerifier
)
{
);
framework = plasmaFramework;
}

Expand Down
2 changes: 1 addition & 1 deletion plasma_framework/contracts/mocks/utils/BitsWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ contract BitsWrapper {
{
return Bits.bitSet(_self, _index);
}
}
}
10 changes: 5 additions & 5 deletions plasma_framework/contracts/src/exits/payment/PaymentExitGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ contract PaymentExitGame is IExitProcessor, PaymentStandardExitRouter, PaymentIn
uint256 supportTxType
)
public
PaymentStandardExitRouter(
{
PaymentStandardExitRouter.init(
framework,
ethVault,
erc20Vault,
outputGuardHandlerRegistry,
spendingConditionRegistry,
txFinalizationVerifier
)
PaymentInFlightExitRouter(
);
PaymentInFlightExitRouter.init(
framework,
ethVault,
erc20Vault,
Expand All @@ -47,8 +48,7 @@ contract PaymentExitGame is IExitProcessor, PaymentStandardExitRouter, PaymentIn
stateTransitionVerifier,
txFinalizationVerifier,
supportTxType
)
{
);
plasmaFramework = framework;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract PaymentInFlightExitRouter is IExitProcessor, Operated, OnlyWithValue {
event IFEBondUpdated(uint128 bondSize);
event PiggybackBondUpdated(uint128 bondSize);

constructor(
function init(
PlasmaFramework framework,
EthVault ethVault,
Erc20Vault erc20Vault,
Expand Down Expand Up @@ -105,6 +105,7 @@ contract PaymentInFlightExitRouter is IExitProcessor, Operated, OnlyWithValue {
ethVault: ethVault,
erc20Vault: erc20Vault
});

startIFEBond = BondSize.buildParams(INITIAL_IFE_BOND_SIZE, BOND_LOWER_BOUND_DIVISOR, BOND_UPPER_BOUND_MULTIPLIER);
piggybackBond = BondSize.buildParams(INITIAL_PB_BOND_SIZE, BOND_LOWER_BOUND_DIVISOR, BOND_UPPER_BOUND_MULTIPLIER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract PaymentStandardExitRouter is

event StandardExitBondUpdated(uint128 bondSize);

constructor(
function init(
PlasmaFramework framework,
EthVault ethVault,
Erc20Vault erc20Vault,
Expand Down
9 changes: 5 additions & 4 deletions plasma_framework/contracts/src/exits/utils/BondSize.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ library BondSize {
pure
returns (Params memory)
{
require(initialBondSize > 0, "initialBondSize cannot be 0");
require(lowerBoundDivisor > 0, "lowerBoundDivisor cannot be 0");
require(upperBoundMultiplier > 0, "upperBoundMultiplier cannot be 0");

// Set the initial value to far in the future
uint128 initialEffectiveUpdateTime = 2 ** 63;

require(initialBondSize != 0, "initialBondSize cannot be 0");
require(lowerBoundDivisor != 0, "lowerBoundDivisor cannot be 0");
require(upperBoundMultiplier != 0, "upperBoundMultiplier cannot be 0");

return Params({
previousBondSize: initialBondSize,
updatedBondSize: 0,
Expand Down

0 comments on commit 256d913

Please sign in to comment.