Code Monkey home page Code Monkey logo

Comments (10)

varasev avatar varasev commented on September 23, 2024

@akolotov we have to decide who will have a permission to call addBridgeContract and removeBridgeContract functions. Do you have any suggestions about that?

from poa-network-consensus-contracts.

akolotov avatar akolotov commented on September 23, 2024

@varasev I have not found a part of code which allow to set the bridge contract. My understanding now is that it is done by the upgrading the whole RewarByBlock contract. Could addBridgeContract and removeBridgeContract be called in similar manner? It is up to you to implement the ability to control multiple bridge contracts in order to not spoil the current security model.

from poa-network-consensus-contracts.

varasev avatar varasev commented on September 23, 2024

My understanding now is that it is done by the upgrading the whole RewarByBlock contract.

For now, the value of bridgeContract constant may only be changed by changing the implementation of RewardByBlock. It is possible with VotingToChangeProxyAddress contract, so validators should vote for the change.

We could make another type of voting to add/remove bridge contract address to RewardByBlock. @igorbarinov what can you say about it?

An easier way is to allow these functions to be called only by some Multisig Wallet.

Or allow these functions to be called only by the MoC, for example, but I think it's not secure enough.

from poa-network-consensus-contracts.

akolotov avatar akolotov commented on September 23, 2024

What if we do in the same manner how it exists now:
So, instead of

    address public constant bridgeContract = 0x0000000000000000000000000000000000000000;

we will have

    mapping (address => bool) public bridgeContracts;
    bridgeContracts["0x1...a"] = true;
    bridgeContracts["0x2...b"] = true;
    bridgeContracts["0x3...c"] = true;

from poa-network-consensus-contracts.

varasev avatar varasev commented on September 23, 2024

Yes, we can make the addresses hardcoded. In the case when we want to add some new bridge contract, we can implement addBridgeContract that can be called by anyone but with hardcoded new address and can be called only once. For example:

function addBridgeContract() public {
    address newContract = "0x4...d";
    require(bridgeContracts[newContract] == false);
    bridgeContracts[newContract] = true;
}

The same is for removeBridgeContract:

function removeBridgeContract() public {
    address contractToRemove = "0x1...a";
    require(bridgeContracts[contractToRemove] == true);
    bridgeContracts[contractToRemove] = false;
}

addBridgeContract/ removeBridgeContract function will have to be called after RewardByBlock's implementation is upgraded.

from poa-network-consensus-contracts.

varasev avatar varasev commented on September 23, 2024

@akolotov Instead of addBridgeContract/removeBridgeContract we could have a single initBridgeContractAddresses as you suggested above:

function initBridgeContractAddresses() public {
    bridgeContracts["0x1...a"] = false; // removed bridge
    bridgeContracts["0x2...b"] = true;
    bridgeContracts["0x3...c"] = true; 
}

from poa-network-consensus-contracts.

varasev avatar varasev commented on September 23, 2024

To not to change the state of RewardByBlock contract we could just add the next getter in its implementation:

function isBridgeContract(address _addr) public pure returns(bool) {
    if (_addr == "0x1...a") return true;
    if (_addr == "0x2...b") return true;
    if (_addr == "0x3...c") return true;
    return false;
}

And use it inside onlyBridgeContract modifier:

modifier onlyBridgeContract {
    require(isBridgeContract(msg.sender));
    _;
}

from poa-network-consensus-contracts.

akolotov avatar akolotov commented on September 23, 2024

It is OK for me. How about ideas for implementation of mintedByBridge?

from poa-network-consensus-contracts.

varasev avatar varasev commented on September 23, 2024

I'll think about it and implement soon. There shouldn't be any difficulties.

from poa-network-consensus-contracts.

varasev avatar varasev commented on September 23, 2024

Done in #201.

from poa-network-consensus-contracts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.