Skip to content

Commit 04f3b2e

Browse files
Merge branch 'develop' into feat/index-backward-let
2 parents 4b8235f + 24d558e commit 04f3b2e

File tree

16 files changed

+122
-34
lines changed

16 files changed

+122
-34
lines changed

.github/test_e2e_cdk_erigon_args_base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"zkevm_use_real_verifier": false,
1919
"sp1_prover_key": "",
2020
"sequencer_type": "erigon",
21-
"cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.63.0-rc4",
21+
"cdk_erigon_image": "europe-west2-docker.pkg.dev/prj-polygonlabs-devtools-dev/public/cdk-erigon:v2.65.0-RC1",
2222
"enable_normalcy": true,
2323
"erigon_strict_mode": false,
2424
"gas_token_enabled": false,

.github/workflows/test-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
fi
5555
else
5656
# For push/workflow_dispatch, use the fixed commit
57-
COMMIT="413f956c9dde7084af4a39e3d082546ef8bb4a79"
57+
COMMIT="b959a5f2b7e8247ae09e16fd9f51c1e23a1ab5ee"
5858
echo "Using fixed kurtosis-cdk commit: ${COMMIT}"
5959
fi
6060
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT

bridgeservice/bridge_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ func TestGetBridgesHandler(t *testing.T) {
535535
Amount: common.Big0,
536536
DepositCount: 0,
537537
Metadata: []byte("metadata"),
538+
TxnSender: common.HexToAddress("0x5555555555555555555555555555555555555555"),
539+
ToAddress: common.HexToAddress("0xF9D64d54D32EE2BDceAAbFA60C4C438E224427d0"),
538540
},
539541
}
540542

@@ -567,6 +569,11 @@ func TestGetBridgesHandler(t *testing.T) {
567569

568570
require.Equal(t, bridgeResponses, response.Bridges)
569571
require.Equal(t, len(expectedBridges), response.Count)
572+
573+
// Verify to_address is present in the response
574+
require.NotNil(t, response.Bridges)
575+
require.Len(t, response.Bridges, 1)
576+
require.Equal(t, bridgetypes.Address("0xF9D64d54D32EE2BDceAAbFA60C4C438E224427d0"), response.Bridges[0].ToAddress)
570577
})
571578

