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

Renamed SafeCore to Anchor #549

Merged

Conversation

gulshanvasnani
Copy link
Contributor

@gulshanvasnani gulshanvasnani commented Dec 14, 2018

PR does following :-

  1. Renames SafeCore contract name to Anchor.
  2. Updates the references of SafeCore in unit test cases.
  3. Changes the method name commitStateRoot to anchorStateRoot in Anchor contract.
  4. Changes the method name setCoCoreAddress to setCoAnchorAddress in Anchor contract.

Fixes: #537

Copy link
Contributor

@schemar schemar left a comment

Choose a reason for hiding this comment

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

Nice one 🏎💨

Just some comments on wording and indentation 👍

* @notice SafeCore stores another chain's state roots. It stores the address of
* the co-core, which will be the safe core on the other chain. State
* @notice Anchor stores another chain's state roots. It stores the address of
* the co-core, which will be the anchor on the other chain. State
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* the co-core, which will be the anchor on the other chain. State
* the co-anchor, which will be the anchor on the other chain. State

@@ -41,8 +41,8 @@ contract('SafeCore.getLatestStateRootBlockHeight()', function (accounts) {
blockHeight = new BN(5);
stateRoot = web3.utils.sha3("dummy_state_root");
membersManager = await MockMembersManager.new(owner, worker);

safeCore = await SafeCore.new(

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@@ -46,8 +46,8 @@ contract('SafeCore.setCoCoreAddress()', function (accounts) {
stateRoot = web3.utils.sha3("dummy_state_root");
membersManager = await MockMembersManager.new(owner, worker);
coCoreAddress = accounts[6];

safeCore = await SafeCore.new(

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@@ -61,7 +61,7 @@ contract('SafeCore.setCoCoreAddress()', function (accounts) {
coCoreAddress = NullAddress;

await Utils.expectRevert(
safeCore.setCoCoreAddress(coCoreAddress, { from: owner }),
anchor.setCoCoreAddress(coCoreAddress, { from: owner }),
Copy link
Contributor

Choose a reason for hiding this comment

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

In many places:

Suggested change
anchor.setCoCoreAddress(coCoreAddress, { from: owner }),
anchor.setCoCoreAddress(coCoreAddress, { from: owner }),

* @notice SafeCore stores another chain's state roots. It stores the address of
* the co-core, which will be the safe core on the other chain. State
* @notice Anchor stores another chain's state roots. It stores the address of
* the co-core, which will be the anchor on the other chain. State
* roots are exchanged bidirectionally between the core and the co-core
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* roots are exchanged bidirectionally between the core and the co-core
* roots are exchanged bidirectionally between the anchor and the co-anchor

contracts/gateway/Anchor.sol Show resolved Hide resolved
Copy link
Contributor

@schemar schemar left a comment

Choose a reason for hiding this comment

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

LGTM image

But please wait for at least one other review before merging.

Copy link
Contributor

@0xsarvesh 0xsarvesh left a comment

Choose a reason for hiding this comment

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

Almost done. 🙌
Some minor fixes are required.

Committed should also be changed to Anchoredin various files.

Also fix terminology in below contracts:

  1. StateRootInterface
  2. GatewayLib
  3. GatewayBase
  4. MockAnchor L18, L42

I am not sure if StateRootInterface _core, should be call as StateRootInterface _anchor.

@@ -184,7 +184,7 @@ contract SafeCore is StateRootInterface, Organized {
// Input block height should be valid
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add . in the comments.


/* Public functions */

/**
* @notice Contract constructor
* @notice Contract constructor.
*
* @param _remoteChainId _remoteChainId is the chain id of the chain that
* this core tracks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* this core tracks.
* this anchor tracks.

contracts/test/core/MockAnchor.sol Show resolved Hide resolved
@@ -42,7 +42,7 @@ contract MockGatewayBase is GatewayBase {
*
* @dev proveGateway can be called by anyone to verify merkle proof of
* gateway/co-gateway contract address. Trust factor is brought by
* stateRoots mapping. stateRoot is committed in commitStateRoot
* stateRoots mapping. stateRoot is committed in anchorStateRoot
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* stateRoots mapping. stateRoot is committed in anchorStateRoot
* stateRoots mapping. stateRoot is anchored in anchorStateRoot


});

it('should return the latest committed state root block height', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('should return the latest committed state root block height', async () => {
it('should return the latest anchored state root block height', async () => {


});

it('should return the latest committed state root', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('should return the latest committed state root', async () => {
it('should return the latest anchored state root', async () => {

…afecore_to_anchor

# Conflicts:
#	contracts/gateway/Anchor.sol
#	contracts/test/core/MockAnchor.sol
#	test/gateway/gateway_base/prove_gateway.js
#	test/gateway/safe_core/commit_state_root.js
#	test/gateway/safe_core/constructor.js
#	test/gateway/safe_core/get_latest_state_root_block_height.js
#	test/gateway/safe_core/get_remote_chainId.js
#	test/gateway/safe_core/get_state_root.js
#	test/gateway/safe_core/set_co_core_address.js
@schemar
Copy link
Contributor

schemar commented Dec 18, 2018

Also fix terminology in below contracts:

  • StateRootInterface
  • GatewayLib
  • GatewayBase
  • MockAnchor L18, L42

I don't think the gateway code should be aware whether it's an anchor or a core. The gateways should only care about the state root interface. E.g. "state root provider". Or am I missing something?

@gulshanvasnani @sarvesh-ost

@0xsarvesh
Copy link
Contributor

0xsarvesh commented Dec 18, 2018

Also fix terminology in below contracts:

  • StateRootInterface
  • GatewayLib
  • GatewayBase
  • MockAnchor L18, L42

I don't think the gateway code should be aware whether it's an anchor or a core. The gateways should only care about the state root interface. E.g. "state root provider". Or am I missing something?

What should be the name of the variable which represents contract instance implementing StateRootInterface?
Currently, it's core which seems incorrect, as Anchor contract is providing state roots.
Do we need third terminology other than core and Anchor? 🤔

@schemar
Copy link
Contributor

schemar commented Dec 18, 2018

Also fix terminology in below contracts:

  • StateRootInterface
  • GatewayLib
  • GatewayBase
  • MockAnchor L18, L42

I don't think the gateway code should be aware whether it's an anchor or a core. The gateways should only care about the state root interface. E.g. "state root provider". Or am I missing something?

What should be the name of the variable which represents contract instance implementing StateRootInterface?
Currently, it's core which seems incorrect, as Anchor contract is providing state roots.
Do we need third terminology other than core and Anchor? 🤔

Yes, we do. As it can be both. It can be an anchor as well as a core. In fact, it can be anything that implements the state root interface. It's just that in the past only different kinds of cores implemented that interface. Now that the safe core is called anchor, we need a more general name for the variable of that interface type.

@gulshanvasnani
Copy link
Contributor Author

gulshanvasnani commented Dec 19, 2018

Also fix terminology in below contracts:

  • StateRootInterface
  • GatewayLib
  • GatewayBase
  • MockAnchor L18, L42

I don't think the gateway code should be aware whether it's an anchor or a core. The gateways should only care about the state root interface. E.g. "state root provider". Or am I missing something?

What should be the name of the variable which represents contract instance implementing StateRootInterface?
Currently, it's core which seems incorrect, as Anchor contract is providing state roots.
Do we need third terminology other than core and Anchor? 🤔

Yes, we do. As it can be both. It can be an anchor as well as a core. In fact, it can be anything that implements the state root interface. It's just that in the past only different kinds of cores implemented that interface. Now that the safe core is called anchor, we need a more general name for the variable of that interface type.

Name can be stateRoots.

Copy link
Contributor

@schemar schemar left a comment

Choose a reason for hiding this comment

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

Hey @gulshanvasnani,
this looks already much better, but unfortunately you went over the top when it comes to renaming things...

All the contracts must be checked again, as there are many places where it is now called anchor, bit should be more general.
All the tests must be checked again, as there are many places where it is now called anchor, but should be more general.
I added a relevant comment to some of the affected files.

See also some other minor comments in-line.

contracts/StateRootInterface.sol Outdated Show resolved Hide resolved
contracts/StateRootInterface.sol Outdated Show resolved Hide resolved
contracts/gateway/EIP20CoGateway.sol Outdated Show resolved Hide resolved
contracts/gateway/EIP20Gateway.sol Outdated Show resolved Hide resolved
contracts/gateway/GatewayBase.sol Outdated Show resolved Hide resolved
test/gateway/anchor/anchor_state_root.js Show resolved Hide resolved
test/gateway/eip20_cogateway/constructor.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_gateway/activate_gateway.js Outdated Show resolved Hide resolved
test/gateway/eip20_gateway/constructor.js Outdated Show resolved Hide resolved
Copy link
Contributor

@schemar schemar left a comment

Choose a reason for hiding this comment

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

Almost there 🧗🏽‍♂️

contracts/gateway/GatewayBase.sol Outdated Show resolved Hide resolved
contracts/test/gateway/MockGatewayBase.sol Outdated Show resolved Hide resolved
test/gateway/anchor/anchor_state_root.js Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
Copy link
Contributor

@0xsarvesh 0xsarvesh left a comment

Choose a reason for hiding this comment

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

LGTM ⚓️👍🚜

Copy link
Contributor

@schemar schemar left a comment

Choose a reason for hiding this comment

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

Awesome
image

test/gateway/anchor/anchor_state_root.js Show resolved Hide resolved
@schemar schemar merged commit 287d68f into OpenST:develop Dec 21, 2018
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.

4 participants