Skip to content

Commit ec3d4a4

Browse files
committed
requested fixes
* remove gas limit * isolate gas options into mixin function * remove remaining gasPrice references
1 parent ca81f0a commit ec3d4a4

File tree

10 files changed

+79
-172
lines changed

10 files changed

+79
-172
lines changed

index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ const constants = {
9090
ZERO_ADDRESS: '0x' + '0'.repeat(40),
9191
ZERO_BYTES32: '0x' + '0'.repeat(64),
9292

93-
OVM_GAS_PRICE_GWEI: '0.015',
94-
9593
inflationStartTimestampInSecs: 1551830400, // 2019-03-06T00:00:00Z
9694
};
9795

publish/src/Deployer.js

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const linker = require('solc/linker');
44
const ethers = require('ethers');
55
const { gray, green, yellow } = require('chalk');
66
const fs = require('fs');
7-
const { stringify, getExplorerLinkPrefix } = require('./util');
7+
const { stringify, getExplorerLinkPrefix, mixinGasOptions } = require('./util');
88
const { getVersions, getUsers } = require('../..');
99

1010
class Deployer {
@@ -114,28 +114,17 @@ class Deployer {
114114
return ethers.utils.defaultAbiCoder.encode(types, params);
115115
}
116116

117-
async addGasOptions(tx) {
118-
if (this.gasPrice) {
119-
tx.gasPrice = ethers.utils.parseUnits(this.gasPrice.toString(), 'gwei');
120-
} else if ((await this.provider.getFeeData()).maxFeePerGas) {
121-
if (this.maxFeePerGas)
122-
tx.maxFeePerGas = ethers.utils.parseUnits(this.maxFeePerGas.toString(), 'gwei');
123-
if (this.maxPriorityFeePerGas)
124-
tx.maxPriorityFeePerGas = ethers.utils.parseUnits(
125-
this.maxPriorityFeePerGas.toString(),
126-
'gwei'
127-
);
128-
}
129-
}
130-
131117
async sendDummyTx() {
132-
const tx = {
133-
to: '0x0000000000000000000000000000000000000001',
134-
data: '0x0000000000000000000000000000000000000000000000000000000000000000',
135-
value: 0,
136-
};
137-
138-
this.addGasOptions(tx);
118+
const tx = await mixinGasOptions(
119+
{
120+
to: '0x0000000000000000000000000000000000000001',
121+
data: '0x0000000000000000000000000000000000000000000000000000000000000000',
122+
value: 0,
123+
},
124+
this.provider,
125+
this.maxFeePerGas,
126+
this.maxPriorityFeePerGas
127+
);
139128

140129
const response = await this.signer.sendTransaction(tx);
141130
await response.wait();
@@ -145,16 +134,13 @@ class Deployer {
145134
}
146135
}
147136

148-
async sendOverrides(type = 'method-call') {
149-
const gasLimit = this.useOvm
150-
? undefined
151-
: type === 'method-call'
152-
? this.methodCallGasLimit
153-
: this.contractDeploymentGasLimit;
154-
155-
const params = { gasLimit };
156-
157-
this.addGasOptions(params);
137+
async sendOverrides() {
138+
const params = await mixinGasOptions(
139+
{},
140+
this.provider,
141+
this.maxFeePerGas,
142+
this.maxPriorityFeePerGas
143+
);
158144

159145
if (this.nonceManager) {
160146
params.nonce = await this.nonceManager.getNonce();
@@ -295,7 +281,7 @@ class Deployer {
295281

296282
const factory = new ethers.ContractFactory(compiled.abi, bytecode, this.signer);
297283

298-
const overrides = await this.sendOverrides('contract-deployment');
284+
const overrides = await this.sendOverrides();
299285

300286
deployedContract = await factory.deploy(...args, overrides);
301287
const receipt = await deployedContract.deployTransaction.wait();

publish/src/command-utils/transact.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const ethers = require('ethers');
2-
const { appendOwnerActionGenerator, confirmAction, stringify } = require('../util');
2+
const {
3+
appendOwnerActionGenerator,
4+
confirmAction,
5+
stringify,
6+
mixinGasOptions,
7+
} = require('../util');
38
const { gray, yellow, green, redBright } = require('chalk');
49

510
let _dryRunCounter = 0;
@@ -19,8 +24,8 @@ const performTransactionalStep = async ({
1924
expected,
2025
write,
2126
writeArg, // none, 1 or an array of args, array will be spread into params
22-
gasLimit,
23-
deployer,
27+
maxFeePerGas,
28+
maxPriorityFeePerGas,
2429
generateSolidity,
2530
explorerLinkPrefix,
2631
ownerActions,
@@ -76,11 +81,12 @@ const performTransactionalStep = async ({
7681
_dryRunCounter++;
7782
hash = '0x' + _dryRunCounter.toString().padStart(64, '0');
7883
} else {
79-
const overrides = {
80-
gasLimit,
81-
};
82-
83-
deployer.addGasOptions(overrides);
84+
const overrides = await mixinGasOptions(
85+
{},
86+
target.provider,
87+
maxFeePerGas,
88+
maxPriorityFeePerGas
89+
);
8490

8591
if (nonceManager) {
8692
overrides.nonce = await nonceManager.getNonce();

publish/src/commands/deploy-shorting-rewards.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ const deployShortingRewards = async ({
252252
gasLimit: methodCallGasLimit, // allow overriding of gasLimit
253253
...opts,
254254
signer,
255-
deployer,
255+
maxFeePerGas,
256+
maxPriorityFeePerGas,
256257
explorerLinkPrefix,
257258
ownerActions,
258259
ownerActionsFile,

publish/src/commands/deploy/index.js

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ const {
1818
const { performTransactionalStep } = require('../../command-utils/transact');
1919

2020
const {
21-
constants: {
22-
BUILD_FOLDER,
23-
CONFIG_FILENAME,
24-
SYNTHS_FILENAME,
25-
DEPLOYMENT_FILENAME,
26-
OVM_GAS_PRICE_GWEI,
27-
},
21+
constants: { BUILD_FOLDER, CONFIG_FILENAME, SYNTHS_FILENAME, DEPLOYMENT_FILENAME },
2822
} = require('../../../..');
2923

3024
const addSynthsToProtocol = require('./add-synths-to-protocol');
@@ -49,8 +43,6 @@ const takeDebtSnapshotWhenRequired = require('./take-debt-snapshot-when-required
4943

5044
const DEFAULTS = {
5145
priorityGasPrice: '1',
52-
methodCallGasLimit: 250e3, // 250k
53-
contractDeploymentGasLimit: 6.9e6, // TODO split out into separate limits for different contracts, Proxys, Synths, Synthetix
5446
debtSnapshotMaxDeviation: 0.01, // a 1 percent deviation will trigger a snapshot
5547
network: 'kovan',
5648
buildPath: path.join(__dirname, '..', '..', '..', '..', BUILD_FOLDER),
@@ -60,7 +52,6 @@ const deploy = async ({
6052
addNewSynths,
6153
buildPath = DEFAULTS.buildPath,
6254
concurrency,
63-
contractDeploymentGasLimit = DEFAULTS.contractDeploymentGasLimit,
6455
deploymentPath,
6556
dryRun = false,
6657
forceUpdateInverseSynthsOnTestnet = false,
@@ -71,7 +62,6 @@ const deploy = async ({
7162
ignoreCustomParameters,
7263
ignoreSafetyChecks,
7364
manageNonces,
74-
methodCallGasLimit = DEFAULTS.methodCallGasLimit,
7565
network = DEFAULTS.network,
7666
oracleExrates,
7767
privateKey,
@@ -86,18 +76,6 @@ const deploy = async ({
8676
deploymentPath = deploymentPath || getDeploymentPathForNetwork({ network, useOvm });
8777
ensureDeploymentPath(deploymentPath);
8878

89-
let gasPrice = null;
90-
91-
// Gas price needs to be set to 0.015 gwei in Optimism,
92-
// and gas limits need to be dynamically set by the provider.
93-
// More info:
94-
// https://www.notion.so/How-to-pay-Fees-in-Optimistic-Ethereum-f706f4e5b13e460fa5671af48ce9a695
95-
if (useOvm) {
96-
gasPrice = OVM_GAS_PRICE_GWEI;
97-
methodCallGasLimit = undefined;
98-
contractDeploymentGasLimit = undefined;
99-
}
100-
10179
const limitPromise = pLimit(concurrency);
10280

10381
const {
@@ -141,14 +119,13 @@ const deploy = async ({
141119

142120
performSafetyChecks({
143121
config,
144-
contractDeploymentGasLimit,
145122
deployment,
146123
deploymentPath,
147124
freshDeploy,
148125
ignoreSafetyChecks,
149126
manageNonces,
150-
methodCallGasLimit,
151-
gasPrice,
127+
maxFeePerGas,
128+
maxPriorityFeePerGas,
152129
network,
153130
useOvm,
154131
});
@@ -202,15 +179,12 @@ const deploy = async ({
202179

203180
const deployer = new Deployer({
204181
compiled,
205-
contractDeploymentGasLimit,
206182
config,
207183
configFile,
208184
deployment,
209185
deploymentFile,
210-
gasPrice,
211186
maxFeePerGas,
212187
maxPriorityFeePerGas,
213-
methodCallGasLimit,
214188
network,
215189
privateKey,
216190
providerUrl,
@@ -239,17 +213,14 @@ const deploy = async ({
239213
addNewSynths,
240214
concurrency,
241215
config,
242-
contractDeploymentGasLimit,
243216
deployer,
244217
deploymentPath,
245218
dryRun,
246219
earliestCompiledTimestamp,
247220
freshDeploy,
248-
gasPrice,
249221
maxFeePerGas,
250222
maxPriorityFeePerGas,
251223
getDeployParameter,
252-
methodCallGasLimit,
253224
network,
254225
oracleExrates,
255226
providerUrl,
@@ -271,12 +242,11 @@ const deploy = async ({
271242
const runStep = async opts => {
272243
const { noop, ...rest } = await performTransactionalStep({
273244
...opts,
274-
// no gas limit on OVM (use system limit), otherwise use provided limit or the methodCall amount
275-
gasLimit: useOvm ? undefined : opts.gasLimit || methodCallGasLimit,
276245
signer,
277246
dryRun,
278247
explorerLinkPrefix,
279-
deployer,
248+
maxFeePerGas,
249+
maxPriorityFeePerGas,
280250
generateSolidity,
281251
nonceManager: manageNonces ? nonceManager : undefined,
282252
ownerActions,
@@ -410,7 +380,6 @@ const deploy = async ({
410380

411381
await configureSystemSettings({
412382
deployer,
413-
methodCallGasLimit,
414383
useOvm,
415384
generateSolidity,
416385
getDeployParameter,
@@ -472,12 +441,6 @@ module.exports = {
472441
'Path to a folder hosting compiled files from the "build" step in this script',
473442
DEFAULTS.buildPath
474443
)
475-
.option(
476-
'-c, --contract-deployment-gas-limit <value>',
477-
'Contract deployment gas limit',
478-
parseFloat,
479-
DEFAULTS.contractDeploymentGasLimit
480-
)
481444
.option(
482445
'-d, --deployment-path <value>',
483446
`Path to a folder that has your input configuration file ${CONFIG_FILENAME}, the synth list ${SYNTHS_FILENAME} and where your ${DEPLOYMENT_FILENAME} files will go`
@@ -521,12 +484,6 @@ module.exports = {
521484
'-l, --oracle-gas-limit <value>',
522485
'The address of the gas limit oracle for this network (default is use existing)'
523486
)
524-
.option(
525-
'-m, --method-call-gas-limit <value>',
526-
'Method call gas limit',
527-
parseFloat,
528-
DEFAULTS.methodCallGasLimit
529-
)
530487
.option(
531488
'-n, --network <value>',
532489
'The network to run off.',

publish/src/commands/nominate.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const {
1515
loadAndCheckRequiredSources,
1616
loadConnections,
1717
confirmAction,
18+
mixinGasOptions,
1819
} = require('../util');
1920

2021
const DEFAULTS = {
21-
maxPriorityFeePerGas: '1',
22-
gasLimit: 2e5, // 200,000
22+
priorityGasPrice: '1',
2323
};
2424

2525
const nominate = async ({
@@ -29,8 +29,7 @@ const nominate = async ({
2929
useFork = false,
3030
deploymentPath,
3131
maxFeePerGas,
32-
maxPriorityFeePerGas = '1',
33-
gasLimit = DEFAULTS.gasLimit,
32+
maxPriorityFeePerGas = DEFAULTS.priorityGasPrice,
3433
useOvm,
3534
privateKey,
3635
providerUrl,
@@ -148,17 +147,8 @@ const nominate = async ({
148147
const nominationFnc =
149148
'nominateOwner' in deployedContract ? 'nominateOwner' : 'nominateNewOwner';
150149

151-
const feeData = await provider.getFeeData();
152-
153150
console.log(yellow(`Invoking ${contract}.${nominationFnc}(${newOwner})`));
154-
const overrides = {
155-
gasLimit,
156-
};
157-
158-
if (feeData.maxFeePerGas) {
159-
overrides.maxFeePerGas = ethers.utils.parseUnits(maxFeePerGas, 'gwei');
160-
overrides.maxPriorityFeePerGas = ethers.utils.parseUnits(maxPriorityFeePerGas, 'gwei');
161-
}
151+
const overrides = await mixinGasOptions({}, provider, maxFeePerGas, maxPriorityFeePerGas);
162152

163153
const tx = await deployedContract[nominationFnc](newOwner, overrides);
164154
await tx.wait();
@@ -185,13 +175,16 @@ module.exports = {
185175
`Path to a folder that has your input configuration file ${CONFIG_FILENAME} and where your ${DEPLOYMENT_FILENAME} files will go`
186176
)
187177
.option('-g, --max-fee-per-gas <value>', 'Maximum base gas fee price in GWEI')
188-
.option('--max-priority-fee-per-gas <value>', 'Priority gas fee price in GWEI', '1')
178+
.option(
179+
'--max-priority-fee-per-gas <value>',
180+
'Priority gas fee price in GWEI',
181+
DEFAULTS.priorityGasPrice
182+
)
189183
.option(
190184
'-k, --use-fork',
191185
'Perform the deployment on a forked chain running on localhost (see fork command).',
192186
false
193187
)
194-
.option('-l, --gas-limit <value>', 'Gas limit', parseInt, 15e4)
195188
.option('-n, --network <value>', 'The network to run off.', x => x.toLowerCase(), 'kovan')
196189
.option(
197190
'-o, --new-owner <value>',

0 commit comments

Comments
 (0)