stakeordie / scrt-auction

2 stars 9 forks source link

A few functions defaulting to 1m gas when a lot less is enough #43

Closed baedrik closed 3 years ago

baedrik commented 3 years ago

The increase allowance function defaults to using 1m gas. It costs under 110k, probably play it safe and pad that to 150k to give a little leeway for people writing their own token contracts that might be less efficient (or do more processing) than the reference implementation

The create auction tx defaults to 1m. It costs around 600k. Probably give this one an extra buffer and set it to 700k, since we do not really know how many active auctions there will be at one time.

create viewing key function defaults to 1m gas, but costs under 110k. 120k should be safe here.

baedrik commented 3 years ago

Also change minimum bid defaults to 400k gas. 190k should be good here

baedrik commented 3 years ago

Closing an auction may require more gas once we get a feel for how many people find themselves running out. Because SNIP20s don't have a batch send function, it has to call Transfer for every bid, which adds close to 100k gas for each function call. Since the number of bids will vary greatly, so will the gas cost.

cankisagun commented 3 years ago

@baedrik do you have a list of which function requires approx. what amount of gas? It would be easier to pass @the-dusky a list. Tagging this as medium priority given low gas prices at the moment

baedrik commented 3 years ago

@the-dusky increase_allowance 150k create_auction 700k change_minimum_bid 190k create_viewing_key 120k bidding 400k retract_bid 330k finalize will vary greatly with the number of bids. I would probably start with 2m which would cover 16 or 17 bids

Those numbers already include some padding, but if you wanted to round those numbers up to the nearest 50k, it couldn't hurt

the-dusky commented 3 years ago

Currently Matches Baedrik's suggestion.