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

ERC20Connector: add replay protection. Make AdminControlled. Add tests. Refactoring #33

Closed

Conversation

sept-en
Copy link
Contributor

@sept-en sept-en commented Feb 26, 2021

No description provided.

* Add replay protection after the possible upgrade by providing the
  `minBlockAcceptanceHeight` constraint for the proofs acceptance.
* Rename `Locker` contract to `ProofKeeper`.
* Minor improvements.
* Refactoring.
* Add `AdminControlled` contract.
* ERC20Locker: inherit from `AdminControlled`.
* ERC20Locker: make `lockToken` and `unlockToken` pausable.
* Add tests.
@sept-en sept-en changed the title ERC20Connector: add replay protection. Make AdminControlled. Add tests. ERC20Connector: add replay protection. Make AdminControlled. Add tests. Refactoring Feb 26, 2021
@mfornet mfornet self-requested a review February 26, 2021 14:23
Copy link
Contributor

@mfornet mfornet left a comment

Choose a reason for hiding this comment

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

It is hard to see what is the replay issue and the fix in this PR. Can you please separate it in multiples PR:

  1. Add replay protection
  2. Make Admin Controlled
  3. Add minBlockAcceptanceHeight logic.

IMO we should not rename any contract.

import "rainbow-bridge/contracts/eth/nearprover/contracts/ProofDecoder.sol";
import "rainbow-bridge/contracts/eth/nearbridge/contracts/Borsh.sol";

contract ProofKeeper {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not fully onboard with this new name. I understand your motivation for more generic connector that goes beyond locking tokens, but in this particular case Locker makes perfectly clear the goal of this contract while ProofKeeper doesn't IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will split this into separate PRs (though 1 and 3 items will be in one as they are dependent).

What's about Locker - I believe that this name is truly misleading because actually, the contract locks nothing. And moreover, it contains just a _parseProof method and a map of used events and references the appropriate proof producer. So I don't think that old name doesn't represent the behavior of the contract.

On the other hand, the map which is inside - usedEvents (I believe that could be renamed to usedProofs because these are actually proofs, not events) - and _parseAndConsumeProof are there and the contract just keeps used proofs and is able to parse and consume proofs meanwhile verifying that this originates from the expected proof producer. And also as we already have ProofDecoder this doesn't look foreign IMO. But I agree that ProofKeeper isn't the perfect name as well. Perhaps, ProofConsumer or ProofController are a little bit better names but I'm not sure.

But if you think that it's better to keep old names for this connector, we can do this way.

@@ -0,0 +1,42 @@
pragma solidity ^0.6.12;

contract AdminControlled {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't copy past this code and reuse the one from rainbow-bridge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to but this part hasn't been merged yet.

using ProofDecoder for Borsh.Data;

INearProver public prover_;
bytes public nearProofProducerAccount_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with this name. While you are trying to use generic name, nearTokenFactory conveys better the idea of what is happening here IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ERC20Locker passes the nearTokenFactory as an argument to this contract, so I think it already specifies how this will be used. Nevertheless, I'm ok to keep the old name if you think of this contract as specific to this connector.

@sept-en
Copy link
Contributor Author

sept-en commented Mar 1, 2021

Closed in favor of #35 and #36.

@sept-en sept-en closed this Mar 1, 2021
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.

2 participants