Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: calculating incentive #17

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions solidity/contracts/VerifierModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ contract VerifierModule is IVerifierModule {
bytes memory _storageMirrorStorageProof,
SafeTxnParams calldata _arbitraryTxnParams
) internal {
uint256 _startingGas = gasleft();
bytes32 _hashedProposedSettings = _verifyNewSettings(_safe, _proposedSettings, _storageMirrorStorageProof);

// If we dont revert from the _verifyNewSettings() call, then we can update the safe
Expand All @@ -134,15 +135,24 @@ contract VerifierModule is IVerifierModule {
_arbitraryTxnParams.signatures
);

// Pay incentives
// TODO: Calculations for incentives so its not hardcoded to 1e18
ISafe(_safe).execTransactionFromModule(msg.sender, 1e18, '', Enum.Operation.Call);

// Make the storage updates at the end of the call to save gas in a revert scenario
latestVerifiedSettings[_safe] = _hashedProposedSettings;
latestVerifiedSettingsTimestamp[_safe] = block.timestamp;

emit VerifiedUpdate(_safe, _hashedProposedSettings);

// NOTE: This is not the exact gas spent as we still have to make the transaction after the calculation
// NOTE: We do all this at the end of the call to get the most accurate gas calculations

uint256 _gasLeft = gasleft();

uint256 _gasSpent = _startingGas - _gasLeft;

// Gas spent plus 10% incentive
uint256 _incentive = _gasSpent + _gasSpent * 10 / 100;

// Pay incentives
ISafe(_safe).execTransactionFromModule(msg.sender, _incentive, '', Enum.Operation.Call);
}

/**
Expand Down