stellar / rs-soroban-env

Rust environment for Soroban contracts.
Apache License 2.0
59 stars 40 forks source link

Host function protocol gating #1348

Closed jayz22 closed 5 months ago

jayz22 commented 5 months ago

What

Allow host functions to specify its supported protocol bounds, e.g.

        {
            "name": "test",
            "export": "t",
            "functions": [
                {
                    "export": "_",
                    "name": "dummy0",
                    "args": [],
                    "return": "Val",
                    "docs": "A dummy function taking 0 arguments and performs no-op.                
+                  "min_supported_protocol": 20,
+                   "max_supported_protocol": 21
                }                
            ]
        },

And adds logic (mostly macro generated) that automatically checks and enforces these protocol bounds in various paths:

Tests are added in tests/protocol_gate.rs.

For more context, visit the design doc