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

WIP: Enshrined Revenue Sharing implementation #10320

Closed
wants to merge 16 commits into from

Conversation

geoknee
Copy link
Contributor

@geoknee geoknee commented Apr 26, 2024

Copy link
Contributor

semgrep-app bot commented Apr 26, 2024

Semgrep found 15 sol-style-notice-over-dev-natspec findings:

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

Semgrep found 13 sol-style-doc-comment findings:

Javadoc-style comments are not allowed. Use /// style doc comments instead.

Ignore this finding from sol-style-doc-comment.

Semgrep found 11 golang_fmt_errorf_no_params findings:

No fmt.Errorf invocations without fmt arguments allowed

Ignore this finding from golang_fmt_errorf_no_params.

Semgrep found 2 import-text-template findings:

  • op-bindings/bindgen/remote_handlers.go
  • op-bindings/bindgen/generator_local.go

When working with web applications that involve rendering user-generated content, it's important to properly escape any HTML content to prevent Cross-Site Scripting (XSS) attacks. In Go, the text/template package does not automatically escape HTML content, which can leave your application vulnerable to these types of attacks. To mitigate this risk, it's recommended to use the html/template package instead, which provides built-in functionality for HTML escaping. By using html/template to render your HTML content, you can help to ensure that your web application is more secure and less susceptible to XSS vulnerabilities.

Ignore this finding from import-text-template.

Semgrep found 1 dangerous-exec-command finding:

  • op-challenger/game/fault/trace/cannon/executor.go

Detected non-static command inside Command. Audit the input to 'exec.Command'. If unverified user data can reach this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary code.

Ignore this finding from dangerous-exec-command.

@tynes
Copy link
Contributor

tynes commented Apr 26, 2024

You should rebase on latest develop - its not necessary to do the bindings thing anymore, we use a forge script to create the L2 genesis, there are instructions here on how to run the command. I believe this is safe to add to the L2 genesis as part of the PR but we should make sure the specs are finalized before adding it to the L2 genesis generation since we don't have good releases of contracts yet :)

"RevenueSharer: FeeVault must withdraw to RevenueSharer contract"
);
uint256 initial_balance = address(this).balance;
FeeVault(_feeVault).withdraw(); // TODO do we need a reentrancy guard around this?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain this todo more?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The control flow is kinda jank for this system, def not your fault, its trying to build something on top that isn't really suited well for this usecase. It would be good to have a comment saying "withdraw calls back to this contract, sending its full balance of ether" or something like that so its more obvious the control flow

* the minimum withdrawal amount.
*/
function feeVaultWithdrawal(address payable _feeVault) internal returns (uint256) {
require(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be worth also calling to check that the withdrawal network is L2, otherwise the state machine can be fooled

Copy link
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know this is draft but i don't think we should merge it until we align more on the design :)

@geoknee
Copy link
Contributor Author

geoknee commented Apr 27, 2024

i know this is draft but i don't think we should merge it until we align more on the design :)

For sure. I also added WIP to the title, this is far from merging.

@geoknee geoknee force-pushed the gk/revenue-sharing2 branch from 94fe988 to f2530b5 Compare April 29, 2024 12:21
_beneficiary: cfg.revenueShareRecipient(),
_l1Wallet: cfg.revenueShareRemainderRecipient()
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be sure to call initialize on the implementation too, with null values

uint256 remainder = r - s;

// Send Beneficiary their revenue share on L2
if (!SafeCall.send(BENEFICIARY, gasleft(), s)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would like us to add a version of SafeCall that only takes 2 arguments so we don't need to pass gasleft. If you don't want to do it as part of this PR thats fine

@tynes
Copy link
Contributor

tynes commented Apr 29, 2024

This is great so far!

/**
* @dev Withdraws funds from FeeVaults, sends Optimism their revenue share, and withdraws remaining funds to L1.
*/
function execute() external virtual {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you added a mermaid diagram to the specs that showed the flow of calls, that would be amazing

@@ -110,6 +112,8 @@ contract DeployConfig is Script {
sequencerFeeVaultRecipient = stdJson.readAddress(_json, "$.sequencerFeeVaultRecipient");
sequencerFeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.sequencerFeeVaultMinimumWithdrawalAmount");
sequencerFeeVaultWithdrawalNetwork = stdJson.readUint(_json, "$.sequencerFeeVaultWithdrawalNetwork");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could add a useRevenueShare = _envOr(_json, ".useRevenueShare", true); that would be great then in the Genesis generation you can know to configure the fee vaults appropriately when its set to true. Will need to add a setter setUseRevenueShare to be able to not break legacy tests, you can see how this is done with plasma, you need to call it in the tests setUp before calling super.setUp

@@ -110,6 +112,8 @@ contract DeployConfig is Script {
sequencerFeeVaultRecipient = stdJson.readAddress(_json, "$.sequencerFeeVaultRecipient");
sequencerFeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.sequencerFeeVaultMinimumWithdrawalAmount");
sequencerFeeVaultWithdrawalNetwork = stdJson.readUint(_json, "$.sequencerFeeVaultWithdrawalNetwork");
revenueShareRecipient = payable(stdJson.readAddress(_json, "$.revenueShareRecipient"));
revenueShareRemainderRecipient = payable(stdJson.readAddress(_json, "$.revenueShareRemainderRecipient"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use _envOr with null fallback values? This prevents breaking config and also makes it so that the null values are set when the revenue share is turned off

Copy link
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label May 14, 2024
@geoknee geoknee removed the Stale label May 14, 2024
Copy link
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label May 29, 2024
@github-actions github-actions bot closed this Jun 4, 2024
@geoknee geoknee deleted the gk/revenue-sharing2 branch October 23, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants