Skip to content

Commit 23af4d4

Browse files
authored
Merge the develop branch to the master branch, preparation to v2.0.0-rc0
2 parents d78333c + 3311f04 commit 23af4d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2471
-531
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"global-require": "off",
2929
"no-loop-func": "off",
3030
"no-console": "off",
31-
"node/no-missing-require": "off"
31+
"node/no-missing-require": "off",
32+
"import/no-unresolved": "off"
3233
}
3334
}

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,35 @@ jobs:
4242
uses: coverallsapp/github-action@master
4343
with:
4444
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
e2e:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
- name: Run tests
50+
run: yarn e2e-tests:local
51+
publish:
52+
runs-on: ubuntu-latest
53+
needs:
54+
- validate
55+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags')
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Prepare tag names
59+
id: prep
60+
run: |
61+
DOCKER_IMAGE=poanetwork/nft-omnibridge-contracts
62+
if [[ $GITHUB_REF == refs/tags/* ]]; then
63+
echo ::set-output name=tags::${DOCKER_IMAGE}:${GITHUB_REF#refs/tags/},${DOCKER_IMAGE}:latest
64+
else
65+
echo ::set-output name=tags::${DOCKER_IMAGE}:${GITHUB_REF#refs/heads/}-${GITHUB_SHA::8}
66+
fi
67+
- name: Login to Docker Hub
68+
uses: docker/login-action@v1
69+
with:
70+
username: ${{ secrets.DOCKER_USERNAME }}
71+
password: ${{ secrets.DOCKER_PASSWORD }}
72+
- uses: docker/build-push-action@v2
73+
with:
74+
pull: true
75+
push: true
76+
tags: ${{ steps.prep.outputs.tags }}

.solhint.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"avoid-low-level-calls": "off",
77
"no-inline-assembly": "off",
88
"reason-string": "off",
9+
"no-empty-blocks": "off",
10+
"var-name-mixedcase": "off",
911
"func-visibility": ["warn", { "ignoreConstructors": true } ],
1012
"compiler-version": ["error", "0.7.5"]
1113
}

Dockerfile.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ RUN yarn flatten
1515
COPY deploy.sh deploy.sh
1616
COPY ./deploy ./deploy
1717
COPY ./test ./test
18+
COPY ./e2e-tests ./e2e-tests
1819

1920
ENV PATH="/contracts/:${PATH}"

contracts/interfaces/IAMB.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
pragma solidity 0.7.5;
22

33
interface IAMB {
4+
event UserRequestForAffirmation(bytes32 indexed messageId, bytes encodedData);
5+
event UserRequestForSignature(bytes32 indexed messageId, bytes encodedData);
6+
event CollectedSignatures(
7+
address authorityResponsibleForRelay,
8+
bytes32 messageHash,
9+
uint256 numberOfCollectedSignatures
10+
);
11+
event AffirmationCompleted(
12+
address indexed sender,
13+
address indexed executor,
14+
bytes32 indexed messageId,
15+
bool status
16+
);
17+
event RelayedMessage(address indexed sender, address indexed executor, bytes32 indexed messageId, bool status);
18+
419
function messageSender() external view returns (address);
520

621
function maxGasPerTx() external view returns (uint256);

contracts/mocks/AMBMock.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma solidity 0.7.5;
22

33
contract AMBMock {
4-
event MockedEvent(bytes32 indexed messageId, address executor, uint8 dataType, bytes data);
4+
event MockedEvent(bytes32 indexed messageId, address executor, uint8 dataType, bytes data, uint256 gas);
55

66
address public messageSender;
77
uint256 public immutable maxGasPerTx;
@@ -62,7 +62,7 @@ contract AMBMock {
6262
function _sendMessage(
6363
address _contract,
6464
bytes calldata _data,
65-
uint256,
65+
uint256 _gas,
6666
uint256 _dataType
6767
) internal returns (bytes32) {
6868
require(messageId == bytes32(0));
@@ -73,7 +73,7 @@ contract AMBMock {
7373
bytes32 _messageId = bytes32(uint256(0x11223344 << 224)) | bridgeId | bytes32(nonce);
7474
nonce += 1;
7575

76-
emit MockedEvent(_messageId, _contract, uint8(_dataType), _data);
76+
emit MockedEvent(_messageId, _contract, uint8(_dataType), _data, _gas);
7777
return _messageId;
7878
}
7979

contracts/upgradeability/UpgradeabilityOwnerStorage.sol

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@ pragma solidity 0.7.5;
55
* @dev This contract keeps track of the upgradeability owner
66
*/
77
contract UpgradeabilityOwnerStorage {
8-
// Owner of the contract
9-
address internal _upgradeabilityOwner;
10-
118
/**
129
* @dev Tells the address of the owner
13-
* @return the address of the owner
10+
* @return owner the address of the owner
1411
*/
15-
function upgradeabilityOwner() public view returns (address) {
16-
return _upgradeabilityOwner;
12+
function upgradeabilityOwner() public view returns (address owner) {
13+
assembly {
14+
// EIP 1967
15+
// bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
16+
owner := sload(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103)
17+
}
1718
}
1819

1920
/**
2021
* @dev Sets the address of the owner
2122
*/
2223
function setUpgradeabilityOwner(address newUpgradeabilityOwner) internal {
23-
_upgradeabilityOwner = newUpgradeabilityOwner;
24+
assembly {
25+
// EIP 1967
26+
// bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
27+
sstore(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103, newUpgradeabilityOwner)
28+
}
2429
}
2530
}

contracts/upgradeability/UpgradeabilityProxy.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ contract UpgradeabilityProxy is Proxy, UpgradeabilityStorage {
2525
}
2626

2727
/**
28-
* @dev Upgrades the implementation address
29-
* @param version representing the version name of the new implementation to be set
30-
* @param implementation representing the address of the new implementation to be set
28+
* @dev Upgrades the implementation address.
29+
* @param _version representing the version name of the new implementation to be set.
30+
* @param _implementation representing the address of the new implementation to be set.
3131
*/
32-
function _upgradeTo(uint256 version, address implementation) internal {
33-
require(_implementation != implementation);
32+
function _upgradeTo(uint256 _version, address _implementation) internal {
33+
require(_implementation != implementation());
3434

3535
// This additional check verifies that provided implementation is at least a contract
36-
require(Address.isContract(implementation));
36+
require(Address.isContract(_implementation));
3737

3838
// This additional check guarantees that new version will be at least greater than the privios one,
3939
// so it is impossible to reuse old versions, or use the last version twice
40-
require(version > _version);
40+
require(_version > version());
4141

42-
_version = version;
43-
_implementation = implementation;
44-
emit Upgraded(version, implementation);
42+
_setVersion(_version);
43+
_setImplementation(_implementation);
44+
emit Upgraded(_version, _implementation);
4545
}
4646
}

contracts/upgradeability/UpgradeabilityStorage.sol

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,51 @@ pragma solidity 0.7.5;
55
* @dev This contract holds all the necessary state variables to support the upgrade functionality
66
*/
77
contract UpgradeabilityStorage {
8-
// Version name of the current implementation
9-
uint256 internal _version;
10-
11-
// Address of the current implementation
12-
address internal _implementation;
13-
148
/**
159
* @dev Tells the version name of the current implementation
16-
* @return uint256 representing the name of the current version
10+
* @return version uint256 representing the name of the current version
1711
*/
18-
function version() external view returns (uint256) {
19-
return _version;
12+
function version() public view returns (uint256 version) {
13+
assembly {
14+
// EIP 1967
15+
// bytes32(uint256(keccak256('eip1967.proxy.version')) - 1)
16+
version := sload(0x460994c355dbc8229336897ed9def5884fb6b26b0a995b156780d056c758577d)
17+
}
2018
}
2119

2220
/**
2321
* @dev Tells the address of the current implementation
24-
* @return address of the current implementation
22+
* @return impl address of the current implementation
23+
*/
24+
function implementation() public view virtual returns (address impl) {
25+
assembly {
26+
// EIP 1967
27+
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
28+
impl := sload(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc)
29+
}
30+
}
31+
32+
/**
33+
* Internal function for updating version of the implementation contract.
34+
* @param _version new version number.
35+
*/
36+
function _setVersion(uint256 _version) internal {
37+
assembly {
38+
// EIP 1967
39+
// bytes32(uint256(keccak256('eip1967.proxy.version')) - 1)
40+
sstore(0x460994c355dbc8229336897ed9def5884fb6b26b0a995b156780d056c758577d, _version)
41+
}
42+
}
43+
44+
/**
45+
* Internal function for updating implementation contract address.
46+
* @param _impl new implementation contract address.
2547
*/
26-
function implementation() public view virtual returns (address) {
27-
return _implementation;
48+
function _setImplementation(address _impl) internal {
49+
assembly {
50+
// EIP 1967
51+
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
52+
sstore(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, _impl)
53+
}
2854
}
2955
}

contracts/upgradeable_contracts/BasicAMBMediator.sol

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import "@openzeppelin/contracts/utils/Address.sol";
88
* @title BasicAMBMediator
99
* @dev Basic storage and methods needed by mediators to interact with AMB bridge.
1010
*/
11-
contract BasicAMBMediator is Ownable {
11+
abstract contract BasicAMBMediator is Ownable {
1212
bytes32 internal constant BRIDGE_CONTRACT = 0x811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f; // keccak256(abi.encodePacked("bridgeContract"))
1313
bytes32 internal constant MEDIATOR_CONTRACT = 0x98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab9880; // keccak256(abi.encodePacked("mediatorContract"))
14-
bytes32 internal constant REQUEST_GAS_LIMIT = 0x2dfd6c9f781bb6bbb5369c114e949b69ebb440ef3d4dd6b2836225eb1dc3a2be; // keccak256(abi.encodePacked("requestGasLimit"))
1514

1615
/**
1716
* @dev Throws if caller on the other side is not an associated mediator.
@@ -25,8 +24,9 @@ contract BasicAMBMediator is Ownable {
2524
* @dev Internal function for reducing onlyMediator modifier bytecode overhead.
2625
*/
2726
function _onlyMediator() internal view {
28-
require(msg.sender == address(bridgeContract()));
29-
require(messageSender() == mediatorContractOnOtherSide());
27+
IAMB bridge = bridgeContract();
28+
require(msg.sender == address(bridge));
29+
require(bridge.messageSender() == mediatorContractOnOtherSide());
3030
}
3131

3232
/**
@@ -45,16 +45,6 @@ contract BasicAMBMediator is Ownable {
4545
_setMediatorContractOnOtherSide(_mediatorContract);
4646
}
4747

48-
/**
49-
* @dev Sets the gas limit to be used in the message execution by the AMB bridge on the other network.
50-
* This value can't exceed the parameter maxGasPerTx defined on the AMB bridge.
51-
* Only the owner can call this method.
52-
* @param _requestGasLimit the gas limit for the message execution.
53-
*/
54-
function setRequestGasLimit(uint256 _requestGasLimit) external onlyOwner {
55-
_setRequestGasLimit(_requestGasLimit);
56-
}
57-
5848
/**
5949
* @dev Get the AMB interface for the bridge contract address
6050
* @return AMB interface for the bridge contract address
@@ -71,14 +61,6 @@ contract BasicAMBMediator is Ownable {
7161
return addressStorage[MEDIATOR_CONTRACT];
7262
}
7363

74-
/**
75-
* @dev Tells the gas limit to be used in the message execution by the AMB bridge on the other network.
76-
* @return the gas limit for the message execution.
77-
*/
78-
function requestGasLimit() public view returns (uint256) {
79-
return uintStorage[REQUEST_GAS_LIMIT];
80-
}
81-
8264
/**
8365
* @dev Stores a valid AMB bridge contract address.
8466
* @param _bridgeContract the address of the bridge contract.
@@ -96,24 +78,6 @@ contract BasicAMBMediator is Ownable {
9678
addressStorage[MEDIATOR_CONTRACT] = _mediatorContract;
9779
}
9880

99-
/**
100-
* @dev Stores the gas limit to be used in the message execution by the AMB bridge on the other network.
101-
* @param _requestGasLimit the gas limit for the message execution.
102-
*/
103-
function _setRequestGasLimit(uint256 _requestGasLimit) internal {
104-
require(_requestGasLimit <= maxGasPerTx());
105-
uintStorage[REQUEST_GAS_LIMIT] = _requestGasLimit;
106-
}
107-
108-
/**
109-
* @dev Tells the address that generated the message on the other network that is currently being executed by
110-
* the AMB bridge.
111-
* @return the address of the message sender.
112-
*/
113-
function messageSender() internal view returns (address) {
114-
return bridgeContract().messageSender();
115-
}
116-
11781
/**
11882
* @dev Tells the id of the message originated on the other network.
11983
* @return the id of the message originated on the other network.
@@ -129,4 +93,6 @@ contract BasicAMBMediator is Ownable {
12993
function maxGasPerTx() internal view returns (uint256) {
13094
return bridgeContract().maxGasPerTx();
13195
}
96+
97+
function _passMessage(bytes memory _data, bool _useOracleLane) internal virtual returns (bytes32);
13298
}

0 commit comments

Comments
 (0)