572579
t.Run("GetBridges for L1 network error", func(t *testing.T) {

bridgeservice/docs/docs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,11 @@ const docTemplate = `{
801801
"type": "integer",
802802
"example": 10
803803
},
804+
"to_address": {
805+
"description": "Address of the contract that was the recipient of the transaction. This may differ from the bridge contract address.",
806+
"type": "string",
807+
"example": "0xF9D64d54D32EE2BDceAAbFA60C4C438E224427d0"
808+
},
804809
"tx_hash": {
805810
"description": "Hash of the transaction that included the bridge event",
806811
"type": "string",

bridgeservice/docs/swagger.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,11 @@
794794
"type": "integer",
795795
"example": 10
796796
},
797+
"to_address": {
798+
"description": "Address of the contract that was the recipient of the transaction. This may differ from the bridge contract address.",
799+
"type": "string",
800+
"example": "0xF9D64d54D32EE2BDceAAbFA60C4C438E224427d0"
801+
},
797802
"tx_hash": {
798803
"description": "Hash of the transaction that included the bridge event",
799804
"type": "string",

bridgeservice/docs/swagger.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ definitions:
8080
description: ID of the network where the bridge transaction originated
8181
example: 10
8282
type: integer
83+
to_address:
84+
description: Address of the contract that was the recipient of the transaction.
85+
This may differ from the bridge contract address.
86+
example: 0xF9D64d54D32EE2BDceAAbFA60C4C438E224427d0
87+
type: string
8388
tx_hash:
8489
description: Hash of the transaction that included the bridge event
8590
example: 0xdef4567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

bridgeservice/types/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ type BridgeResponse struct {
140140

141141
// Address of the transaction sender who initiated the bridge transaction
142142
TxnSender Address `json:"txn_sender" example:"0xabc1234567890abcdef1234567890abcdef12345"`
143+
144+
// Address of the contract that was the recipient of the transaction. This may differ from the bridge contract address.
145+
ToAddress Address `json:"to_address" example:"0xF9D64d54D32EE2BDceAAbFA60C4C438E224427d0"`
143146
}
144147

145148
// ClaimsResult contains the list of claim records and the total count

bridgeservice/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ func NewBridgeResponse(bridge *bridgesync.Bridge, networkID uint32,
144144
DepositCount: bridge.DepositCount,
145145
BridgeHash: bridgetypes.Hash(bridge.Hash().Hex()),
146146
TxnSender: bridgetypes.Address(bridge.TxnSender.Hex()),
147+
ToAddress: bridgetypes.Address(bridge.ToAddress.Hex()),
147148
}
148149
}
149150

bridgesync/backfill_tx_sender.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ func (b *BackfillTxnSender) extractData(ctx context.Context,
337337
return common.Address{}, common.Address{}, ctx.Err()
338338
default:
339339
}
340-
return ExtractTxnSenderAndFrom(ctx, b.client, b.bridgeAddr, txHash, logEvent, b.log)
340+
txnSender, fromAddr, _, err = ExtractTxnAddresses(ctx, b.client, b.bridgeAddr, txHash, logEvent, b.log)
341+
return txnSender, fromAddr, err
341342
}
342343

343344
// bulkUpdate performs a bulk update of multiple records
@@ -370,7 +371,7 @@ func (b *BackfillTxnSender) bulkUpdate(
370371

371372
stmt, err := tx.PrepareContext(dbCtx, fmt.Sprintf(`
372373
UPDATE %s
373-
SET
374+
SET
374375
txn_sender = COALESCE(NULLIF(txn_sender, ''), ?),
375376
from_address = COALESCE(NULLIF(from_address, ''), ?)
376377
WHERE block_num = ? AND block_pos = ?;

bridgesync/downloader.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ func (t *Transaction) From() common.Address {
144144
return common.HexToAddress(t.FromRaw)
145145
}
146146

147+
func (t *Transaction) ToAddress() common.Address {
148+
if t.To == "" {
149+
return common.Address{}
150+
}
151+
return common.HexToAddress(t.To)
152+
}
153+
147154
func RPCTransactionByHash(client aggkittypes.EthClienter,
148155
txHash common.Hash) (*Transaction, error) {
149156
// Use client.Call to fetch transaction details using eth_getTransactionByHash
@@ -155,33 +162,25 @@ func RPCTransactionByHash(client aggkittypes.EthClienter,
155162
return &tx, nil
156163
}
157164

158-
func extractTxnSender(
159-
client aggkittypes.EthClienter,
160-
txHash common.Hash) (common.Address, error) {
161-
tx, err := RPCTransactionByHash(client, txHash)
162-
if err != nil {
163-
return common.Address{}, fmt.Errorf("failed to get transaction by hash for %s: %w", txHash.Hex(), err)
164-
}
165-
return tx.From(), nil
166-
}
167-
168-
// ExtractTxnSenderAndFrom extracts the txn_sender and from address from the transaction trace.
169-
// Return txnSender (same for all events in the same transaction) and fromAddr (specific for the event)
170-
func ExtractTxnSenderAndFrom(ctx context.Context,
165+
// ExtractTxnAddresses extracts the txn_sender, from address, and to address from the transaction trace.
166+
func ExtractTxnAddresses(ctx context.Context,
171167
client aggkittypes.EthClienter,
172168
bridgeAddr common.Address,
173169
txHash common.Hash,
174170
logEvent *agglayerbridge.AgglayerbridgeBridgeEvent,
175-
logger *logger.Logger) (txnSender common.Address, fromAddr common.Address, err error) {
171+
logger *logger.Logger) (txnSender common.Address, fromAddr common.Address, toAddr common.Address, err error) {
176172
// If event is a message, fromAddr is log.origin_address
177173
// so we only need the txn_sender that can be obtained from hash_receipt
174+
// and toAddr from the transaction receipt (same source as txn_sender)
178175
if logEvent.LeafType == bridgeLeafTypeMessage {
179-
txnSender, err = extractTxnSender(client, txHash)
176+
tx, err := RPCTransactionByHash(client, txHash)
180177
if err != nil {
181-
return common.Address{}, common.Address{},
182-
fmt.Errorf("extractTxnSenderAndFrom: failed to extract txn sender from tx_hash:%s: %w", txHash.Hex(), err)
178+
return common.Address{}, common.Address{}, common.Address{},
179+
fmt.Errorf("extractTxnAddresses: failed to extract txn sender from tx_hash:%s: %w", txHash.Hex(), err)
183180
}
184-
return txnSender, logEvent.OriginAddress, nil
181+
txnSender = tx.From()
182+
toAddr = tx.ToAddress()
183+
return txnSender, logEvent.OriginAddress, toAddr, nil
185184
}
186185
foundCalls, rootCall, err := extractCallData(client, bridgeAddr, txHash, logger, func(c Call) (bool, error) {
187186
if logEvent.LeafType == bridgeLeafTypeAsset {
@@ -190,18 +189,19 @@ func ExtractTxnSenderAndFrom(ctx context.Context,
190189
return false, nil
191190
})
192191
if err != nil {
193-
return common.Address{}, common.Address{},
194-
fmt.Errorf("extractTxnSenderAndFrom:failed to extract bridge event data (tx hash: %s): %w", txHash, err)
192+
return common.Address{}, common.Address{}, common.Address{},
193+
fmt.Errorf("extractTxnAddresses:failed to extract bridge event data (tx hash: %s): %w", txHash, err)
195194
}
196195
txnSender = rootCall.From
196+
toAddr = rootCall.To
197197
fromAddr, err = ExtractFromAddrFromCalls(foundCalls, logEvent)
198198
if err != nil {
199-
return common.Address{}, common.Address{},
200-
fmt.Errorf("extractTxnSenderAndFrom: failed to extract fromAddr from tx_hash:%s calls: %w",
199+
return common.Address{}, common.Address{}, common.Address{},
200+
fmt.Errorf("extractTxnAddresses: failed to extract fromAddr from tx_hash:%s calls: %w",
201201
txHash.Hex(), err)
202202
}
203203

204-
return txnSender, fromAddr, nil
204+
return txnSender, fromAddr, toAddr, nil
205205
}
206206

207207
type bridgeCallParams struct {
@@ -360,7 +360,7 @@ func buildBridgeEventHandler(
360360
"DestinationNetwork: %d, DestinationAddress: %s, DepositCount: %d, Amount: %s, ",
361361
bridgeEvent.LeafType, bridgeEvent.OriginNetwork, bridgeEvent.OriginAddress.Hex(), bridgeEvent.DestinationNetwork,
362362
bridgeEvent.DestinationAddress.Hex(), bridgeEvent.DepositCount, bridgeEvent.Amount.String())
363-
txnSender, fromAddress, err := ExtractTxnSenderAndFrom(ctx, client, bridgeAddr, l.TxHash,
363+
txnSender, fromAddress, toAddress, err := ExtractTxnAddresses(ctx, client, bridgeAddr, l.TxHash,
364364
bridgeEvent, logger)
365365
if err != nil {
366366
return fmt.Errorf("failed to extract bridge event data (tx hash: %s): %w", l.TxHash, err)
@@ -381,6 +381,7 @@ func buildBridgeEventHandler(
381381
Metadata: bridgeEvent.Metadata,
382382
DepositCount: bridgeEvent.DepositCount,
383383
TxnSender: txnSender,
384+
ToAddress: toAddress,
384385
}})
385386
return nil
386387
}

0 commit comments

Comments
 (0)