darwinia-network / darwinia-messages-sol

Darwinia cross-chain messages gateway and protocol for EVM developers 💌
MIT License
29 stars 8 forks source link

Decrease message calldata limit from 4096 to 2048 #146

Closed hujw77 closed 2 years ago

hujw77 commented 2 years ago

Decrease meesage calldata limit from 4096 to 2048

Fix #145 After this pr.

Malicous app

One message benchmark, 247033 gas used (includes 10w dispatch call).

yarn test test/test_malicous_send_message_single.js
·----------------------------------------------------|---------------------------|----------------|-----------------------------·
|                Solc version: 0.8.11                ·  Optimizer enabled: true  ·  Runs: 999999  ·  Block limit: 12450000 gas  │
·····················································|···························|················|······························
|  Methods                                                                                                                      │
·················|···································|·············|·············|················|···············|··············
|  Contract      ·  Method                           ·  Min        ·  Max        ·  Avg           ·  # calls      ·  eur (avg)  │
·················|···································|·············|·············|················|···············|··············
|  InboundLane   ·  receive_messages_proof           ·          -  ·          -  ·        247033  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  MalicousApp   ·  malicious                        ·          -  ·          -  ·        482744  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  OutboundLane  ·  receive_messages_delivery_proof  ·          -  ·          -  ·        160030  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············

30 messages benchmark, 4989490 gas used, ~ 166,316 gas per message.

yarn test test/test_malicous_send_message.js
·----------------------------------------------------|---------------------------|----------------|-----------------------------·
|                Solc version: 0.8.11                ·  Optimizer enabled: true  ·  Runs: 999999  ·  Block limit: 12450000 gas  │
·····················································|···························|················|······························
|  Methods                                                                                                                      │
·················|···································|·············|·············|················|···············|··············
|  Contract      ·  Method                           ·  Min        ·  Max        ·  Avg           ·  # calls      ·  eur (avg)  │
·················|···································|·············|·············|················|···············|··············
|  InboundLane   ·  receive_messages_proof           ·          -  ·          -  ·       4989490  ·           31  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  MalicousApp   ·  malicious                        ·     431444  ·     482744  ·        433154  ·           60  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  OutboundLane  ·  receive_messages_delivery_proof  ·          -  ·          -  ·       2506192  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············

Normal app.

One message benchmark, 121201 gas used.

yarn test test/test_normal_send_message_single.js
·----------------------------------------------------|---------------------------|----------------|-----------------------------·
|                Solc version: 0.8.11                ·  Optimizer enabled: true  ·  Runs: 999999  ·  Block limit: 12450000 gas  │
·····················································|···························|················|······························
|  Methods                                                                                                                      │
·················|···································|·············|·············|················|···············|··············
|  Contract      ·  Method                           ·  Min        ·  Max        ·  Avg           ·  # calls      ·  eur (avg)  │
·················|···································|·············|·············|················|···············|··············
|  InboundLane   ·  receive_messages_proof           ·          -  ·          -  ·        121201  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  OutboundLane  ·  receive_messages_delivery_proof  ·          -  ·          -  ·        110036  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  OutboundLane  ·  send_message                     ·          -  ·          -  ·        412714  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············

30 messages benchmark, 1773129 gas used, ~ 59,104 gas per message.

·----------------------------------------------------|---------------------------|----------------|-----------------------------·
|                Solc version: 0.8.11                ·  Optimizer enabled: true  ·  Runs: 999999  ·  Block limit: 12450000 gas  │
·····················································|···························|················|······························
|  Methods                                                                                                                      │
·················|···································|·············|·············|················|···············|··············
|  Contract      ·  Method                           ·  Min        ·  Max        ·  Avg           ·  # calls      ·  eur (avg)  │
·················|···································|·············|·············|················|···············|··············
|  InboundLane   ·  receive_messages_proof           ·      35998  ·    1829165  ·       1773129  ·           32  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  OutboundLane  ·  receive_messages_delivery_proof  ·          -  ·          -  ·        995236  ·            2  ·          -  │
·················|···································|·············|·············|················|···············|··············
|  OutboundLane  ·  send_message                     ·     390350  ·     441650  ·        392060  ·           60  ·          -  │
·················|···································|·············|·············|················|···············|··············