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
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 18 additions & 25 deletions cmd/iconbridge/chain/near/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,34 +88,24 @@ func (s *Sender) Segment(ctx context.Context, msg *chain.Message) (tx chain.Rela
Receipts: make([][]byte, 0),
}

var msgSize uint64
receipt := msg.Receipts[0]
bbist marked this conversation as resolved.
Show resolved Hide resolved

newMsg = &chain.Message{
From: msg.From,
Receipts: msg.Receipts,
rlpEvents, err := codec.RLP.MarshalToBytes(receipt.Events)
if err != nil {
return nil, nil, err
}
for i, receipt := range msg.Receipts {
rlpEvents, err := codec.RLP.MarshalToBytes(receipt.Events)
bbist marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, nil, err
}
rlpReceipt, err := codec.RLP.MarshalToBytes(&chain.RelayReceipt{
Index: receipt.Index,
Height: receipt.Height,
Events: rlpEvents,
})
if err != nil {
return nil, nil, err
}
newMsgSize := msgSize + uint64(len(rlpReceipt))
if newMsgSize > txMaxDataSize {
newMsg.Receipts = msg.Receipts[i:]
break
}
msgSize = newMsgSize
rm.Receipts = append(rm.Receipts, rlpReceipt)

rlpReceipt, err := codec.RLP.MarshalToBytes(&chain.RelayReceipt{
Index: receipt.Index,
Height: receipt.Height,
Events: rlpEvents,
})
if err != nil {
return nil, nil, err
}

rm.Receipts = append(rm.Receipts, rlpReceipt)

message, err := codec.RLP.MarshalToBytes(rm)
if err != nil {
return nil, nil, err
Expand All @@ -126,7 +116,10 @@ func (s *Sender) Segment(ctx context.Context, msg *chain.Message) (tx chain.Rela
return nil, nil, err
}

return tx, newMsg, nil
return tx, &chain.Message{
From: msg.From,
Receipts: msg.Receipts[1:],
}, nil
}

func (s *Sender) newRelayTransaction(ctx context.Context, prev string, message []byte) (*RelayTransaction, error) {
Expand Down