Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Minor fixes #328

Merged
merged 6 commits into from
Oct 4, 2019
Merged

Some Minor fixes #328

merged 6 commits into from
Oct 4, 2019

Conversation

boolafish
Copy link
Contributor

@boolafish boolafish commented Oct 2, 2019

Note

  • remove some solhint workaround as latest version fixes the bug. @kevsul 's PR has been merged and released.
  • take care of BondSize boundary number, closes Use SafeMath for all tainted inputs  #296. End up not using SafeMath as it is really meaning less since it only protects uint256 but we are using uint128. Instead, I add tests on that we support edge case of upgrade to max num of uint128.
  • Add boundary of the BondSize to not be 0 during update. Thus with min size 1.
  • fix bug around comparing time in BondSize. There was a bug when now == effectiveUpdateTime the update would be broken. Found this while trying to add tests for coverage : )
  • make depositVerifier be updated right at newDepositVerifierMaturityTimestamp

  • upgrade to solidity 0.5.12 see this comment: Some Minor fixes #328 (comment)
  • make compiler happy when optimizer is off. Somehow it failed to compile when the optimizer is tuned off with the change on BondSize. (Whenever there is a require inside buildParams it fails to compile....). Found this because the coverage tool forces optimizer to be off. Seems like it cannot be called in a constructor. So I change the constructor for Routers to become init function instead. Reverting this as it end up increase deployment gas quite a lot, and we don't really have security issue as the params are fixed in PaymentExitGame contract now.

@boolafish boolafish requested a review from pgebal October 2, 2019 08:13
@boolafish boolafish changed the title Minor fixes Several Minor fixes Oct 2, 2019
@pdobacz
Copy link
Contributor

pdobacz commented Oct 2, 2019

is there a requirement to go solc 0.5.12 now? If 0.5.11 works just fine, could we stick to it for just a while longer to limit the number of things in flux?

@boolafish
Copy link
Contributor Author

boolafish commented Oct 2, 2019

@pdobacz I think we should stick with latest version before we start the audit. I don't mind to upgrade that a bit later though. Would this impact your side?

});
});

describe('with boundary size of numbers', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thec00n here is the new tests for boundary

Copy link
Contributor

@thec00n thec00n Oct 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not appreciate https://github.com/omisego/plasma-contracts/blob/11b3bae4926dabc491dfbce511207b2f2798ba0f/plasma_framework/contracts/src/exits/utils/BondSize.sol#L75 in the beginning but I think it's actually the best solution in this case to ensure that the check does not overflow and to avoid a scenario where we get stuck with a new bond size.

@pdobacz
Copy link
Contributor

pdobacz commented Oct 2, 2019

@boolafish

@pdobacz I think we should stick with latest version before we start the audit. I don't mind to upgrade that a bit later though. Would this impact your side?

we'd probably like to upgrade to the same version, which impacts the builder/deployer images for elixir-omg and the deployment process a bit.

(or we could just yolo and use different versions for now, but if sth funny happens we'll have one more thing to debug).

If we can upgrade a bit later, I'd appreciate that. Maybe after the branch-entanglement and deployment changes are behind us?

But if time comes and you need to, pls upgrade and let us know, thx 🙏

@boolafish boolafish force-pushed the minor_fixes branch 2 times, most recently from 256d913 to bec1900 Compare October 2, 2019 09:01

if (_self.updatedBondSize != 0 && now > _self.effectiveUpdateTime) {
_self.previousBondSize = _self.updatedBondSize;
if (self.updatedBondSize != 0 && now >= self.effectiveUpdateTime) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now >= self.effectiveUpdateTime part was a bug! It was now > self.effectiveUpdateTime but in bondSize(self) it is using now < self.effectiveUpdateTime. As a result, when now == self.effectiveUpdateTime it would fail to fall into this if block.

this.lowerBoundDivisor,
this.upperBoundMultiplier,
);
describe('in general...', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it :+)

Copy link
Contributor Author

@boolafish boolafish Oct 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, my bad. re-word it to with normal cases

expect(bondSize).to.be.bignumber.equal(secondNewBondSize);
describe('with boundary size of numbers', () => {
it('should able to update to max number of uint128 without having overflow issue', async () => {
const maxSizeOfUint256 = (new BN(2)).pow(new BN(128)).sub(new BN(1)); // 2^128 - 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uint256 -> Uint128

Copy link
Contributor

@thec00n thec00n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@boolafish boolafish changed the title Several Minor fixes Some Minor fixes Oct 4, 2019
Remove this comment: "// solhint-disable-next-line reason-string" as the issue is solved.
solhint bug: protofire/solhint#157
1. refactor the code a bit to remove underscore prefix for var
2. add tests to show the boundary number for BondSize

see: https://git.io/JecTv
It uses "now < self.effectiveUpdateTime" to choose the updatedBondSize or not. But it is using "now > self.effectiveUpdateTime" when updating.
As a result, when now == self.effectiveUpdateTime, it becomes a hole that belongs to no one.
…rityTimestamp

All other places would make the update take effect right on the timestamp instead of timestamp + 1.
This change makes it to be consistent with others.
@boolafish boolafish merged commit 9ad2b9b into master Oct 4, 2019
@boolafish boolafish deleted the minor_fixes branch October 4, 2019 04:26
@boolafish boolafish mentioned this pull request Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use SafeMath for all tainted inputs
4 participants