Skip to content

Commit

Permalink
[LM] Set native bridge fee to 0 in bridge interfaces (#1107)
Browse files Browse the repository at this point in the history
- Pending transfers are already pending so they shouldn't need a bridge
fee, however, it looks like there is some validation logic in the plugin
validator that requires native bridge fee to be non-nil.
- This sets the native bridge fees to 0 in the bridge interfaces. They
will be overwritten later on in resolveProposedTransfers by calling the
`GetBridgePayloadAndFee` function directly
  • Loading branch information
ogtownsend authored Jun 27, 2024
1 parent bd1db00 commit 475dd3a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,9 @@ func (l *l1ToL2Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: []byte{}, // no finalization data, not ready
Stage: bridgecommon.StageRebalanceConfirmed,
BridgeData: []byte{}, // no finalization data, not ready
Stage: bridgecommon.StageRebalanceConfirmed,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusNotReady,
ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index),
Expand All @@ -386,8 +387,9 @@ func (l *l1ToL2Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: readyData[i], // finalization data since its ready
Stage: bridgecommon.StageFinalizeReady,
BridgeData: readyData[i], // finalization data since its ready
Stage: bridgecommon.StageFinalizeReady,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusReady, // ready == finalized for L1 -> L2 transfers due to auto-finalization by the native bridge
ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ func Test_l1ToL2Bridge_toPendingTransfers(t *testing.T) {
Date: time.Time{},
BridgeData: []byte{},
Stage: 1,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusNotReady,
ID: fmt.Sprintf("%s-%d", common.HexToHash("0x1"), 1),
Expand All @@ -1393,6 +1394,7 @@ func Test_l1ToL2Bridge_toPendingTransfers(t *testing.T) {
Date: time.Time{},
BridgeData: []byte{1, 2, 3},
Stage: 2,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusReady,
ID: fmt.Sprintf("%s-%d", common.HexToHash("0x2"), 2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ func (l *l2ToL1Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: readyData[i], // finalization data for withdrawals that are ready
Stage: bridgecommon.StageFinalizeReady,
BridgeData: readyData[i], // finalization data for withdrawals that are ready
Stage: bridgecommon.StageFinalizeReady,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusReady,
ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index),
Expand All @@ -360,8 +361,9 @@ func (l *l2ToL1Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: []byte{}, // No data since its not ready
Stage: bridgecommon.StageRebalanceConfirmed,
BridgeData: []byte{}, // No data since its not ready
Stage: bridgecommon.StageRebalanceConfirmed,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusNotReady,
ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,9 @@ func (l *l1ToL2Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: transfer.BridgeReturnData, // unique nonce from the OP Bridge Adapter
Stage: bridgecommon.StageRebalanceConfirmed,
BridgeData: transfer.BridgeReturnData, // unique nonce from the OP Bridge Adapter
Stage: bridgecommon.StageRebalanceConfirmed,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusNotReady,
ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index),
Expand All @@ -517,8 +518,9 @@ func (l *l1ToL2Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: transfer.BridgeReturnData, // unique nonce from the OP Bridge Adapter
Stage: bridgecommon.StageFinalizeReady,
BridgeData: transfer.BridgeReturnData, // unique nonce from the OP Bridge Adapter
Stage: bridgecommon.StageFinalizeReady,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusReady, // ready == finalized for L1 -> L2 transfers due to auto-finalization by the native bridge
ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ func (l *l2ToL1Bridge) GetTransfers(
if len(missingSent) > 0 {
l.lggr.Errorw("missing sent logs", "missingSent", missingSent)
}
l.lggr.Infow("partitioned withdrawal transfers",
"needsToBeProven", needsToBeProven,
"needsToBeFinalized", needsToBeFinalized,
)

return l.toPendingTransfers(ctx, lggr, localToken, remoteToken, needsToBeProven, needsToBeFinalized, parsedToLp)
}
Expand Down Expand Up @@ -382,8 +386,9 @@ func (l *l2ToL1Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: provePayload,
Stage: bridgecommon.StageRebalanceConfirmed,
BridgeData: provePayload,
Stage: bridgecommon.StageRebalanceConfirmed,
NativeBridgeFee: ubig.NewI(0),
},
// Both "prove" and "finalize" are handled by the "finalizeWithdrawalERC20" call in the
// OptimismL1BridgeAdapter, therefore we set the status to "Ready"
Expand All @@ -409,8 +414,9 @@ func (l *l2ToL1Bridge) toPendingTransfers(
TxHash: transfer.Raw.TxHash,
LogIndex: int64(transfer.Raw.Index),
}].BlockTimestamp,
BridgeData: finalizePayload,
Stage: bridgecommon.StageFinalizeReady,
BridgeData: finalizePayload,
Stage: bridgecommon.StageFinalizeReady,
NativeBridgeFee: ubig.NewI(0),
},
Status: models.TransferStatusReady, // Ready to be finalized
ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index),
Expand Down

0 comments on commit 475dd3a

Please sign in to comment.