Skip to content

Commit

Permalink
Remove excess parameter from AdminUpgradeabilityProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
varasev committed Mar 24, 2020
1 parent e69b32d commit 74e0855
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 44 deletions.
6 changes: 1 addition & 5 deletions contracts/upgradeability/AdminUpgradeabilityProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ contract AdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, Upgradeabilit
* Contract constructor.
* @param _logic address of the initial implementation.
* @param _admin Address of the proxy administrator.
* @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
* This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
*/
constructor(address _logic, address _admin, bytes memory _data) UpgradeabilityProxy(_logic, _data) public payable {
constructor(address _logic, address _admin) UpgradeabilityProxy(_logic, new bytes(0)) public payable {
assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1));
_setAdmin(_admin);
}
Expand Down
3 changes: 1 addition & 2 deletions scripts/deploy_for_xdai.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ async function deploy(contractName, constructorArguments = null) {

const proxy = await signAndDeploy(proxyContractName, [
implementation.options.address, // implementation address
owner, // admin (owner)
[]
owner // admin (owner)
]);
assert(await proxy.methods.admin().call() == owner);
assert(await proxy.methods.implementation().call() == implementation.options.address);
Expand Down
18 changes: 6 additions & 12 deletions scripts/make_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ async function main() {
// Build ValidatorSetAuRa contract
deploy = await contract.deploy({data: '0x' + storageProxyCompiled.bytecode, arguments: [
'0x1000000000000000000000000000000000000000', // implementation address
owner,
[]
owner
]});
spec.engine.authorityRound.params.validators.multi = {
"0": {
Expand All @@ -99,8 +98,7 @@ async function main() {
// Build StakingAuRa contract
deploy = await contract.deploy({data: '0x' + storageProxyCompiled.bytecode, arguments: [
'0x1100000000000000000000000000000000000000', // implementation address
owner,
[]
owner
]});
spec.accounts[STAKING_CONTRACT] = {
balance: '0',
Expand All @@ -114,8 +112,7 @@ async function main() {
// Build BlockRewardAuRa contract
deploy = await contract.deploy({data: '0x' + storageProxyCompiled.bytecode, arguments: [
'0x2000000000000000000000000000000000000000', // implementation address
owner,
[]
owner
]});
spec.accounts[BLOCK_REWARD_CONTRACT] = {
balance: '0',
Expand All @@ -131,8 +128,7 @@ async function main() {
// Build RandomAuRa contract
deploy = await contract.deploy({data: '0x' + storageProxyCompiled.bytecode, arguments: [
'0x3000000000000000000000000000000000000000', // implementation address
owner,
[]
owner
]});
spec.accounts[RANDOM_CONTRACT] = {
balance: '0',
Expand All @@ -147,8 +143,7 @@ async function main() {
// Build TxPermission contract
deploy = await contract.deploy({data: '0x' + storageProxyCompiled.bytecode, arguments: [
'0x4000000000000000000000000000000000000000', // implementation address
owner,
[]
owner
]});
spec.accounts[PERMISSION_CONTRACT] = {
balance: '0',
Expand All @@ -163,8 +158,7 @@ async function main() {
// Build Certifier contract
deploy = await contract.deploy({data: '0x' + storageProxyCompiled.bytecode, arguments: [
'0x5000000000000000000000000000000000000000', // implementation address
owner,
[]
owner
]});
spec.accounts[CERTIFIER_CONTRACT] = {
balance: '0',
Expand Down
16 changes: 8 additions & 8 deletions test/BlockRewardAuRa.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ contract('BlockRewardAuRa', async accounts => {
initialStakingAddresses[2].should.not.be.equal('0x0000000000000000000000000000000000000000');
// Deploy BlockRewardAuRa contract
blockRewardAuRa = await BlockRewardAuRa.new();
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner, []);
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner);
blockRewardAuRa = await BlockRewardAuRa.at(blockRewardAuRa.address);
// Deploy RandomAuRa contract
randomAuRa = await RandomAuRa.new();
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner, []);
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner);
randomAuRa = await RandomAuRa.at(randomAuRa.address);
// Deploy StakingAuRa contract
stakingAuRa = await StakingAuRa.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRa.at(stakingAuRa.address);
// Deploy ValidatorSetAuRa contract
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);

// Initialize ValidatorSetAuRa
Expand Down Expand Up @@ -373,19 +373,19 @@ contract('BlockRewardAuRa', async accounts => {
initialStakingAddresses[2].should.not.be.equal('0x0000000000000000000000000000000000000000');
// Deploy BlockRewardAuRa contract
blockRewardAuRa = await BlockRewardAuRa.new();
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner, []);
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner);
blockRewardAuRa = await BlockRewardAuRa.at(blockRewardAuRa.address);
// Deploy RandomAuRa contract
randomAuRa = await RandomAuRa.new();
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner, []);
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner);
randomAuRa = await RandomAuRa.at(randomAuRa.address);
// Deploy StakingAuRa contract
stakingAuRa = await StakingAuRa.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRa.at(stakingAuRa.address);
// Deploy ValidatorSetAuRa contract
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);

// Initialize ValidatorSetAuRa
Expand Down
16 changes: 8 additions & 8 deletions test/StakingAuRa.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ contract('StakingAuRa', async accounts => {
initialStakingAddresses[2].should.not.be.equal('0x0000000000000000000000000000000000000000');
// Deploy BlockReward contract
blockRewardAuRa = await BlockRewardAuRa.new();
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner, []);
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner);
blockRewardAuRa = await BlockRewardAuRa.at(blockRewardAuRa.address);
// Deploy Random contract
randomAuRa = await RandomAuRa.new();
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner, []);
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner);
randomAuRa = await RandomAuRa.at(randomAuRa.address);
// Deploy Staking contract
stakingAuRa = await StakingAuRaTokens.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRaTokens.at(stakingAuRa.address);
// Deploy ValidatorSet contract
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);
// Initialize ValidatorSet
await validatorSetAuRa.initialize(
Expand Down Expand Up @@ -1861,7 +1861,7 @@ contract('StakingAuRa', async accounts => {
beforeEach(async () => {
// Deploy ValidatorSet contract
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);

// Initialize ValidatorSet
Expand Down Expand Up @@ -2406,7 +2406,7 @@ contract('StakingAuRa', async accounts => {

// Deploy StakingAuRa contract
stakingAuRa = await StakingAuRaCoins.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRaCoins.at(stakingAuRa.address);
await validatorSetAuRa.setStakingContract(stakingAuRa.address).should.be.fulfilled;

Expand Down Expand Up @@ -2678,12 +2678,12 @@ contract('StakingAuRa', async accounts => {
it('should fail for a non-removable validator', async () => {
// Deploy Staking contract
stakingAuRa = await StakingAuRaTokens.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRaTokens.at(stakingAuRa.address);

// Deploy ValidatorSet contract
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);

// Initialize ValidatorSet
Expand Down
18 changes: 9 additions & 9 deletions test/ValidatorSetAuRa.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ contract('ValidatorSetAuRa', async accounts => {
owner = accounts[0];
// Deploy BlockReward contract
blockRewardAuRa = await BlockRewardAuRa.new();
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner, []);
blockRewardAuRa = await AdminUpgradeabilityProxy.new(blockRewardAuRa.address, owner);
blockRewardAuRa = await BlockRewardAuRa.at(blockRewardAuRa.address);
// Deploy Staking contract
stakingAuRa = await StakingAuRa.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRa.at(stakingAuRa.address);
// Deploy ValidatorSet contract
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);
});

Expand Down Expand Up @@ -147,7 +147,7 @@ contract('ValidatorSetAuRa', async accounts => {
initialStakingAddresses = accounts.slice(4, 6 + 1); // accounts[4...6]

randomAuRa = await RandomAuRa.new();
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner, []);
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner);
randomAuRa = await RandomAuRa.at(randomAuRa.address);

await validatorSetAuRa.setCurrentBlockNumber(0).should.be.fulfilled;
Expand Down Expand Up @@ -407,7 +407,7 @@ contract('ValidatorSetAuRa', async accounts => {
initialStakingAddresses = accounts.slice(4, 6 + 1); // accounts[4...6]

randomAuRa = await RandomAuRa.new();
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner, []);
randomAuRa = await AdminUpgradeabilityProxy.new(randomAuRa.address, owner);
randomAuRa = await RandomAuRa.at(randomAuRa.address);

await validatorSetAuRa.setCurrentBlockNumber(0).should.be.fulfilled;
Expand Down Expand Up @@ -525,11 +525,11 @@ contract('ValidatorSetAuRa', async accounts => {
});
it('should enqueue unremovable validator anyway', async () => {
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);

stakingAuRa = await StakingAuRa.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRa.at(stakingAuRa.address);

await validatorSetAuRa.setCurrentBlockNumber(0).should.be.fulfilled;
Expand Down Expand Up @@ -700,11 +700,11 @@ contract('ValidatorSetAuRa', async accounts => {
});
it('should choose validators randomly but leave an unremovable validator', async () => {
validatorSetAuRa = await ValidatorSetAuRa.new();
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner, []);
validatorSetAuRa = await AdminUpgradeabilityProxy.new(validatorSetAuRa.address, owner);
validatorSetAuRa = await ValidatorSetAuRa.at(validatorSetAuRa.address);

stakingAuRa = await StakingAuRa.new();
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner, []);
stakingAuRa = await AdminUpgradeabilityProxy.new(stakingAuRa.address, owner);
stakingAuRa = await StakingAuRa.at(stakingAuRa.address);

await validatorSetAuRa.setCurrentBlockNumber(0).should.be.fulfilled;
Expand Down

0 comments on commit 74e0855

Please sign in to comment.