diff --git a/e2e/chains/bsc/Dockerfile.bootstrap b/e2e/chains/bsc/Dockerfile.bootstrap index d351c42..df89ccd 100644 --- a/e2e/chains/bsc/Dockerfile.bootstrap +++ b/e2e/chains/bsc/Dockerfile.bootstrap @@ -5,6 +5,7 @@ RUN apk add --d --no-cache ca-certificates npm nodejs bash alpine-sdk expect jq RUN git clone https://github.com/binance-chain/bsc-genesis-contract.git -b v1.1.9 /root/genesis \ && cd /root/genesis && npm ci +COPY scripts/contracts/SystemReward.template /root/genesis/contracts/SystemReward.template COPY scripts/contracts/BSCValidatorSet.template /root/genesis/contracts/BSCValidatorSet.template COPY scripts/generate-validator.js /root/genesis/generate-validator.js COPY scripts/genesis-template.template /root/genesis/genesis-template.template diff --git a/e2e/chains/bsc/docker-compose.bsc.yml b/e2e/chains/bsc/docker-compose.bsc.yml index 7f64cf9..a536d57 100644 --- a/e2e/chains/bsc/docker-compose.bsc.yml +++ b/e2e/chains/bsc/docker-compose.bsc.yml @@ -6,6 +6,6 @@ services: context: . dockerfile: Dockerfile.bsc args: - GIT_SOURCE: https://github.com/yoshidan/bsc.git - GIT_CHECKOUT_BRANCH: v1.2.10_test + GIT_SOURCE: https://github.com/binance-chain/bsc.git + GIT_CHECKOUT_BRANCH: v1.2.10 image: bsc-geth:docker-local diff --git a/e2e/chains/bsc/scripts/contracts/SystemReward.template b/e2e/chains/bsc/scripts/contracts/SystemReward.template new file mode 100644 index 0000000..13e1b49 --- /dev/null +++ b/e2e/chains/bsc/scripts/contracts/SystemReward.template @@ -0,0 +1,86 @@ +pragma solidity 0.6.4; + +import "./System.sol"; +import "./lib/Memory.sol"; +import "./interface/IParamSubscriber.sol"; +import "./interface/ISystemReward.sol"; + +contract SystemReward is System, IParamSubscriber, ISystemReward { + uint256 public constant MAX_REWARDS = 1e18; + + uint public numOperator; + mapping(address => bool) operators; + + modifier doInit() { + if (!alreadyInit) { + operators[LIGHT_CLIENT_ADDR] = true; + operators[INCENTIVIZE_ADDR] = true; + numOperator = 2; + alreadyInit = true; + } + _; + } + + modifier onlyOperator() { +// start mod + // require(operators[msg.sender],"only operator is allowed to call the method"); +// end mod + _; + } + + event rewardTo(address indexed to, uint256 amount); + event rewardEmpty(); + event receiveDeposit(address indexed from, uint256 amount); + event addOperator(address indexed operator); + event deleteOperator(address indexed operator); + event paramChange(string key, bytes value); + + receive() external payable{ + if (msg.value>0) { + emit receiveDeposit(msg.sender, msg.value); + } + } + + function claimRewards(address payable to, uint256 amount) external override(ISystemReward) doInit onlyOperator returns (uint256) { + uint256 actualAmount = amount < address(this).balance ? amount : address(this).balance; + if (actualAmount > MAX_REWARDS) { + actualAmount = MAX_REWARDS; + } + if (actualAmount != 0) { + to.transfer(actualAmount); + emit rewardTo(to, actualAmount); + } else { + emit rewardEmpty(); + } + return actualAmount; + } + + function isOperator(address addr) external view returns (bool) { + return operators[addr]; + } + + function updateParam(string calldata key, bytes calldata value) onlyGov external override { + if (Memory.compareStrings(key, "addOperator")) { + bytes memory valueLocal = value; + require(valueLocal.length == 20, "length of value for addOperator should be 20"); + address operatorAddr; + assembly { + operatorAddr := mload(add(valueLocal, 20)) + } + operators[operatorAddr] = true; + emit addOperator(operatorAddr); + } else if (Memory.compareStrings(key, "deleteOperator")) { + bytes memory valueLocal = value; + require(valueLocal.length == 20, "length of value for deleteOperator should be 20"); + address operatorAddr; + assembly { + operatorAddr := mload(add(valueLocal, 20)) + } + delete operators[operatorAddr]; + emit deleteOperator(operatorAddr); + } else { + require(false, "unknown param"); + } + emit paramChange(key, value); + } +} \ No newline at end of file