TheAlgorithms / Solidity

Algorithms and data structures implemented in Solidity
GNU Lesser General Public License v2.1
326 stars 88 forks source link

Math #3

Closed wenceslas-sanchez closed 2 years ago

wenceslas-sanchez commented 2 years ago

Fibonacci first implementation.

TODO:

wenceslas-sanchez commented 2 years ago

I don't know if you want to implement CI. For the moment the project directory is like :

|__Math
|  |__fibonacci
|  |  |__fibonacci.sol
|  |  |__testFibonacci.sol

and test files can be executed if you copy/paste the folder fibonacci into RemixIDE for instance.

Panquesito7 commented 2 years ago

I don't know if you want to implement CI. For the moment the project directory is like :

|__Math
|  |__fibonacci
|  |  |__fibonacci.sol
|  |  |__testFibonacci.sol

and test files can be executed if you copy/paste the folder fibonacci into RemixIDE for instance.

CI would be great, thanks! Let us know if you need any help! :D

wenceslas-sanchez commented 2 years ago

I tried to setup CI process for this project but I didn't find a good way to do it :

Maybe you know someone more experimented in Solidity to manage this issue ?

Panquesito7 commented 2 years ago

I tried to setup CI process for this project but I didn't find a good way to do it :

  • if we develop test in Solidity, we should have issues with gas consuption with the number of tests.
  • if we develop them in Javascript, it doesn't match TheAlgorithm philosophy (testing with the same language we wrote code, right ?).

Maybe you know someone more experimented in Solidity to manage this issue ?

We can use another language if needed. 😃 Otherwise, CC: @mkubdev, @KukretiShubham.

KukretiShubham commented 2 years ago

For solidity either we can develop a standard test javascript file or use remix

wenceslas-sanchez commented 2 years ago

For solidity either we can develop a standard test javascript file or use remix

OK go for javascript if you are good with that ! 😄 But, the issue of gas consumption is the same with Solidity or Javascript, isn't it ?

KukretiShubham commented 2 years ago

For solidity either we can develop a standard test javascript file or use remix

OK go for javascript if you are good with that ! smile But, the issue of gas consumption is the same with Solidity or Javascript, isn't it ?

Why do we need to test them on a mainnet? Testnet doesn't cost real money. And testing does not necessary should be done on the network. It can be done using chai or mocha.

wenceslas-sanchez commented 2 years ago

For solidity either we can develop a standard test javascript file or use remix

OK go for javascript if you are good with that ! smile But, the issue of gas consumption is the same with Solidity or Javascript, isn't it ?

Why do we need to test them on a mainnet? Testnet doesn't cost real money. And testing does not necessary should be done on the network. It can be done using chai or mocha.

The issue is that some algorithms version (for instance Fibonnaci) are really are very expansive. If we add many of those expansive execution, we won't be able to run all tests because there is gas cap, isn't it ? The issue is more about scalability than cost in itself.

KukretiShubham commented 2 years ago

For solidity either we can develop a standard test javascript file or use remix

OK go for javascript if you are good with that ! smile But, the issue of gas consumption is the same with Solidity or Javascript, isn't it ?

Why do we need to test them on a mainnet? Testnet doesn't cost real money. And testing does not necessary should be done on the network. It can be done using chai or mocha.

The issue is that some algorithms version (for instance Fibonnaci) are really are very expansive. If we add many of those expansive execution, we won't be able to run all tests because there is gas cap, isn't it ? The issue is more about scalability than cost in itself.

Yeah, we can't do every computation on-chain. Such complex computations should be off-chain. And we should discourage the practice of using unnecessary computation on onchain. If that's your point. I agree.