Skip to content
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

Resend txn & Handle dropped txns #70 #72

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

bshevchenko
Copy link
Contributor

@bshevchenko bshevchenko commented Aug 28, 2019

Description

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code is formatted by rubocop.
  • If the external API is modified such the REST endpoints or GraphQL
    schema, do update the documentation via apipie or the schema itself.
  • I have added tests to cover my code and critical edge cases.
  • I have run all tests and passes via bin/rake test with high
    code coverage(at least 90%).
  • I have squashed my commit with a meaningful message before merging.
  • I have updated the documentation if needed and accordingly.
  • I have signed and submitted the Contributors License Agreement.
  • QA has tested and verified the PR.

@bshevchenko
Copy link
Contributor Author

#70

@bshevchenko bshevchenko marked this pull request as ready for review September 2, 2019 15:26
@bshevchenko
Copy link
Contributor Author

rubocop displays 1265 offenses from all over the project, so not sure what to do about it

@FrancisMurilloDigix
Copy link
Contributor

@bshevchenko Don't worry about the warnings. We are using rubocop as the formatter, not a linter.

@FrancisMurilloDigix
Copy link
Contributor

Can you run rubocop -a and only commit the files for this PR? In my editor, I usually have the files I touched autoformat with rubocop.

@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix done! Draft code for cron job is within the watching_transaction module (resend). Need your feedback on it. Job itself should be configured depending on the server environment, which I am not aware of.

Btw, as far as I am concerned, @roynalnaruto is supposed to be the reviewer for this PR, no?

@FrancisMurilloDigix
Copy link
Contributor

FrancisMurilloDigix commented Sep 4, 2019

@bshevchenko I am the main developer for the Rails application so I am also the reviewer. For the cron job, checkout scheduler.rb.

@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix all right, thank you! So shall I just put my code there under the "schedule.every '5m' do"?
Also what do you think on web3 initialization in the watching_transaction.rb? And on test coverage for resend method. I didn't test it yet, neither manually or automatically.

@FrancisMurilloDigix
Copy link
Contributor

@bshevchenko 5m is fine.

Was going to comment whether we can remove the web3 dependency and simply put it in ethereum_api.rb.

Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial set of comments.

app/models/watching_transaction.rb Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Show resolved Hide resolved
app/models/watching_transaction.rb Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix ran out of your comments. Please check new commits

Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comprehensive set of comments

app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/graphql/mutations/watch_transaction_mutation.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
app/graphql/resolvers/watched_transaction_resolver.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still reviewing the tests.

The group_id for rewatch might be incorrect or misunderstood so watch out for that. Gonna try to stay open for tomorrow if you have more questions.

app/graphql/resolvers/watched_transaction_resolver.rb Outdated Show resolved Hide resolved
app/graphql/resolvers/watched_transaction_resolver.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
test/graphql/resend_transaction_mutation_test.rb Outdated Show resolved Hide resolved
test/graphql/resend_transaction_mutation_test.rb Outdated Show resolved Hide resolved
test/factories/watching_transactions.rb Outdated Show resolved Hide resolved
test/graphql/resend_transaction_mutation_test.rb Outdated Show resolved Hide resolved
test/graphql/watch_transaction_mutation_test.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done.

app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/graphql/mutations/resend_transaction_mutation.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
test/graphql/resend_transaction_mutation_test.rb Outdated Show resolved Hide resolved
test/graphql/resend_transaction_mutation_test.rb Outdated Show resolved Hide resolved
@bshevchenko
Copy link
Contributor Author

bshevchenko commented Sep 9, 2019

So, as of now, I see 6 unresolved conversations that are related to:

  1. Tests for WatchingTransaction model (watch, resend, resend_transactions)
  2. Having transactionHash outside of the transactionObject argument

On 1 I'll soon provide new commits, but for 2 I need more feedback

Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 2, you are right about the receipt and txhash so we have to take the extra txhash field for watchTransaction.

@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix check out my latest commit please

@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix or even 3 latest commits. They include what was lacking. I hope that's all

Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there.

test/models/watching_transaction_test.rb Show resolved Hide resolved
test/models/watching_transaction_test.rb Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
app/models/watching_transaction.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix everything seems to be resolved to me

Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty pleased with this.

Just some enhancements on the test and one forgotten test on the WatchedTransaction

test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Show resolved Hide resolved
@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix check latests commits please

Copy link
Contributor

@FrancisMurilloDigix FrancisMurilloDigix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done. When you're done addressing this last touch up.

  • Do rubocop -a and commit the files again.
  • Do squash the commits


WatchingTransaction.resend_transactions

assert_requested(get_failed_stub, times: 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use size instead of 1 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supposed to be 1, because if API is unavailable then no more attempts will be made during current job

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is called for each transaction so it is n times instead of 1. You should try setting it to n and then n+1 to see the effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it breaks whole cycle. Tests are passing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed few new lines in watching_transaction.rb:
if ok_tx == :error
Rails.logger.info 'Failed to get transaction by hash. Killing job..'
break
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrancisMurilloDigix I'm not getting what you trying to say

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, got it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll anyway break on the next iteration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if API would be still unavailable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the next iteration fails and the reason is that the API is down or a network issue, then returning or breaking early is fine. Since error handling is not truly addressed, at least the consistency of behavior is the same when either request is down.

Yeah, so adding a break or return on a failed send_raw_transaction is good enough for now.

test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/models/watching_transaction_test.rb Outdated Show resolved Hide resolved
test/graphql/watched_transaction_query_test.rb Outdated Show resolved Hide resolved
@bshevchenko
Copy link
Contributor Author

Nicely done. When you're done addressing this last touch up.

  • Do rubocop -a and commit the files again.
  • Do squash the commits

All right, but I'm curious why you don't just use "Squash and merge" feature?

@bshevchenko
Copy link
Contributor Author

@FrancisMurilloDigix done

@FrancisMurilloDigix
Copy link
Contributor

Thanks for your hard work. Will merge after some advice from @tymat

Will add the remaining break and rubocop -a everything so the formatter just works hopefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants