Skip to content

Commit

Permalink
New parameter on "transactionIntentBuilder": "addDataMovementGas".
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed Sep 17, 2023
1 parent 2f261d6 commit 8dcf4bd
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: Address.fromBech32(DELEGATION_MANAGER_SC_ADDRESS),
dataParts: dataParts,
executionGasLimit: executionGasLimit,
gasLimit: executionGasLimit,
addDataMovementGas: true,
value: options.value
}).build();
}
Expand All @@ -77,7 +78,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: this.computeExecutionGasLimitForNodesManagement(numNodes)
gasLimit: this.computeExecutionGasLimitForNodesManagement(numNodes),
addDataMovementGas: true
}).build();
}

Expand All @@ -99,7 +101,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: this.computeExecutionGasLimitForNodesManagement(numNodes)
gasLimit: this.computeExecutionGasLimitForNodesManagement(numNodes),
addDataMovementGas: true
}).build();
}

Expand All @@ -125,7 +128,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: executionGasLimit
gasLimit: executionGasLimit,
addDataMovementGas: true
}).build();
}

Expand All @@ -151,7 +155,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: executionGasLimit
gasLimit: executionGasLimit,
addDataMovementGas: true
}).build();
}

Expand All @@ -177,7 +182,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: executionGasLimit
gasLimit: executionGasLimit,
addDataMovementGas: true
}).build();
}

Expand All @@ -199,7 +205,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: this.computeExecutionGasLimitForNodesManagement(numNodes)
gasLimit: this.computeExecutionGasLimitForNodesManagement(numNodes),
addDataMovementGas: true
}).build();
}

Expand All @@ -218,7 +225,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations)
gasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations),
addDataMovementGas: true
}).build();
}

Expand All @@ -237,7 +245,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations)
gasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations),
addDataMovementGas: true
}).build();
}

Expand All @@ -255,7 +264,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations)
gasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations),
addDataMovementGas: true
}).build();
}

Expand All @@ -273,7 +283,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations)
gasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations),
addDataMovementGas: true
}).build();
}

Expand All @@ -291,7 +302,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations)
gasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations),
addDataMovementGas: true
}).build();
}

Expand All @@ -309,7 +321,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations)
gasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations),
addDataMovementGas: true
}).build();
}

Expand All @@ -332,7 +345,8 @@ export class DelegationTransactionIntentsFactory {
sender: options.sender,
receiver: options.delegationContract,
dataParts: dataParts,
executionGasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations)
gasLimit: new BigNumber(this.config.gasLimitDelegationOperations).plus(this.config.additionalGasLimitForDelegationOperations),
addDataMovementGas: true
}).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ describe("test smart contract intents factory", function () {
assert.isDefined(deployIntent.data);
expect(deployIntent.data!.length).to.be.greaterThan(0);

const expectedGasLimit = 6000000 + 50000 + 1500 * deployIntent.data!.length;
assert.equal(deployIntent.gasLimit.valueOf(), expectedGasLimit);
assert.equal(deployIntent.gasLimit.valueOf(), gasLimit);
assert.equal(deployIntent.value, 0);

assert.deepEqual(deployIntent, abiDeployIntent);
Expand Down Expand Up @@ -102,7 +101,7 @@ describe("test smart contract intents factory", function () {
assert.isDefined(deployIntent.data);
assert.deepEqual(deployIntent.data, Buffer.from("add@07"));

assert.equal(deployIntent.gasLimit.valueOf(), 6059000);
assert.equal(deployIntent.gasLimit.valueOf(), gasLimit);
assert.equal(deployIntent.value, 0);

assert.deepEqual(deployIntent, abiDeployIntent);
Expand Down Expand Up @@ -135,8 +134,7 @@ describe("test smart contract intents factory", function () {
assert.isDefined(deployIntent.data);
assert.isTrue(Buffer.from(deployIntent.data!).toString().startsWith("upgradeContract@"));

const expectedGasLimit = 6000000 + 50000 + 1500 * deployIntent.data!.length;
assert.equal(deployIntent.gasLimit.valueOf(), expectedGasLimit);
assert.equal(deployIntent.gasLimit.valueOf(), gasLimit);
assert.equal(deployIntent.value, 0);

assert.deepEqual(deployIntent, abiDeployIntent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export class SmartContractTransactionIntentsFactory {
sender: options.sender,
receiver: Address.fromBech32(CONTRACT_DEPLOY_ADDRESS),
dataParts: parts,
executionGasLimit: options.gasLimit
gasLimit: options.gasLimit,
addDataMovementGas: false
}).build();
}

Expand All @@ -85,7 +86,8 @@ export class SmartContractTransactionIntentsFactory {
sender: options.sender,
receiver: options.contractAddress,
dataParts: parts,
executionGasLimit: options.gasLimit
gasLimit: options.gasLimit,
addDataMovementGas: false
}).build();
}

Expand Down Expand Up @@ -123,7 +125,8 @@ export class SmartContractTransactionIntentsFactory {
sender: options.sender,
receiver: options.contract,
dataParts: parts,
executionGasLimit: options.gasLimit
gasLimit: options.gasLimit,
addDataMovementGas: false
}).build();
}

Expand Down
Loading

0 comments on commit 8dcf4bd

Please sign in to comment.