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

les: fix SendTx cost calculation and verify cost table #19437

Merged
merged 3 commits into from
Apr 10, 2019

Conversation

zsfelfoldi
Copy link
Contributor

This PR backports the new transaction cost calculation (including the size cost correction for large transactions which is now used by latest servers too). It also adds a verification for required message types in the announced cost table.

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

In the handshake, could we also check the costtable length? In theory les/1 client should only receive les/1 costtable and les/2 client should only receive les/2 costtable. Now we have checked the existence of each cost. It would be better to also check the table length.

peer.fcServer.QueueRequest(reqID, cost)
return func() { peer.SendTxs(reqID, cost, ll) }
return func() { peer.SendTxs(reqID, cost, enc) }
Copy link
Member

Choose a reason for hiding this comment

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

After modifying the TestTransactionStatusLes2 to this style, the RLP decode is failed.

@zsfelfoldi
Copy link
Contributor Author

I don't think we should strictly check the length of the cost table. We might want to add new requests later and in many cases it is doable without a new protocol version. Maybe we could add some protection against sending excessively large handshake packets in general but I don't think we should add it to 1.8.

@zsfelfoldi
Copy link
Contributor Author

Even worse, currently the server does announce the cost of requests for all protocol versions. Now that you brought this up, this might not be ideal but expecting an exact size for the cost table would definitely break now.

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

LGTM

@rjl493456442
Copy link
Member

@zsfelfoldi You are right. We have to also consider the compatibility between the 1.8.26 light clients and old server.

case lpv2:
msgcode = SendTxV2Msg
default:
panic(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a message. panic(nil) is really bad style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these were all removed when LES/1 was removed so I really don't think we need to care about it in this hotfix

case lpv2:
checkList = reqListV2
default:
panic(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

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