XiPingTing

joined 10 months ago
 

I have some mathematical algorithm I have reason to run as an on-chain function in a smart contract. After unrolling for-loops I'm looking at I'm guessing 10000 lines of code where each line is doing simple arithmetic (adding or multiplying floating point numbers in small arrays).

I know for a fact the function can be computed 3000-5000 times per second on a 2.3 GHz Intel i5, when written in C depending on parameter tweaks.

Before writing the code my 'gut feel' is I'm looking at 1,000,000 gas for something like this, based on some simple hardhat tests with large for-loops.

Running this on a main chain looks like a joke, but running this on Polygon or some kind of roll-up looks like it might not be ridiculously expensive?

I estimate users will need to call the function/transaction maybe 5 or 10 times total. I also estimate that the on-chain data will be around 5 kilobytes per transaction (or 2kb with on-chain decompression). The majority of participants to the smart contract would likely be willing to spend $120 total on those 5 or 10 transactions but $10000 might not be out of the question for certain corporate use-cases.

Ballpark, does this sound like it adds up or have I vastly underestimated the cost of gas or on-chain data?

 

I have some mathematical algorithm I have reason to run as an on-chain function in a smart contract. After unrolling for-loops I'm looking at I'm guessing 10000 lines of code where each line is doing simple arithmetic (adding or multiplying floating point numbers in small arrays).

I know for a fact the function can be computed 3000-5000 times per second on a 2.3 GHz Intel i5, when written in C depending on parameter tweaks.

Before writing the code my 'gut feel' is I'm looking at 1,000,000 gas for something like this, based on some simple hardhat tests with large for-loops.

Running this on a main chain looks like a joke, but running this on Polygon or some kind of roll-up looks like it might not be ridiculously expensive?

I estimate users will need to call the function/transaction maybe 5 or 10 times total. I also estimate that the on-chain data will be around 5 kilobytes per transaction (or 2kb with on-chain decompression). The majority of participants to the smart contract would likely be willing to spend $120 total on those 5 or 10 transactions but $10000 might not be out of the question for certain corporate use-cases.

Ballpark, does this sound like it adds up or have I vastly underestimated the cost of gas or on-chain data?

 

When a miner receives a block, it needs to check transaction signatures as part of verifying the block. Looking at the call hierarchy for crypto.SigToPub it’s not clear where an incoming block’s signatures are verified. Can anyone point me to the relevant code in Go-Ethereum?

 

My understanding is that you can optionally include data in a transaction which isn’t hashed into a block. Does this data get preserved forever?

 

Verifying a block you need to check each transaction’s signature. Once a block has been accepted by a network and has a couple verified children blocks, those signatures are redundant. Does ethereum discard signatures or preserve them indefinitely?