Skip to content

Commit

Permalink
Remove unneccesary getVersionNumber() function declaration in contrac…
Browse files Browse the repository at this point in the history
…t libraries (#8349)

### Description

Current Behavior: Multiple contract libraries have versioning bytecode that is overwritten by inheriting contracts or simply unused
New Behavior: Removed unnecessary versioning in library contracts. Only difference in functionality would be if one were attempt to query the version of a library with getVersionNumber(), although this is seldom done in practice


### Testing
Changes do not need to be tested specifically, since getVersion was not called on libraries.

### Related issues

- Consistently unversion contract libraries #7435

### Backwards compatibility

Changes are backwards compatible since the functionality being removed was unnecessary and not used.

### Documentation

N/a
  • Loading branch information
Tjudice authored and yorhodes committed Aug 11, 2021
1 parent 8534798 commit 2a8cafa
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 60 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/common/Accounts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ contract Accounts is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 2, 0);
return (1, 1, 2, 1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract MetaTransactionWallet is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
return (1, 1, 1, 1);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions packages/protocol/contracts/common/Signatures.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ pragma solidity ^0.5.13;
import "openzeppelin-solidity/contracts/cryptography/ECDSA.sol";

library Signatures {
/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 2, 0);
}

/**
* @notice Given a signed address, returns the signer of the address.
* @param message The address that was signed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ library AddressLinkedList {
using LinkedList for LinkedList.List;
using SafeMath for uint256;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ library AddressSortedLinkedList {
using SafeMath for uint256;
using SortedLinkedList for SortedLinkedList.List;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ library AddressSortedLinkedListWithMedian {
using SafeMath for uint256;
using SortedLinkedListWithMedian for SortedLinkedListWithMedian.List;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ library IntegerSortedLinkedList {
using SafeMath for uint256;
using SortedLinkedList for SortedLinkedList.List;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

/**
* @notice Inserts an element into a doubly linked list.
* @param list A storage pointer to the underlying list.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/governance/Election.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ contract Election is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 2, 0);
return (1, 1, 2, 1);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/governance/Governance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ contract Governance is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 2, 1, 0);
return (1, 2, 1, 1);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/governance/LockedGold.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contract LockedGold is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 1);
return (1, 1, 1, 2);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions packages/protocol/contracts/governance/Proposals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ library Proposals {
string descriptionUrl;
}

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

/**
* @notice Constructs a proposal.
* @param proposal The proposal struct to be constructed.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/identity/Attestations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ contract Attestations is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 1);
return (1, 1, 1, 2);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/identity/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ contract Escrow is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 1);
return (1, 1, 1, 2);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/stability/SortedOracles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract SortedOracles is ISortedOracles, ICeloVersionedContract, Ownable, Initi
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 2, 0);
return (1, 1, 2, 1);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/scripts/bash/release-on-devchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ yarn run truffle exec ./scripts/truffle/verify-bytecode.js --network development

echo "- Check versions of current branch"
# From check-versions.sh
CONTRACT_EXCLUSION_REGEX=".*Test|Mock.*|I[A-Z].*|.*Proxy|.*LinkedList.*|MultiSig.*|ReleaseGold|SlasherUtil|FixidityLib|Signatures|Proposals|UsingPrecompiles"
CONTRACT_EXCLUSION_REGEX=".*Test|Mock.*|I[A-Z].*|.*Proxy|MultiSig.*|ReleaseGold|SlasherUtil|UsingPrecompiles"
yarn ts-node scripts/check-backward.ts sem_check --old_contracts $BUILD_DIR/contracts --new_contracts build/contracts --exclude $CONTRACT_EXCLUSION_REGEX --output_file report.json

# From make-release.sh
Expand Down
7 changes: 4 additions & 3 deletions packages/protocol/scripts/truffle/make-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ const deployImplementation = async (
contractName: string,
Contract: TruffleContract<Truffle.ContractInstance>,
dryRun: boolean,
from: string
from: string,
requireVersion = true
) => {
const testingDeployment = false
if (from) {
Expand All @@ -95,7 +96,7 @@ const deployImplementation = async (
const getVersionNumberAbi = contract.abi.find(
(abi: any) => abi.type === 'function' && abi.name === 'getVersionNumber'
)
if (!getVersionNumberAbi) {
if (requireVersion && !getVersionNumberAbi) {
throw new Error(`Contract ${contractName} has changes but does not specify a version number`)
}
return contract
Expand Down Expand Up @@ -208,7 +209,7 @@ const deployLibrary = async (
isDryRun: boolean,
from: string
) => {
const contract = await deployImplementation(contractName, contractArtifact, isDryRun, from)
const contract = await deployImplementation(contractName, contractArtifact, isDryRun, from, false)
addresses.set(contractName, contract.address)
return
}
Expand Down

0 comments on commit 2a8cafa

Please sign in to comment.