-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/automatic gas 1559 #547
Feature/automatic gas 1559 #547
Conversation
… implement the new gas parameters, and take transaction type into account fixes #546 by preserving the transaction type across the transaction rewrite
Strange, not sure why the tests are failing here, they pass when I run it on my system |
I can't confirm that. Coz when i ran first of failed tests in ci pipeline The reason of crashing is clear: it runs I suggest you to add some checks that there's at least that much blocks in blockchain when you've creating Meanwhile i'll add check in I'm not sure how tests will be going after that, but at least there'll be no crash on it. |
Oh... yeah that could be. I tend to have my Ganache always running in the background, so it would have a fair amount of history. Instead of returning nil if the chain block number is too low, maybe return based on all the blocks available. Reality is this is an edge case that only happens in testing. ie, if there are only 5 blocks on chain, return the result based on those 5 blocks, even if We don't easily have control over the number of blocks that may be present on the Ganache chain. So we can't really count on previous tests having been run to generate a certain amount of traffic. (tests are run in parallel,and possibly in random order) |
Ganache starts locally from scratch on every tests run. So it's always empty. I still wonder why tests have been green from the start in this setup, but it is what it is. So i've checked my hypothesis and when i've update method check it stop crushing in that case, but test becomes red. All of them i guess and there's pretty much there. So now we're having some wired situation when seems that we have some not quite reliable localTests. Actualy i don't know what to do yet. Actually this thing happening since method that we testing in Also i'm thinking that we shouldn't update any of our code to cover this situation (when our lib runs on empty blockchain) since it's almost unbelievable in real life usecases. So i guess we should do something with tests, but i wonder what?
Any ideas [what to do with write in blockchain tests]? |
It was okay before, because it wasn't using Oracle, and thus did not need historical blocks to return a result. It simply used the I agree we should not be modifying the main code to handle this odd case which should happen in testing only. The solution here is to add a class (not instance) |
We're facing not swift problem, but blockchain problem here. Like it's even possible to save ganache blockchain state through the ci/cd runs, but the problem is that we're needed to generate enough transactions for 21 blocks at least and consider different situations. And this is the place where i've gave up. If you have an tool to generate such number of diverse transactions for ganache i'll could setup ganache for ci/cd pipeline easily |
Yes, but it's a problem we can solve in Swift. By creating a We can easily generate any number if transactions in a loop to initialize Ganache, and it is pretty easy to bypass the code that is causing us problems. Either by writing raw transactions, or by creating transactions with manual settings for the gas parameters (we only fail when we have to resolve Having the |
Ok I've added a pre-loader This thread discusses some better options for running one-time setup, which we should explore for a future PR / improvement |
…of `XCTestCase` so they automatically inherit the default initialization code for ganache Some light lint cleanup
Refactored the tests a bit, so they automatically inherit the setUp, slightly less ugly now. |
I'm disagree with that, i think that
So i suggest to use your code to one-time generate some persistent state and save it within test folder and make ganache to initiate itself according to that state in ci/cd config. This made possible to user to look ci/cd path when they wants to run tests locally and reproduce it themselves, since it would be still single line of code with path where to read, not some massive yml config. |
And how does this work when someone is developing within XCode? using Having said that, I will reverse out my changes to the tests here, this will cause it to fail again. I will submit a new PR with a new test group that can be used to prime Ganache with the blocks. The new PR will need to be applied, and your changes to the ci/cd will need to be made before this one will pass tests. |
Okay, I've reverted here, and added the generator in PR #549. Now all we need is for ci/cd to be updated so this one can pass the tests again.
I don't think it needs to be persistent, it just needs to be consistent. And what I had before would have satisfied that, as on each run of the tests, Ganache would start at 0, and then the code would add exactly the same 25 blocks to the chain before proceeding with testing, creating the exact same environment for each test session.
This is neither a Swift problem, or a blockchain problem... this is a testing problem. There is nothing wrong with having some code to create a suitable environment for your testing to proceed. In fact it's pretty uncommon not to have some sort of code to initialize/create that environment. Sometimes it's per test, sometimes it's per session. |
This actually don't works here either. Like every user have to run ganache manually (my thought is by cli) to make any local tests pass.
My assumptions is follow:
This is (passing argument to ganache) is not that simple as just run ganache without any arguments, but it seems that both this case will made new contributor struggle.
I'm thinking that we should not move any additional setup of CI/CD pipeline into Xcode project rather SPM (seems it'll be possible starting from Swift 5.7). I'm seeing this picture:
|
Can you clarify what you mean by "don't work". If I start Ganache, from the Ganache UI (not from command line) do a "Ethereum Quickstart" And then I can run the tests
Many, including myself, run Ganache via the GUI app (not via npm), as it provides a nice interface for inspecting the state of the blockchain. Short of having an extensive testing document that details how it needs to be done, which we don't have, we cannot make assumptions on how people will try to test. Assuming the user is using XCode, the natural inclination will be to do the |
Well it's not the same. As you mentioned above
Yep, if we were able to setup consistent environment per session i would be agree that approach, but as i said in the point above — there's lack of tools to setup environment per [testing] session, not to mention SPM which is providing very limited tool set yet. |
No, because the code as it was written would only create blocks if there were less than 25 blocks on the test chain. So once it ran once, it would early exit on any other calls, and not add more blocks. If it did run, it would only create up to 25 blocks... meaning that if the block count was 0 - it would add 25, if the block count was 5 - it would add 20. |
This is exact proposed pipeline for manual testing, just reading your that message i haven't found mention about ganache run even if it GUI or CLI, so i agreed with this extended pipeline for manual testing that you provided here.
I'm agreed that users who uses GUI ganache version will met additional obstacles by this way. And, actually, i'm blaming early stage Ethereum infrastructure for that, but, sorry, that's offtopic, it's just hurts. So despite that, i'm seeing that we're choosing by two options:
As for me at this exact PR i'm about to choose latter, since complex things, mostly like lack of SPM automation tooling, XCTests constrains. |
Oh, I've missed that, this makes it one per session. |
So how do we proceed? should I update my other PR to be basically what I had here, were it does a "once per session" run automatically, and only runs if the block count is < 25? You can integrate that one, and hen this one will pass the tests as the infrastructure will be in place then. |
Let's restore it here. |
This reverts commit 84c9885.
This PR enables handling of
.automatic
for the new gas parameters on an EIP-1559 transaction.The existing handler was refactored to use the new
Oracle
for gas pricingThis PR also fixes #546 by preserving transaction type in the transaction rewrite