Skip to content

Commit

Permalink
BlockchainParameters: remove ClientVersion
Browse files Browse the repository at this point in the history
In the previous commit, all usage of it has been removed. So now we can
remove the state and the initializer params.
  • Loading branch information
karlb committed Jun 9, 2023
1 parent a9e1adf commit 486d819
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 45 deletions.
24 changes: 5 additions & 19 deletions packages/protocol/contracts/governance/BlockchainParameters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import "../common/UsingPrecompiles.sol";
contract BlockchainParameters is Ownable, Initializable, UsingPrecompiles {
using SafeMath for uint256;

struct ClientVersion {
uint256 major;
uint256 minor;
uint256 patch;
}

struct LookbackWindow {
// Value for lookbackWindow before `nextValueActivationBlock`
uint256 oldValue;
Expand All @@ -26,7 +20,6 @@ contract BlockchainParameters is Ownable, Initializable, UsingPrecompiles {
uint256 nextValueActivationEpoch;
}

ClientVersion private minimumClientVersion;
uint256 public blockGasLimit;
uint256 public intrinsicGasForAlternativeFeeCurrency;
LookbackWindow public uptimeLookbackWindow;
Expand All @@ -43,21 +36,14 @@ contract BlockchainParameters is Ownable, Initializable, UsingPrecompiles {

/**
* @notice Used in place of the constructor to allow the contract to be upgradable via proxy.
* @param major Minimum client version that can be used in the chain, major version.
* @param minor Minimum client version that can be used in the chain, minor version.
* @param patch Minimum client version that can be used in the chain, patch level.
* @param _gasForNonGoldCurrencies Intrinsic gas for non-gold gas currencies.
* @param gasLimit Block gas limit.
* @param lookbackWindow Lookback window for measuring validator uptime.
*/
function initialize(
uint256 major,
uint256 minor,
uint256 patch,
uint256 _gasForNonGoldCurrencies,
uint256 gasLimit,
uint256 lookbackWindow
) external initializer {
function initialize(uint256 _gasForNonGoldCurrencies, uint256 gasLimit, uint256 lookbackWindow)
external
initializer
{
_transferOwnership(msg.sender);
setBlockGasLimit(gasLimit);
setIntrinsicGasForAlternativeFeeCurrency(_gasForNonGoldCurrencies);
Expand All @@ -72,7 +58,7 @@ contract BlockchainParameters is Ownable, Initializable, UsingPrecompiles {
* @return Patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 2, 0, 0);
return (2, 2, 0, 0);
}

/**
Expand Down
4 changes: 0 additions & 4 deletions packages/protocol/migrations/19_blockchainparams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { config } from '@celo/protocol/migrationsConfig'
import { BlockchainParametersInstance } from 'types'

const initializeArgs = async (_: string): Promise<any[]> => {
const version = config.blockchainParameters.minimumClientVersion
return [
version.major,
version.minor,
version.patch,
config.blockchainParameters.gasForNonGoldCurrencies,
config.blockchainParameters.deploymentBlockGasLimit,
config.blockchainParameters.uptimeLookbackWindow,
Expand Down
5 changes: 0 additions & 5 deletions packages/protocol/migrationsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ const DefaultConfig = {
},
blockchainParameters: {
gasForNonGoldCurrencies: 50000,
minimumClientVersion: {
major: 1,
minor: 0,
patch: 0,
},
deploymentBlockGasLimit: 20000000,
blockGasLimit: 13000000,
uptimeLookbackWindow: 12,
Expand Down
19 changes: 2 additions & 17 deletions packages/protocol/test/governance/network/blockchainparams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ const EPOCH = 100

contract('BlockchainParameters', (accounts: string[]) => {
let blockchainParameters: BlockchainParametersInstance
const version = {
major: 1,
minor: 8,
patch: 2,
}
const gasLimit = 7000000
const gasForNonGoldCurrencies = 50000

Expand Down Expand Up @@ -150,14 +145,7 @@ contract('BlockchainParameters', (accounts: string[]) => {
const lookbackWindow = 20

it('should set the variables', async () => {
await blockchainParameters.initialize(
version.major,
version.minor,
version.patch,
gasForNonGoldCurrencies,
gasLimit,
lookbackWindow
)
await blockchainParameters.initialize(gasForNonGoldCurrencies, gasLimit, lookbackWindow)
assert.equal((await blockchainParameters.blockGasLimit()).toNumber(), gasLimit)

// need to wait an epoch for uptimeLookbackWindow
Expand All @@ -169,14 +157,11 @@ contract('BlockchainParameters', (accounts: string[]) => {
})
it('should emit correct events', async () => {
const resp = await blockchainParameters.initialize(
version.major,
version.minor,
version.patch,
gasForNonGoldCurrencies,
gasLimit,
lookbackWindow
)
assert.equal(resp.logs.length, 5)
assert.equal(resp.logs.length, 4)
assertContainSubset(resp.logs[2], {
event: 'IntrinsicGasForAlternativeFeeCurrencySet',
args: {
Expand Down

0 comments on commit 486d819

Please sign in to comment.