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

fix(bmr): send only one receipt per transaction #545

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

MuhammedIrfan
Copy link
Collaborator

@MuhammedIrfan MuhammedIrfan commented Sep 26, 2022

Closes #543
Closes #186

Checklist:

  • I have performed a self-review of my own code
  • I have documented my code in accordance with the documentation guidelines
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have run the unit tests
  • I only have one commit (if not, squash them into one commit).
  • I have a descriptive commit message that adheres to the commit message guidelines

@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Merging #545 (bf923b0) into main (4e691bb) will increase coverage by 0.49%.
The diff coverage is 77.27%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #545      +/-   ##
============================================
+ Coverage     42.01%   42.51%   +0.49%     
  Complexity      801      801              
============================================
  Files           115      116       +1     
  Lines         11321    11317       -4     
  Branches        941      941              
============================================
+ Hits           4757     4811      +54     
+ Misses         6155     6093      -62     
- Partials        409      413       +4     
Impacted Files Coverage Δ
cmd/iconbridge/chain/icon/sender.go 0.00% <0.00%> (ø)
cmd/iconbridge/chain/bsc/sender.go 33.85% <50.00%> (-4.86%) ⬇️
cmd/iconbridge/chain/near/sender.go 61.49% <66.66%> (+14.00%) ⬆️
cmd/iconbridge/common/chainutils/segment.go 89.28% <89.28%> (ø)
cmd/iconbridge/chain/bsc/verifier.go 47.05% <0.00%> (-0.66%) ⬇️
cmd/iconbridge/chain/substrate-eth/receiver.go 62.77% <0.00%> (ø)
cmd/iconbridge/chain/bsc/receiver.go 59.02% <0.00%> (+1.42%) ⬆️

cmd/iconbridge/chain/near/sender.go Outdated Show resolved Hide resolved
cmd/iconbridge/chain/near/sender.go Show resolved Hide resolved
@bbist bbist self-requested a review September 27, 2022 09:29
@bbist
Copy link
Collaborator

bbist commented Sep 27, 2022

Hi @MuhammedIrfan,
Can you try with the latest changes? You need to provide a configurable value for tx_data_size_limit from the config file as specified here.

@CyrusVorwald
Copy link
Contributor

These changes need tests.

@bbist
Copy link
Collaborator

bbist commented Sep 27, 2022

These changes need tests.

Thanks @CyrusVorwald-ICON for pointing it out. It wasn't a final solution, but rather an intermediate one to see if it works for NEAR. Anyway, I'll refactor the shared code for segmentation used across all chains and add necessary test and push again.

@bbist bbist self-assigned this Sep 27, 2022
@bbist
Copy link
Collaborator

bbist commented Sep 30, 2022

Hi @MuhammedIrfan,

The tests that were failing on near side were not implemented correctly. I've changed the test parameters so that they work as expected. They should work now.

@bbist
Copy link
Collaborator

bbist commented Sep 30, 2022

Hi @MuhammedIrfan,

The tests that were failing on near side were not implemented correctly. I've changed the test parameters so that they work as expected. They should work now.

Btw, have you deployed this code? Let's test it on local and see if it resolves the original issue that this PR resolves. If it does, I'll approve the changes and merge into main.

@MuhammedIrfan
Copy link
Collaborator Author

@bbist looks like it does not add message to tx if rlp size is more than configured limit also if it have only 1 event

@bbist
Copy link
Collaborator

bbist commented Oct 7, 2022

@bbist looks like it does not add message to tx if rlp size is more than configured limit also if it have only 1 event

Yeah. That's true. You can configure a limit that can handle 1 event. We did the same for BSC.

@MuhammedIrfan
Copy link
Collaborator Author

@bbist looks like it does not add message to tx if rlp size is more than configured limit also if it have only 1 event

Yeah. That's true. You can configure a limit that can handle 1 event. We did the same for BSC.

But we can't always be sure of size right, at times when the event size is more than configured it create relay message without any receipts eg: https://explorer.testnet.near.org/transactions/3or4kyeL7fQ6uds73BfCynMbHscnBG4tLjwCHNA4EJon

@MuhammedIrfan MuhammedIrfan added the team: hugobyte Relevant to HugoByte label Oct 7, 2022
@bbist
Copy link
Collaborator

