Skip to content

Commit

Permalink
chore: add receipts to all turnstone tx proofs
Browse files Browse the repository at this point in the history
The receipts will be needed in paloma to attest the txs were successful.
  • Loading branch information
maharifu committed Sep 5, 2024
1 parent e3d1295 commit 5ca33de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
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

0 comments on commit 5ca33de

Please sign in to comment.