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

[ETHEREUM-CONTRACTS] TrustedMacros: A TrustedForwarder that rules them all #1782

Closed
2 of 8 tasks
hellwolf opened this issue Jan 18, 2024 · 4 comments · Fixed by #1786 or #2025
Closed
2 of 8 tasks

[ETHEREUM-CONTRACTS] TrustedMacros: A TrustedForwarder that rules them all #1782

hellwolf opened this issue Jan 18, 2024 · 4 comments · Fixed by #1786 or #2025
Assignees
Labels
Epic Issues container Project: PROTOCOL-EVMv1 Superfluid protocol EVM v1 implementation in Solidity Type: Enhancement New feature or request

Comments

@hellwolf
Copy link
Contributor

hellwolf commented Jan 18, 2024

Overview

What?

This is a trusted forwarder with high degree of extensibility through permission-less and user-defined "macro contracts", where:

  • Macro contracts encapsulates a high level ABI call wrapper, which compresses call data as a result.
    • Benefit: it is good for L2 where calldata size matters when it comes to transaction cost.
  • Additionally, it makes it a much easier and consistent interface for integrating eip-712.
    *Benefit: the transaction is more readable than otherwise still having to users to read less legible eip-712 transaction with naive eip-712 integration.

An example user-defined macro request using eip-712:

image

How?

  1. Upon requested by the TrustedMacro contract, a user-defined macro should return a array of Superfluid batch operations, which will be send to trustedForwardBatchCall by the TrustedMacro.
  2. A user-defined macro is stateless but still can query other external contracts, which eliminates a class of security issues without compromising extensibility completely.

[missing image]

Why?

  • Allow apps to compress calldata for L2s (!), without having to register a bespoke trusted forwarder.
  • Allow uniformed out-of-box integration of eip-712 legible signature!

Deadline:

  • Prototype ready: soon.
  • Integration to an application: end of Jan.

Technical Design Document (TDD):

Acceptance criteria

  • Prototype demoed
  • Test-integration with an live app
  • Satisfies entire acceptance criteria
  • Is the appetite for the spike exhausted?
  • Documentation updated
  • Presentation to stakeholders
  • Output is a TDD
  • Recommendation on next steps

Links/Resources

@hellwolf hellwolf added Project: PROTOCOL-EVMv1 Superfluid protocol EVM v1 implementation in Solidity Type: Enhancement New feature or request labels Jan 18, 2024
@hellwolf hellwolf self-assigned this Jan 18, 2024
@hellwolf hellwolf changed the title [ETHEREUM-CONTRACTS] TrustedMacro: A TrustedForwarder that rules them all [ETHEREUM-CONTRACTS] TrustedMacros: A TrustedForwarder that rules them all Jan 18, 2024
@hellwolf
Copy link
Contributor Author

An example user-defined macro request using eip-712:

image

@hellwolf
Copy link
Contributor Author

hellwolf commented Jan 18, 2024

Work in progress: #1786

contract TokenBatchStreamerMacro is IUserDefinedMacro {
    function executeMacro(ISuperfluid host, bytes memory params) external view
        returns (ISuperfluid.Operation[] memory operations)
    {
        IConstantFlowAgreementV1 cfa = IConstantFlowAgreementV1(address(host.getAgreementClass(
            keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1")
        )));
        (ISuperToken token, int96 flowRate, address[] memory recipients) =
            abi.decode(params, (ISuperToken, int96, address[]));
        operations = new ISuperfluid.Operation[](recipients.length);
        // Build batch call operations here
        for (uint i = 0; i < recipients.length; ++i) {
            bytes memory callData = abi.encodeCall(cfa.createFlow,
                                                   (token,
                                                    recipients[i],
                                                    flowRate,
                                                    new bytes(0) // placeholder
                                                   ));
            operations[i] = ISuperfluid.Operation({
                operationType : BatchOperation.OPERATION_TYPE_SUPERFLUID_CALL_AGREEMENT, // type
                target: address(cfa),
                data: abi.encode(callData, new bytes(0))
                });
        }
    }

    function hash712Params(bytes memory params) external view returns (bytes32 hash) {
        (ISuperToken token, int96 flowRate, address[] memory recipients) =
            abi.decode(params, (ISuperToken, int96, address[]));
    }
}

@hellwolf hellwolf linked a pull request Jan 22, 2024 that will close this issue
@hellwolf hellwolf linked a pull request Jan 22, 2024 that will close this issue
@hellwolf hellwolf added the Team: Protocol Protocol Core, Sentinel, Peripherals, Protocol Infrastructure Tools & DevOps label Jan 23, 2024
@hellwolf
Copy link
Contributor Author

hellwolf commented Jan 24, 2024

Scroll transaction breakdown.

Reference: https://docs.scroll.io/en/developers/guides/estimating-gas-and-tx-fees/

Example:

https://scrollscan.com/tx/0xbcf040cf21c27a1cb3b3ee158ee5fd48d6444d139f8aa5898d74f4bedad7029f

Value: 0 ETH ($0.00)
Total Tx Fee: 0.000220640420055117 ETH ($0.49)
Gas Price: 0.0000000006 ETH (0.6 Gwei)
Gas Limit & Usage by Txn: 700,000 | 242,946 (34.71%)
L1 Data Fee 0.000074872820055117 ETH ($0.17)
Execution Fee 0.0001457676 ETH ($0.33)

In this case, the L2 execution fee is still a large portion (60%) of the transaction fee.

Optimism/Arbitrum

They still have significantly lower L2 execution fee.

In case of optimism, it's in tune of Mwei.

While in case of Arbitru, L1+L2 gas fees are mixed together in reporting. It sometimes ends up being 0.1 Gwei.

@hellwolf
Copy link
Contributor Author

A blurb:

For future reference:

A new builder's tool by Superfluid: Macros.
"Build it in solidity, ship it with ethersca-as-ui or generative-macro-UI (coming soon...)."
From #nocode to #onlysoliditycode .
Benefits:
build less, ship more
gas savings on rollup-centric L2s
readable multi-lingual ERC712 signatures
gasless transactions for end users with ERC712 signatures

@hellwolf hellwolf added Epic Issues container and removed Epic Issues container Team: Protocol Protocol Core, Sentinel, Peripherals, Protocol Infrastructure Tools & DevOps labels Mar 11, 2024
@hellwolf hellwolf linked a pull request Oct 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Issues container Project: PROTOCOL-EVMv1 Superfluid protocol EVM v1 implementation in Solidity Type: Enhancement New feature or request
Projects
None yet
1 participant