bbist commented Oct 19, 2022

@bbist looks like it does not add message to tx if rlp size is more than configured limit also if it have only 1 event

Yeah. That's true. You can configure a limit that can handle 1 event. We did the same for BSC.

But we can't always be sure of size right, at times when the event size is more than configured it create relay message without any receipts eg: https://explorer.testnet.near.org/transactions/3or4kyeL7fQ6uds73BfCynMbHscnBG4tLjwCHNA4EJon

What is the maximum number of events the NEAR chain can handle in a single transaction? Is it a single event of can it handle 2-3 or more? If so, you can chose some data size limit that can cover 2 or more events. And in the worst case, it'll forward 1 event. This is what we did for BSC.
If this approach is sufficient, then it's fine. Otherwise, we might have to modify the code to also support for minimum number of events, rather than the transaction data size limit.

@MuhammedIrfan
Copy link
Collaborator Author

MuhammedIrfan commented Oct 22, 2022

@bbist

in the worst case, it'll forward 1 event. This is what we did for BSC. If this approach is sufficient, then it's fine. Otherwise, we might have to modify the code to also support for minimum number of events, rather than the transaction data size limit.

This is not happening, I have updated the test to test this scenario. Please check.

What is the maximum number of events the NEAR chain can handle in a single transaction? Is it a single event of can it handle 2-3 or more?

At present NEAR supports only one event which is being improved as part of gas optimization, As different BTP Messages have different gas usage, for example, Init BTP Message will use less than that transfer, and Link BTP Message uses more gas, Until we find a way to optimize and segment the message in the relay we might just keep only 1 BTP Message per Relay Message

@bbist
Copy link
Collaborator

bbist commented Oct 22, 2022

@bbist

in the worst case, it'll forward 1 event. This is what we did for BSC. If this approach is sufficient, then it's fine. Otherwise, we might have to modify the code to also support for minimum number of events, rather than the transaction data size limit.

This is not happening, I have updated the test to test this scenario. Please check.

What is the maximum number of events the NEAR chain can handle in a single transaction? Is it a single event of can it handle 2-3 or more?

At present NEAR supports only one event which is being improved as part of gas optimization, As different BTP Messages have different gas usage, for example, Init BTP Message will use less than that transfer, and Link BTP Message uses more gas, Until we find a way to optimize and segment the message in the relay we might just keep only 1 BTP Message per Relay Message

Well, in that case as a temporary solution, let's have a minimum number of events set to 1 while segmenting for NEAR.

@bbist
Copy link
Collaborator

bbist commented Nov 2, 2022

@bbist

in the worst case, it'll forward 1 event. This is what we did for BSC. If this approach is sufficient, then it's fine. Otherwise, we might have to modify the code to also support for minimum number of events, rather than the transaction data size limit.

This is not happening, I have updated the test to test this scenario. Please check.

What is the maximum number of events the NEAR chain can handle in a single transaction? Is it a single event of can it handle 2-3 or more?

At present NEAR supports only one event which is being improved as part of gas optimization, As different BTP Messages have different gas usage, for example, Init BTP Message will use less than that transfer, and Link BTP Message uses more gas, Until we find a way to optimize and segment the message in the relay we might just keep only 1 BTP Message per Relay Message

Well, in that case as a temporary solution, let's have a minimum number of events set to 1 while segmenting for NEAR.

@MuhammedIrfan,
Has necessary changes been made on this issue? Please don't let it be a blocker for the integration. You can make necessary changes in your NEAR specific Segment() function to forward a single event, and maybe add a TODO comment to comeback to this issue later. Let's try to resolve this PR.

Message *chain.Message
Options types.SenderOptions
}{
PrivateKey: "22yx6AjQgG1jGuAmPuEwLnVKFnuq5LU23dbU3JBZodKxrJ8dmmqpDZKtRSfiU4F8UQmv1RiZSrjWhQMQC3ye7M1J",
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be good to generate a random one instead predefined for private key

@andrii-kl andrii-kl self-requested a review November 7, 2022 12:51
@MuhammedIrfan MuhammedIrfan marked this pull request as draft November 18, 2022 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team: hugobyte Relevant to HugoByte
Projects
None yet
4 participants