Skip to main content
Zondax Github LinkZondax Github Link
Theme SwitchTheme Switch

Benchmarks

Milestone 1

This benchmark compares gas used for CBOR serialization written in solidity with other calls like a simple transfer of FIL or a ERC20 transfer call written using AssemblyScript SDK developed by Zondax.

Benchmarks

The complete delivery plan can be found here.

This benchmark shows the progression in the initial FEVM implementation.

|------------------------------------|----------------------|
| Call | Gas used |
|------------------------------------|----------------------|
| serializeAddSigner (CBOR contract) | 107,072,567 |
| serializeAddress (CBOR contract) | 82,175,116 |
| serializeBool (CBOR contract) | 14,151,467 |
| getBalance (SimpleCoin contract) | 9,321,353 |
| ERC20 send (assemblyscript native) | 697,452 |
| Simple send (native) | 413,868 |
|------------------------------------|----------------------|

This benchmark shows the progression after FEVM optimizations.

|------------------------------------|----------------------|
| Call | Gas used |
|------------------------------------|----------------------|
| serializeAddSigner (CBOR contract) | 13,922,379 |
| serializeAddress (CBOR contract) | 11,341,547 |
| serializeBool (CBOR contract) | 3,719,855 |
| getBalance (SimpleCoin contract) | 3,356,533 |
|------------------------------------|----------------------|

This benchmark shows the progression after FEVM optimizations.

|------------------------------------|----------------------|
| Call | Gas used |
|------------------------------------|----------------------|
| serializeAddSigner (CBOR contract) | 14,602,887 |
| serializeAddress (CBOR contract) | 11,930,295 |
| serializeBool (CBOR contract) | 4,042,787 |
| getBalance (SimpleCoin contract) | 3,665,937 |
|------------------------------------|----------------------|

Milestone 2

This benchmark shows the progression after FEVM optimizations.

| ------------------------------------ |----------------------|
| Call | Gas used |
|--------------------------------------|----------------------|
| serializeAddSigner (CBOR contract) | 14,602,887 |
| serializeAddress (CBOR contract) | 11,930,295 |
| serializeBool (CBOR contract) | 4,042,787 |
| getBalance (SimpleCoin contract) | 3,665,937 |
| ------------------------------------ |----------------------|

This benchmark compares gas used for CBOR serialization using precompiled contracts with other calls like a simple transfer of FIL or a ERC20 transfer call written using AssemblyScript SDK developed by Zondax. It also includes Milestone 1 benchmark result.

Benchmarks

These values were generated by running the smart contracts on the integration suite written in rust by Filecoin. The current version used can be found here 🔗.

|---------------------------------------------------|----------------------|
| Call | Gas used |
|---------------------------------------------------|----------------------|
| serializeAddSigner (CBOR contract) | 14,602,887 |
| serializeAddress (CBOR contract) | 11,930,295 |
| ERC20 token transfer (EVM contract) | 6,469,792 |
| serializeBool (CBOR contract) | 4,042,787 |
| empty call (precompiled contract) | 2,474,315 |
| sha256 (precompiled contract) | 2,171,066 |
| cborBoolean (precompiled contract) | 2,507,039 |
| cborAddress (precompiled contract) | 2,059,723 |
| cborAddSigner (precompiled contract) | 2,670,929 |
| ERC20-like token transfer (assemblyscript native) | 697,452 |
| Simple send (native) | 413,868 |
| --------------------------------------------------|----------------------|

When serializing in a precompiled contract we are using less gas than when serializing inside a Solidity contract. However, the gas usage is still significant. The use of the opcode STATICCALL seems to cost the most and the rest seem to be memory.

Notes

  • The ERC20-like token smart contract was written using AssemblyScript SDK. It can be found here 🔗
  • The empty call could be use as the baseline, as it just call a precompiled actor that does nothing. This should be the less expensive call.
  • The "simple send" is a FIL token transfer.