passportxyz / passport

Passport allows users to prove their identity through a secure, decentralized UI
Other
954 stars 450 forks source link

Arbitrum Gas Estimation #1310

Open michaelgreen06 opened 1 year ago

michaelgreen06 commented 1 year ago

Estimate the costs of bringing stamps on chain using arbitrum one.

michaelgreen06 commented 1 year ago

I have looked into this using this resource provided by Arbitrum

@schultztimothy set up arbitrum's gas-estimation script from their SDK which gives estimations of gas cost based on current conditions.

The issue is, we have calculated all previous on chain stamp costs at a 64GWEI gas price on the L1. Even if the current L1 gas price were 64GWEI when running the gas-estimation script, the calculated transaction cost would vary due to the way arbitrum calculates L1 fees. They basically have an account w/ a rolling balance (sometimes it is negative & sometimes it is positive) to pay L1 fees. As a result of this rolling balance sometimes the L1 gas that arbitrum charges can differ at the same L1 gas cost.

Taking all of this into account I got various values from the gas-estimation script and manually calculated the price of bringing stamps on chain by tripling the current estimation of L1 gas costs (at a price of 30GWEI on L1) provided by the gas-estimation script. I feel safe w/ this conservative approach to estimating the gas costs as the closest way to compare "apples to apples" w/ our previous calculations.

1 Stamp: 0.0007551375 Eth ($1.402) 2 Stamps: 0.0009148124 Eth ($1.699) 3 Stamps: 0.0010751439 Eth ($2.0) 10 Stamps: 0.0021958929 Eth ($4.07)

*price of $1,857/eth used to calc USD cost of transactions

michaelgreen06 commented 1 year ago

I've done some comparing of txn fees from transactions I've found on Arbiscan to txn fee estimations that come from the gas-estimation script.

Sometimes the txn fee from the estimation script matches very closely to the transaction fee that shows up on arbiscan. Sometimes the 2 fees are up to 100% different. EG 0.0000841258 eth (estimation) vs 0.000167 (arbiscan)

Just want to call out that if we care about getting truly accurate data for transaction costs our best bet is to deploy these contracts to arbitrum and do some testing.