Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
maharifu committed Sep 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 327c224 commit 7e3931a
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
@@ -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
}
}

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

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

eventIdAtomic = atomic.Int64{}
)

@@ -1769,9 +1773,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,
)

0 comments on commit 7e3931a

Please sign in to comment.