stellar / rs-soroban-env

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

Tightening up metering in auth #1340

Closed jayz22 closed 6 months ago

jayz22 commented 6 months ago

What

Fix a few small but protocol-breaking metering issues discovered by the security review: i. auth entry charging the wrong amount https://github.com/stellar/rs-soroban-env/issues/1297 ii. (not protocol breaking) auth snapshot() function charge after allocation iii. auth manager not charging RefCell wrapping.

I also did a clean up by wrapping the with_capacity method with metering into a new MeteredContainer::with_metered_capacity method, which makes sure bugs like (i) and (ii) above cannot happen.

Unfortunately these breaks a lot of existing observations that depends on auth, basically all mem_bytes have increased by 8 (size of the RefCell counter) and cpu_insns have increased by 2, which is caused by fixing (iii).

Why

[TODO: Why this change is being made. Include any context required to understand the why.]

Known limitations

[TODO or N/A]