-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix: refactored tx submit checker initialisation #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort imports, please:
goimports -local github.com/neutron-org -w .
# Conflicts: # cmd/neutron_query_relayer/main.go # internal/app/app.go
func (tc *TxSubmitChecker) Run(ctx context.Context) error { | ||
// we don't want to start jobs before we read all pending txs from database, | ||
// hence we block on this read operation right in the beginning | ||
func (tc *TxSubmitChecker) Run(ctx context.Context, submittedTxsTasksQueue <-chan relay.PendingSubmittedTxInfo) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is good idea to move submittedTxsTasksQueue
into Run(), cause we kinda give idea that you can use this function with multiple queues on the same object. But you're not, cause it is tied to concrete storage
that is in TxSubmitChecker struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what your point here is; you can, for example, run multiple instances of TxSubmitChecker
in separate goroutines to enable parallel processing of pending txs
cmd/neutron_query_relayer/main.go
Outdated
logger.Fatal("Failed to create NewDefaultStorage", zap.Error(err)) | ||
} | ||
defer func(storage relay.Storage) { | ||
if cfg.AllowTxQueries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now I reailse that this suggestion was a piece of shit #44 (comment): storage is also used by KV processor, so we are not able to have a nil storage on AllowTxQueries==false
and therefore should close storage regardless of tx query allowance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, does that mean we always need storage to be correctly initialised in any workflow? Why wouldn't we just always initialise it then? That will allow us to remove dummy storage implementation completely, and also remove some useless logic around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly, that's the idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, i'll revert that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dummy storage implementation is still present though, don't we need to remove it since we don't use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
internal/app/app.go
Outdated
func NewDefaultTxSubmitChecker(cfg config.NeutronQueryRelayerConfig, logRegistry *nlogger.Registry, | ||
storage relay.Storage) (relay.TxSubmitChecker, error) { | ||
neutronClient, err := raw.NewRPCClient(cfg.NeutronChain.RPCAddr, cfg.NeutronChain.Timeout, | ||
logRegistry.Get(TargetChainRPCClientContext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrongly passed context: should be NeutronChainRPCClientContext
internal/txprocessor/txprocessor.go
Outdated
QueryID: queryID, | ||
SubmittedTxHash: hash, | ||
NeutronHash: neutronTxHash, | ||
SubmitTime: time.Now(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this submission time 1) is not correct; 2) is not used by the submit checker. wyt we can do with it? I'd remove it cuz it misleads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, i don't see any usages anywhere in the code. removed this field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great and all tests are passing. Can you please resolve merge conflicts now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'm very interested in merging this ASAP for my task! (but there are conflicts)
# Conflicts: # .env.example # .env.example.dev # cmd/neutron_query_relayer/main.go # internal/app/app.go # internal/relay/relayer.go # internal/txprocessor/txprocessor.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests pass. lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, untested
6021acb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests pass
This PR refactors the submit checker:
HOW TO TEST THIS CODE?
Tun the tx and kv integration tests using the audit fix branches for neutron and neutron-contracts, this branch for the relayer, and the main branch for the integration tests.