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

Rename Core >safe core and origin core >mosaic core #522

Merged
Merged
52 changes: 26 additions & 26 deletions contracts/core/KernelGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract KernelGateway is KernelGatewayInterface {

/* Events */

/** Emit event when open kernel in origin core is proven. */
/** Emit event when open kernel in mosaic core is proven. */
event OpenKernelProven(
bytes20 _originCoreIdentifier,
bytes20 _auxiliaryCoreIdentifier,
Expand All @@ -47,38 +47,38 @@ contract KernelGateway is KernelGatewayInterface {
uint256 _currentDynasty
);

/** Emit event origin core account is proven. */
event OriginCoreProven(
address _originCore,
/** Emit event mosaic core account is proven. */
event MosaicCoreProven(
address _mosaicCore,
uint256 _blockHeight,
bytes32 _storageRoot,
bool _wasAlreadyProved
);

/** Index of kernel hash storage location in origin core. */
/** Index of kernel hash storage location in mosaic core. */
uint8 public constant KERNEL_HASH_INDEX = 5;

/* Variables */

/** Address of origin core. */
address public originCore;
/** Address of mosaic core. */
address public mosaicCore;

/** Address of the origin block store. */
BlockStoreInterface public originBlockStore;

/** Address of the auxiliary block store. */
BlockStoreInterface public auxiliaryBlockStore;

/** path to prove merkle account proof for OriginCore contract. */
bytes public encodedOriginCorePath;
/** path to prove merkle account proof for MosaicCore contract. */
bytes public encodedMosaicCorePath;

/** Storage path. */
bytes public storagePath;

/** A mapping of kernel hash to the kernel object. */
mapping(bytes32 => MetaBlock.Kernel) public kernels;

/** A mapping of origin block height to the storage root of origin core. */
/** A mapping of origin block height to the storage root of mosaic core. */
mapping(uint256 => bytes32) public storageRoots;

/** The hash of the currently active kernel. */
Expand All @@ -90,7 +90,7 @@ contract KernelGateway is KernelGatewayInterface {
/** The auxiliary dynasty height at which the open kernel will be active. */
uint256 public openKernelActivationHeight;

/** The origin core identifier. */
/** The mosaic core identifier. */
bytes20 public originCoreIdentifier;

/** The auxiliary core identifier. */
Expand All @@ -116,23 +116,23 @@ contract KernelGateway is KernelGatewayInterface {
* @notice Initializes the contract with origin and auxiliary block store
* addresses.
*
* @param _originCore The address of OriginCore contract.
* @param _mosaicCore The address of MosaicCore contract.
* @param _originBlockStore The block store that stores the origin chain.
* @param _auxiliaryBlockStore The block store that stores the auxiliary
* chain.
* @param _kernelHash Initial kernel hash.
*/
constructor (
address _originCore,
address _mosaicCore,
BlockStoreInterface _originBlockStore,
BlockStoreInterface _auxiliaryBlockStore,
bytes32 _kernelHash
)
public
{
require(
_originCore != address(0),
"The address of the origin core must not be zero."
_mosaicCore != address(0),
"The address of the mosaic core must not be zero."
);

require(
Expand All @@ -152,7 +152,7 @@ contract KernelGateway is KernelGatewayInterface {

originBlockStore = _originBlockStore;
auxiliaryBlockStore = _auxiliaryBlockStore;
originCore = _originCore;
mosaicCore = _mosaicCore;
activeKernelHash = _kernelHash;
originCoreIdentifier = originBlockStore.getCoreIdentifier();
auxiliaryCoreIdentifier = auxiliaryBlockStore.getCoreIdentifier();
Expand All @@ -175,14 +175,14 @@ contract KernelGateway is KernelGatewayInterface {
keccak256(abi.encodePacked(indexBytes))
);

encodedOriginCorePath = BytesLib.bytes32ToBytes(
keccak256(abi.encodePacked(_originCore))
encodedMosaicCorePath = BytesLib.bytes32ToBytes(
keccak256(abi.encodePacked(_mosaicCore))
);
}

/**
* @notice Prove origin core account and update the latest storage root of
* origin core. This function will validate the proof against the
* @notice Prove mosaic core account and update the latest storage root of
* mosaic core. This function will validate the proof against the
* state root from the OriginBlockStore
*
* @param _accountRlp RLP encoded account data.
Expand All @@ -194,7 +194,7 @@ contract KernelGateway is KernelGatewayInterface {
*
* @return success_ `true` if the proof is successful.
*/
function proveOriginCore(
function proveMosaicCore(
bytes calldata _accountRlp,
bytes calldata _accountBranchRlp,
uint256 _originBlockHeight
Expand Down Expand Up @@ -235,14 +235,14 @@ contract KernelGateway is KernelGatewayInterface {
storageRoot = updateStorageRoot(
_accountRlp,
_accountBranchRlp,
encodedOriginCorePath,
encodedMosaicCorePath,
stateRoot,
_originBlockHeight
);
}

emit OriginCoreProven(
originCore,
emit MosaicCoreProven(
mosaicCore,
_originBlockHeight,
storageRoot,
isAlreadyProven
Expand Down Expand Up @@ -519,7 +519,7 @@ contract KernelGateway is KernelGatewayInterface {
/* Internal functions */

/**
* @notice Get storage root for the OriginCore contract.
* @notice Get storage root for the MosaicCore contract.
*
* @dev The existence of storage root is proved with merkle proof.
*
Expand Down Expand Up @@ -556,7 +556,7 @@ contract KernelGateway is KernelGatewayInterface {
);

/*
* Verify the remote origin core contract against the committed state
* Verify the remote mosaic core contract against the committed state
* root with the state trie Merkle proof.
*/
require(
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/KernelGatewayInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pragma solidity ^0.5.0;
interface KernelGatewayInterface {

/**
* @notice Prove origin core account and update the latest storage root of
* origin core. This function will validate the proof against the
* @notice Prove mosaic core account and update the latest storage root of
* mosaic core. This function will validate the proof against the
* state root from the OriginBlockStore
*
* @param _accountRlp RLP encoded account data.
Expand All @@ -31,7 +31,7 @@ interface KernelGatewayInterface {
*
* @return success_ `true` if the proof is successful.
*/
function proveOriginCore(
function proveMosaicCore(
bytes calldata _accountRlp,
bytes calldata _accountBranchRlp,
uint256 _originBlockHeight
Expand Down
17 changes: 9 additions & 8 deletions contracts/core/OriginCore.sol → contracts/core/MosaicCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ pragma solidity ^0.5.0;
// limitations under the License.

import "../OstInterface.sol";
import "./OriginCoreConfig.sol";
import "./OriginCoreInterface.sol";
import "./MosaicCoreConfig.sol";
import "./MosaicCoreInterface.sol";
import "./Stake.sol";
import "../lib/MetaBlock.sol";
import "../lib/SafeMath.sol";
import "../StateRootInterface.sol";

/**
* @title OriginCore is a meta-blockchain with staked validators on Ethereum.
* @title MosaicCore is a meta-blockchain with staked validators on Ethereum.
*/
contract OriginCore is
OriginCoreInterface,
OriginCoreConfig,
StateRootInterface {
contract MosaicCore is
MosaicCoreInterface,
MosaicCoreConfig,
StateRootInterface
{
using SafeMath for uint256;

/* Events */
Expand Down Expand Up @@ -131,7 +132,7 @@ contract OriginCore is
/* Constructor */

/**
* The OriginCore constructor initializes the OriginCore and deploys an
* The MosaicCore constructor initializes the MosaicCore and deploys an
* instance of the Stake contract.
*
* @param _auxiliaryCoreIdentifier The core identifier of the auxiliary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pragma solidity ^0.5.0;
// See the License for the specific language governing permissions and
// limitations under the License.

/** @title Configuration constants of the OriginCore contract. */
contract OriginCoreConfig {
/** @title Configuration constants of the MosaicCore contract. */
contract MosaicCoreConfig {

/** The number of decimals of the base token. */
uint256 public constant DECIMALSFACTOR = 10 ** uint256(18);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pragma solidity ^0.5.0;
// See the License for the specific language governing permissions and
// limitations under the License.

/** @title Interface for the origin core contract on origin. */
interface OriginCoreInterface {
/** @title Interface for the mosaic core contract on origin. */
interface MosaicCoreInterface {

/**
* @notice Proposes a new meta-block. The block is stored if the proposal
Expand Down
32 changes: 16 additions & 16 deletions contracts/core/Stake.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ contract Stake is StakeInterface {
/** The token that is used as staking currency. */
EIP20Interface public stakingToken;

/** Address of the origin core. */
address public originCore;
/** Address of the mosaic core. */
address public mosaicCore;

/**
* The minimum weight that is required for this meta-blockchain to function.
Expand Down Expand Up @@ -135,12 +135,12 @@ contract Stake is StakeInterface {
/* Modifiers */

/**
* Verifies that the message was sent by the origin core.
* Verifies that the message was sent by the mosaic core.
*/
modifier onlyOriginCore() {
modifier onlyMosaicCore() {
require(
msg.sender == originCore,
"Caller must be the registered Origin Core."
msg.sender == mosaicCore,
"Caller must be the registered mosaic Core."
);

_;
Expand Down Expand Up @@ -172,21 +172,21 @@ contract Stake is StakeInterface {
* before it becomes functional, the initial set of validators must
* be set by calling `initialize()`.
* !!! You probably don't want to deploy the Stake contract
* !!! yourself. Instead, it should be deployed from the OriginCore
* !!! yourself. Instead, it should be deployed from the MosaicCore
* !!! constructor.
*
* @param _stakingToken The address of the ERC-20 token that is used to
* deposit stakes.
* @param _originCore Address of the origin core. Some methods may only be
* called from the origin core.
* @param _mosaicCore Address of the mosaic core. Some methods may only be
* called from the mosaic core.
* @param _minimumWeight The minimum total weight that all active validators
* must have so that the meta-blockchain is not
* considered halted. See also the modifier
* `aboveMinimumWeight()`.
*/
constructor(
address _stakingToken,
address _originCore,
address _mosaicCore,
uint256 _minimumWeight
)
public
Expand All @@ -196,16 +196,16 @@ contract Stake is StakeInterface {
"The address of the staking token must not be zero."
);
require(
_originCore != address(0),
"The address of the origin core must not be zero."
_mosaicCore != address(0),
"The address of the mosaic core must not be zero."
);
require(
_minimumWeight > 0,
"Minimum weight must be greater than zero."
);

stakingToken = EIP20Interface(_stakingToken);
originCore = _originCore;
mosaicCore = _mosaicCore;
minimumWeight = _minimumWeight;

/*
Expand Down Expand Up @@ -391,7 +391,7 @@ contract Stake is StakeInterface {
/**
* @notice Notifies the contract about a closing meta-block in order to
* handle any changes in the set of validators.
* Can only be called from OriginCore.
* Can only be called from MosaicCore.
*
* @dev The height is given to `assert` that the call is in sync with the
* contract.
Expand All @@ -405,7 +405,7 @@ contract Stake is StakeInterface {
uint256 _closingHeight
)
external
onlyOriginCore()
onlyMosaicCore()
aboveMinimumWeight()
returns (
address[] memory updatedValidators_,
Expand Down Expand Up @@ -446,7 +446,7 @@ contract Stake is StakeInterface {
* @notice Returns the weight of a validator at a specific meta-block height,
* based on the auxiliary address of the validator.
*
* @dev The OriginCore can use this method to track the verified weight by
* @dev The MosaicCore can use this method to track the verified weight by
* the verified votes and notice when a supermajority has been
* reached, therefore committing the meta-block.
* The height is given to `assert` that the call is in sync with the
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/StakeInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ interface StakeInterface {
/**
* @notice Notifies the contract about a closing meta-block in order to
* handle any changes in the set of validators.
* Can only be called from OriginCore.
* Can only be called from MosaicCore.
*
* @dev The height is given to `assert` that the call is in sync with the
* contract.
Expand Down Expand Up @@ -145,7 +145,7 @@ interface StakeInterface {
* @notice Returns the weight of a validator at a specific meta-block
* height, based on the auxiliary address of the validator.
*
* @dev The OriginCore can use this method to track the verified weight by
* @dev The MosaicCore can use this method to track the verified weight by
* the verified votes and notice when a supermajority has been
* reached, therefore committing the meta-block.
* The height is given to `assert` that the call is in sync with the
Expand Down
2 changes: 1 addition & 1 deletion contracts/gateway/EIP20CoGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ contract EIP20CoGateway is GatewayBase {
constructor(
address _valueToken,
address _utilityToken,
CoreInterface _core,
StateRootInterface _core,
uint256 _bounty,
IsMemberInterface _membersManager,
address _gateway
Expand Down
2 changes: 1 addition & 1 deletion contracts/gateway/EIP20Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ contract EIP20Gateway is GatewayBase {
constructor(
EIP20Interface _token,
EIP20Interface _baseToken,
CoreInterface _core,
StateRootInterface _core,
uint256 _bounty,
IsMemberInterface _membersManager
)
Expand Down
Loading