Skip to content

Commit

Permalink
blockchainparams: remove minimum client version (#10204)
Browse files Browse the repository at this point in the history
* Remove minimum client version set/get/check

According to CIP-53: celo-org/celo-proposals#318

* BlockchainParameters: remove ClientVersion

In the previous commit, all usage of it has been removed. So now we can
remove the state and the initializer params.

* Undo remove ClientVersion from BlockchainParameters

to keep the storage layout identical.

* BlockchainParameters: bump major version

We changed the initializer, so the contract API has changed.
  • Loading branch information
karlb authored Jun 12, 2023
1 parent 9c47cbe commit e208c22
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 229 deletions.
18 changes: 0 additions & 18 deletions packages/celotool/src/e2e-tests/blockchain_parameters_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ describe('Blockchain parameters tests', function (this: any) {
parameters = await kit.contracts.getBlockchainParameters()
}

const setMinimumClientVersion = async (major: number, minor: number, patch: number) => {
await parameters.setMinimumClientVersion(major, minor, patch).send({ from: validatorAddress })
}

describe('when running a node', () => {
before(async () => {
await restartGeth()
Expand All @@ -84,19 +80,5 @@ describe('Blockchain parameters tests', function (this: any) {
const res = await parameters.getBlockGasLimit()
assert.equal(0, res.comparedTo(23000000))
})
it('should exit when minimum version is updated', async () => {
this.timeout(0)
await setMinimumClientVersion(1, 9, 99)
// The client checks every 60 seconds and then waits 10 seconds before quitting, so we
// may have to wait a little over 70 seconds
await sleep(75, true)
try {
// It should have exited by now, call RPC to trigger error
await kit.connection.getBlockNumber()
} catch (_) {
return
}
throw new Error('expected failure')
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ ___

*Defined in [connection.ts:327](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/connect/src/connection.ts#L327)*

**`deprecated`** no longer needed since gasPrice is available on minimumClientVersion node rpc
**`deprecated`** no longer needed since gasPrice is available on node rpc

**Parameters:**

Expand Down Expand Up @@ -656,7 +656,7 @@ ___

*Defined in [connection.ts:337](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/connect/src/connection.ts#L337)*

**`deprecated`** no longer needed since gasPrice is available on minimumClientVersion node rpc
**`deprecated`** no longer needed since gasPrice is available on node rpc

**Parameters:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ___

*Defined in [packages/sdk/contractkit/src/kit.ts:113](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/kit.ts#L113)*

**`deprecated`** no longer needed since gasPrice is available on minimumClientVersion node rpc
**`deprecated`** no longer needed since gasPrice is available on node rpc

___

Expand Down Expand Up @@ -246,7 +246,7 @@ ___

*Defined in [packages/sdk/contractkit/src/kit.ts:285](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/kit.ts#L285)*

**`deprecated`** no longer needed since gasPrice is available on minimumClientVersion node rpc
**`deprecated`** no longer needed since gasPrice is available on node rpc

**Parameters:**

Expand Down Expand Up @@ -472,7 +472,7 @@ ___

*Defined in [packages/sdk/contractkit/src/kit.ts:210](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/kit.ts#L210)*

**`deprecated`** no longer needed since gasPrice is available on minimumClientVersion node rpc
**`deprecated`** no longer needed since gasPrice is available on node rpc

**Parameters:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Network parameters that are configurable by governance.
* [methodIds](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#methodids)
* [setBlockGasLimit](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#setblockgaslimit)
* [setIntrinsicGasForAlternativeFeeCurrency](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#setintrinsicgasforalternativefeecurrency)
* [setMinimumClientVersion](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#setminimumclientversion)
* [setUptimeLookbackWindow](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#setuptimelookbackwindow)

### Accessors
Expand All @@ -42,7 +41,6 @@ Network parameters that are configurable by governance.
* [getEpochSizeNumber](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#getepochsizenumber)
* [getFirstBlockNumberForEpoch](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#getfirstblocknumberforepoch)
* [getLastBlockNumberForEpoch](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#getlastblocknumberforepoch)
* [getMinimumClientVersion](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#getminimumclientversion)
* [getPastEvents](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#getpastevents)
* [version](_wrappers_blockchainparameters_.blockchainparameterswrapper.md#version)

Expand Down Expand Up @@ -259,28 +257,6 @@ Name | Type |

___

### setMinimumClientVersion

**setMinimumClientVersion**: *function* = proxySend(
this.connection,
this.contract.methods.setMinimumClientVersion
)

*Defined in [packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts:63](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts#L63)*

Set minimum client version.

#### Type declaration:

▸ (...`args`: InputArgs): *CeloTransactionObject‹Output›*

**Parameters:**

Name | Type |
------ | ------ |
`...args` | InputArgs |

___

### setUptimeLookbackWindow

Expand Down Expand Up @@ -387,19 +363,6 @@ Name | Type |

**Returns:** *Promise‹number›*

___

### getMinimumClientVersion

**getMinimumClientVersion**(): *Promise‹[ClientVersion](../interfaces/_wrappers_blockchainparameters_.clientversion.md)*

*Defined in [packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts:51](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts#L51)*

Get minimum client version.

**Returns:** *Promise‹[ClientVersion](../interfaces/_wrappers_blockchainparameters_.clientversion.md)*

___

### getPastEvents

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

* [blockGasLimit](_wrappers_blockchainparameters_.blockchainparametersconfig.md#blockgaslimit)
* [intrinsicGasForAlternativeFeeCurrency](_wrappers_blockchainparameters_.blockchainparametersconfig.md#intrinsicgasforalternativefeecurrency)
* [minimumClientVersion](_wrappers_blockchainparameters_.blockchainparametersconfig.md#minimumclientversion)

## Properties

### blockGasLimit
Expand All @@ -29,11 +27,3 @@ ___
**intrinsicGasForAlternativeFeeCurrency**: *BigNumber*

*Defined in [packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts:14](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts#L14)*

___

### minimumClientVersion

**minimumClientVersion**: *[ClientVersion](_wrappers_blockchainparameters_.clientversion.md)*

*Defined in [packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts:13](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts#L13)*
51 changes: 7 additions & 44 deletions packages/protocol/contracts/governance/BlockchainParameters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "../common/UsingPrecompiles.sol";
contract BlockchainParameters is Ownable, Initializable, UsingPrecompiles {
using SafeMath for uint256;

// obsolete
struct ClientVersion {
uint256 major;
uint256 minor;
Expand All @@ -26,12 +27,11 @@ contract BlockchainParameters is Ownable, Initializable, UsingPrecompiles {
uint256 nextValueActivationEpoch;
}

ClientVersion private minimumClientVersion;
ClientVersion private minimumClientVersion; // obsolete
uint256 public blockGasLimit;
uint256 public intrinsicGasForAlternativeFeeCurrency;
LookbackWindow public uptimeLookbackWindow;

event MinimumClientVersionSet(uint256 major, uint256 minor, uint256 patch);
event IntrinsicGasForAlternativeFeeCurrencySet(uint256 gas);
event BlockGasLimitSet(uint256 limit);
event UptimeLookbackWindowSet(uint256 window, uint256 activationEpoch);
Expand All @@ -44,23 +44,15 @@ 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);
setMinimumClientVersion(major, minor, patch);
setBlockGasLimit(gasLimit);
setIntrinsicGasForAlternativeFeeCurrency(_gasForNonGoldCurrencies);
setUptimeLookbackWindow(lookbackWindow);
Expand All @@ -74,22 +66,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);
}

/**
* @notice Sets the minimum client version.
* @param major Major version.
* @param minor Minor version.
* @param patch Patch version.
* @dev For example if the version is 1.9.2, 1 is the major version, 9 is minor,
* and 2 is the patch level.
*/
function setMinimumClientVersion(uint256 major, uint256 minor, uint256 patch) public onlyOwner {
minimumClientVersion.major = major;
minimumClientVersion.minor = minor;
minimumClientVersion.patch = patch;
emit MinimumClientVersionSet(major, minor, patch);
return (1, 3, 0, 0);
}

/**
Expand Down Expand Up @@ -149,18 +126,4 @@ contract BlockchainParameters is Ownable, Initializable, UsingPrecompiles {
}
}

/**
* @notice Query minimum client version.
* @return Major version number.
* @return Minor version number.
* @return Patch version number.
*/
function getMinimumClientVersion()
external
view
returns (uint256 major, uint256 minor, uint256 patch)
{
return (minimumClientVersion.major, minimumClientVersion.minor, minimumClientVersion.patch);
}

}
1 change: 0 additions & 1 deletion packages/protocol/governanceConstitution.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const DefaultConstitution = {
},
BlockchainParameters: {
default: 0.9,
setMinimumClientVersion: 0.9,
setBlockGasLimit: 0.8,
setIntrinsicGasForAlternativeFeeCurrency: 0.8,
},
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
Loading

0 comments on commit e208c22

Please sign in to comment.