Skip to content

Conversation

@LukasGasior1
Copy link
Contributor

@LukasGasior1 LukasGasior1 commented Jun 13, 2017

  • added FilterManager for managing filters states

@rtkaczyk rtkaczyk self-requested a review June 14, 2017 13:34
case e: JString =>
extractBytes(e).toOption.getOrElse(throw new RuntimeException(s"Unable to parse topics, expected byte data but got ${e.values}"))
case other =>
throw new RuntimeException(s"Unable to parse topics, expected byte data but got: $other")
Copy link
Contributor

Choose a reason for hiding this comment

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

😨

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...so you noticed that :P fixed

}
.recover { case ex => errorResponse(rpcReq, InternalError) }
.recover { case ex =>
log.error("Failed to handle RPC request", ex)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍
We generally miss logging in this area. Would be really helpful to know which methods are being called from Ethereum Wallet.


val maxBlockHashesChanges = 256

var filters: Seq[Filter] = Nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not a Map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

And do you think it's worthy to join filters and lastCheckBlocks within the same Map?

sender() ! NewFilterResponse(filter.id)
}

private def uninstallFilter(id: BigInt): Unit = {
Copy link
Contributor

@AlanVerbner AlanVerbner Jun 15, 2017

Choose a reason for hiding this comment

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

The definition states: Additonally Filters timeout when they aren't requested with eth_getFilterChanges for a period of time. ... is that done? If so please point me out where is it and discard this comment 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, missed 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.

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Works perfectly! 🤘

(pendingTransactionsManager ? PendingTransactionsManager.GetPendingTransactions)
.mapTo[PendingTransactionsManager.PendingTransactions]
.flatMap { case PendingTransactionsManager.PendingTransactions(pendingTransactions) =>
keyStore.listAccounts() match {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this filter is required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to documentation no, but geth implementation only returns pending transactions of accounts managed by this node so I think it's needed to stay consistent

sealed trait Filter {
def id: BigInt
}
case class LogFilter(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible the following field is missing?

removed: TAG - true when the log was removed, due to a chain reorganization. false if its a valid log.

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 is, according to documentation, but...:
a) geth does not return such field
b) I don't think there's a case when this should be set to false (we never return logs from dropped blocks)

Copy link
Contributor

Choose a reason for hiding this comment

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

Discard the comment then

}

private def getBlockHashesAfter(blockNumber: BigInt): Seq[ByteString] = {
val bestBlock = appStateStorage.getBestBlockNumber()
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is being queried here https://github.com/input-output-hk/etc-client/pull/218/files#diff-b5ee4e4c8bcd462269de630eb5466a06R127 maybe we can send it as paramenter instead of getting that value again

recur(blockNumber + 1, Nil)
}

private def getPendingTransactions(): Future[Seq[SignedTransaction]] = {
Copy link
Contributor

@AlanVerbner AlanVerbner Jun 16, 2017

Choose a reason for hiding this comment

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

It seems this one doesn't work as parity does. Our implementation is returning all the pending transactions every time I query them. In parity, it only returns the ones It hasn't returned before.

This doc statement is confusing, but might be the reason Creates a filter in the node, to notify when new pending transactions arrive . Maybe new is interpreted as parity does, ie: new in terms of this API

transactionHash: Option[ByteString],
blockHash: ByteString,
blockNumber: BigInt,
address: Address,
Copy link
Contributor

Choose a reason for hiding this comment

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

since we are using Extraction.decompose should we use ByteString for address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added custom serializer for Address

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 AddressJsonSerializer

@LukasGasior1 LukasGasior1 removed the WIP label Jun 21, 2017
AlanVerbner
AlanVerbner previously approved these changes Jun 21, 2017
Copy link
Contributor

@AlanVerbner AlanVerbner left a comment

Choose a reason for hiding this comment

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

@LukasGasior1 I've been testing and the code works really good! 🚀

The pending block isn't yet done so i'm skipping tests on that subject


var filterTimeouts: Map[BigInt, Cancellable] = Map.empty

implicit val timeout = Timeout(5.seconds)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this used for? Should it be configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course it should

AlanVerbner
AlanVerbner previously approved these changes Jun 22, 2017
Copy link
Contributor

@AlanVerbner AlanVerbner left a comment

Choose a reason for hiding this comment

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

lgtm

@LukasGasior1 LukasGasior1 merged commit 7df6bf4 into phase/4/jsonrpc Jun 22, 2017
@LukasGasior1 LukasGasior1 deleted the feature/ethFilter branch June 22, 2017 16:53
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.

4 participants