Commit 16132b26 authored by Hamdi Allam's avatar Hamdi Allam Committed by GitHub

Merge pull request #7585 from ethereum-optimism/indexer.portal.deposit.fix

bugfix(indexer) index the mint field of the l1 deposit transactions and not the value field
parents 272b6d72 3d601d37
...@@ -26,6 +26,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) { ...@@ -26,6 +26,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
optimismPortal, err := bindings.NewOptimismPortal(testSuite.OpCfg.L1Deployments.OptimismPortalProxy, testSuite.L1Client) optimismPortal, err := bindings.NewOptimismPortal(testSuite.OpCfg.L1Deployments.OptimismPortalProxy, testSuite.L1Client)
require.NoError(t, err) require.NoError(t, err)
bobAddr := testSuite.OpCfg.Secrets.Addresses().Bob
aliceAddr := testSuite.OpCfg.Secrets.Addresses().Alice aliceAddr := testSuite.OpCfg.Secrets.Addresses().Alice
// attach 1 ETH to the deposit and random calldata // attach 1 ETH to the deposit and random calldata
...@@ -34,7 +35,9 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) { ...@@ -34,7 +35,9 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
l1Opts.Value = big.NewInt(params.Ether) l1Opts.Value = big.NewInt(params.Ether)
depositTx, err := optimismPortal.DepositTransaction(l1Opts, aliceAddr, l1Opts.Value, 100_000, false, calldata) // In the same deposit transaction, transfer, 0.5ETH to Bob. We do this to ensure we're only indexing
// bridged funds from the source address versus any transferred value to a recipient in the same L2 transaction
depositTx, err := optimismPortal.DepositTransaction(l1Opts, bobAddr, big.NewInt(params.Ether/2), 100_000, false, calldata)
require.NoError(t, err) require.NoError(t, err)
depositReceipt, err := wait.ForReceiptOK(context.Background(), testSuite.L1Client, depositTx.Hash()) depositReceipt, err := wait.ForReceiptOK(context.Background(), testSuite.L1Client, depositTx.Hash())
require.NoError(t, err) require.NoError(t, err)
...@@ -57,7 +60,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) { ...@@ -57,7 +60,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
require.Equal(t, uint64(100_000), deposit.GasLimit.Uint64()) require.Equal(t, uint64(100_000), deposit.GasLimit.Uint64())
require.Equal(t, uint64(params.Ether), deposit.Tx.Amount.Uint64()) require.Equal(t, uint64(params.Ether), deposit.Tx.Amount.Uint64())
require.Equal(t, aliceAddr, deposit.Tx.FromAddress) require.Equal(t, aliceAddr, deposit.Tx.FromAddress)
require.Equal(t, aliceAddr, deposit.Tx.ToAddress) require.Equal(t, bobAddr, deposit.Tx.ToAddress)
require.ElementsMatch(t, calldata, deposit.Tx.Data) require.ElementsMatch(t, calldata, deposit.Tx.Data)
event, err := testSuite.DB.ContractEvents.L1ContractEvent(deposit.InitiatedL1EventGUID) event, err := testSuite.DB.ContractEvents.L1ContractEvent(deposit.InitiatedL1EventGUID)
......
...@@ -92,10 +92,17 @@ CREATE TABLE IF NOT EXISTS l1_transaction_deposits ( ...@@ -92,10 +92,17 @@ CREATE TABLE IF NOT EXISTS l1_transaction_deposits (
l2_transaction_hash VARCHAR NOT NULL UNIQUE, l2_transaction_hash VARCHAR NOT NULL UNIQUE,
initiated_l1_event_guid VARCHAR NOT NULL UNIQUE REFERENCES l1_contract_events(guid) ON DELETE CASCADE, initiated_l1_event_guid VARCHAR NOT NULL UNIQUE REFERENCES l1_contract_events(guid) ON DELETE CASCADE,
-- transaction data -- transaction data. NOTE: `to_address` is the recipient of funds transferred in value field of the
-- L2 deposit transaction and not the amount minted on L1 from the source address. Hence the `amount`
-- column in this table does NOT indiciate the amount transferred to the recipient but instead funds
-- bridged from L1 into `from_address`.
from_address VARCHAR NOT NULL, from_address VARCHAR NOT NULL,
to_address VARCHAR NOT NULL, to_address VARCHAR NOT NULL,
-- This refers to the amount MINTED on L2 (msg.value of the L1 transaction). Important distinction from
-- the `value` field of the deposit transaction which simply is the value transferred to specified recipient.
amount UINT256 NOT NULL, amount UINT256 NOT NULL,
gas_limit UINT256 NOT NULL, gas_limit UINT256 NOT NULL,
data VARCHAR NOT NULL, data VARCHAR NOT NULL,
timestamp INTEGER NOT NULL CHECK (timestamp > 0) timestamp INTEGER NOT NULL CHECK (timestamp > 0)
......
...@@ -71,7 +71,7 @@ func OptimismPortalTransactionDepositEvents(contractAddress common.Address, db * ...@@ -71,7 +71,7 @@ func OptimismPortalTransactionDepositEvents(contractAddress common.Address, db *
Tx: database.Transaction{ Tx: database.Transaction{
FromAddress: txDeposit.From, FromAddress: txDeposit.From,
ToAddress: txDeposit.To, ToAddress: txDeposit.To,
Amount: depositTx.Value, Amount: depositTx.Mint,
Data: depositTx.Data, Data: depositTx.Data,
Timestamp: transactionDepositEvents[i].Timestamp, Timestamp: transactionDepositEvents[i].Timestamp,
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment