Skip to content

Redundant gas charges from Has -> Get access pattern #26448

@meetrick

Description

@meetrick

cachekv.GStore.Has currently calls Get internally on cache misses.

As a result, code paths using Has followed by Get pay gas for both operations even though only a single lookup is needed.

Current examples

  • x/bank/keeper/send.go:getSendEnabled
  • x/upgrade/keeper/keeper.go:getProtocolVersion

In particular, getSendEnabled is part of the SendCoins hot path and adds unnecessary gas cost per denom checked.

Possible improvement

  • make cachekv.Has use parent.Has instead of parent.Get
  • replace Has + Get patterns with a single Get where possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions