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

chore: add receipts to all turnstone tx proofs #433

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 9 additions & 16 deletions chain/evm/compass.go
Original file line number Diff line number Diff line change
Expand Up @@ -1238,23 +1238,16 @@ func (t compass) provideTxProof(ctx context.Context, queueTypeName string, rawMs

var serializedReceipt []byte

msg, ok := rawMsg.Msg.(*evmtypes.Message)
// If this is a turnstone message, we may need additional info
if ok {
switch msg.GetAction().(type) {
case *evmtypes.Message_UploadUserSmartContract:
// For UserUploadSmartContract messages, we need the transaction
// receipt, so that paloma can use the generated events to get the
// contract address
receipt, err := t.evm.TransactionReceipt(ctx, tx.Hash())
if err != nil {
return err
}
// If this is a turnstone message, we need to get the tx receipt
if _, ok := rawMsg.Msg.(*evmtypes.Message); ok {
receipt, err := t.evm.TransactionReceipt(ctx, tx.Hash())
if err != nil {
return err
}

serializedReceipt, err = receipt.MarshalBinary()
if err != nil {
return err
}
serializedReceipt, err = receipt.MarshalBinary()
if err != nil {
return err
}
}

Expand Down
11 changes: 10 additions & 1 deletion chain/evm/compass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ var (
return tx
}()

sampleReceiptTx1 = &ethtypes.Receipt{
Status: ethtypes.ReceiptStatusSuccessful,
}

eventIdAtomic = atomic.Int64{}
)

Expand Down Expand Up @@ -1915,9 +1919,14 @@ func TestProvidingEvidenceForAMessage(t *testing.T) {
setup: func(t *testing.T) (*mockEvmClienter, *evmmocks.PalomaClienter) {
evm, paloma := newMockEvmClienter(t), evmmocks.NewPalomaClienter(t)
evm.On("TransactionByHash", mock.Anything, mock.Anything).Return(sampleTx1, false, nil)
evm.On("TransactionReceipt", mock.Anything, mock.Anything).
Return(sampleReceiptTx1, nil)

paloma.On("AddMessageEvidence", mock.Anything, queue.QueueSuffixTurnstone, uint64(555),
&types.TxExecutedProof{SerializedTX: whoops.Must(sampleTx1.MarshalBinary())},
&types.TxExecutedProof{
SerializedTX: whoops.Must(sampleTx1.MarshalBinary()),
SerializedReceipt: whoops.Must(sampleReceiptTx1.MarshalBinary()),
},
).Return(
nil,
)
Expand Down
Loading