Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
56aac2c7
Commit
56aac2c7
authored
Aug 16, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simply things
parent
6f073fee
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
32 deletions
+22
-32
deposits.go
indexer/api/routes/deposits.go
+2
-2
withdrawals.go
indexer/api/routes/withdrawals.go
+2
-2
bridge_transactions.go
indexer/database/bridge_transactions.go
+3
-8
bridge_transfers.go
indexer/database/bridge_transfers.go
+3
-3
bridge_transactions_e2e_test.go
indexer/e2e_tests/bridge_transactions_e2e_test.go
+0
-3
bridge_transfers_e2e_test.go
indexer/e2e_tests/bridge_transfers_e2e_test.go
+8
-8
l1_processor.go
indexer/processor/l1_processor.go
+2
-4
l2_processor.go
indexer/processor/l2_processor.go
+2
-2
No files found.
indexer/api/routes/deposits.go
View file @
56aac2c7
...
...
@@ -48,7 +48,7 @@ func newDepositResponse(deposits []*database.L1BridgeDepositWithTransactionHashe
Amount
:
deposit
.
L1BridgeDeposit
.
Tx
.
Amount
.
Int
.
String
(),
L1Token
:
TokenInfo
{
ChainId
:
1
,
Address
:
deposit
.
L1BridgeDeposit
.
TokenPair
.
L
1
TokenAddress
.
String
(),
Address
:
deposit
.
L1BridgeDeposit
.
TokenPair
.
L
ocal
TokenAddress
.
String
(),
Name
:
"TODO"
,
Symbol
:
"TODO"
,
Decimals
:
420
,
...
...
@@ -58,7 +58,7 @@ func newDepositResponse(deposits []*database.L1BridgeDepositWithTransactionHashe
},
L2Token
:
TokenInfo
{
ChainId
:
10
,
Address
:
deposit
.
L1BridgeDeposit
.
TokenPair
.
L2
TokenAddress
.
String
(),
Address
:
deposit
.
L1BridgeDeposit
.
TokenPair
.
Remote
TokenAddress
.
String
(),
Name
:
"TODO"
,
Symbol
:
"TODO"
,
Decimals
:
420
,
...
...
indexer/api/routes/withdrawals.go
View file @
56aac2c7
...
...
@@ -73,7 +73,7 @@ func newWithdrawalResponse(withdrawals []*database.L2BridgeWithdrawalWithTransac
WithdrawalState
:
"COMPLETE"
,
// TODO
L1Token
:
TokenInfo
{
ChainId
:
1
,
Address
:
withdrawal
.
L2BridgeWithdrawal
.
TokenPair
.
L1
TokenAddress
.
String
(),
Address
:
withdrawal
.
L2BridgeWithdrawal
.
TokenPair
.
Remote
TokenAddress
.
String
(),
Name
:
"Example"
,
// TODO
Symbol
:
"EXAMPLE"
,
// TODO
Decimals
:
18
,
// TODO
...
...
@@ -83,7 +83,7 @@ func newWithdrawalResponse(withdrawals []*database.L2BridgeWithdrawalWithTransac
},
L2Token
:
TokenInfo
{
ChainId
:
10
,
Address
:
withdrawal
.
L2BridgeWithdrawal
.
TokenPair
.
L
2
TokenAddress
.
String
(),
Address
:
withdrawal
.
L2BridgeWithdrawal
.
TokenPair
.
L
ocal
TokenAddress
.
String
(),
Name
:
"Example"
,
// TODO
Symbol
:
"EXAMPLE"
,
// TODO
Decimals
:
18
,
// TODO
...
...
indexer/database/bridge_transactions.go
View file @
56aac2c7
...
...
@@ -26,19 +26,14 @@ type Transaction struct {
type
L1TransactionDeposit
struct
{
SourceHash
common
.
Hash
`gorm:"serializer:json;primaryKey"`
L2TransactionHash
common
.
Hash
`gorm:"serializer:json"`
InitiatedL1EventGUID
uuid
.
UUID
Version
U256
OpaqueData
hexutil
.
Bytes
`gorm:"serializer:json"`
Tx
Transaction
`gorm:"embedded"`
GasLimit
U256
}
type
L2TransactionWithdrawal
struct
{
WithdrawalHash
common
.
Hash
`gorm:"serializer:json;primaryKey"`
Nonce
U256
InitiatedL2EventGUID
uuid
.
UUID
...
...
indexer/database/bridge_transfers.go
View file @
56aac2c7
...
...
@@ -10,7 +10,7 @@ import (
)
var
(
ETHTokenPair
=
TokenPair
{
L
1TokenAddress
:
predeploys
.
LegacyERC20ETHAddr
,
L2
TokenAddress
:
predeploys
.
LegacyERC20ETHAddr
}
ETHTokenPair
=
TokenPair
{
L
ocalTokenAddress
:
predeploys
.
LegacyERC20ETHAddr
,
Remote
TokenAddress
:
predeploys
.
LegacyERC20ETHAddr
}
)
/**
...
...
@@ -18,8 +18,8 @@ var (
*/
type
TokenPair
struct
{
L
1TokenAddress
common
.
Address
`gorm:"serializer:json"`
L2
TokenAddress
common
.
Address
`gorm:"serializer:json"`
L
ocalTokenAddress
common
.
Address
`gorm:"serializer:json"`
Remote
TokenAddress
common
.
Address
`gorm:"serializer:json"`
}
type
BridgeTransfer
struct
{
...
...
indexer/e2e_tests/bridge_transactions_e2e_test.go
View file @
56aac2c7
...
...
@@ -59,9 +59,6 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
require
.
Equal
(
t
,
aliceAddr
,
deposit
.
Tx
.
ToAddress
)
require
.
ElementsMatch
(
t
,
calldata
,
deposit
.
Tx
.
Data
)
require
.
Equal
(
t
,
depositInfo
.
Version
.
Uint64
(),
deposit
.
Version
.
Int
.
Uint64
())
require
.
ElementsMatch
(
t
,
depositInfo
.
OpaqueData
,
deposit
.
OpaqueData
)
event
,
err
:=
testSuite
.
DB
.
ContractEvents
.
L1ContractEvent
(
deposit
.
InitiatedL1EventGUID
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
event
)
...
...
indexer/e2e_tests/bridge_transfers_e2e_test.go
View file @
56aac2c7
...
...
@@ -55,8 +55,8 @@ func TestE2EBridgeTransfersStandardBridgeETHDeposit(t *testing.T) {
deposit
:=
aliceDeposits
[
0
]
.
L1BridgeDeposit
require
.
Equal
(
t
,
depositInfo
.
DepositTx
.
SourceHash
,
deposit
.
TransactionSourceHash
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
L
1
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
L2
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
L
ocal
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
Remote
TokenAddress
)
require
.
Equal
(
t
,
big
.
NewInt
(
params
.
Ether
),
deposit
.
Tx
.
Amount
.
Int
)
require
.
Equal
(
t
,
aliceAddr
,
deposit
.
Tx
.
FromAddress
)
require
.
Equal
(
t
,
aliceAddr
,
deposit
.
Tx
.
ToAddress
)
...
...
@@ -114,8 +114,8 @@ func TestE2EBridgeTransfersOptimismPortalETHReceive(t *testing.T) {
deposit
:=
aliceDeposits
[
0
]
.
L1BridgeDeposit
require
.
Equal
(
t
,
depositInfo
.
DepositTx
.
SourceHash
,
deposit
.
TransactionSourceHash
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
L
1
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
L2
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
L
ocal
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
deposit
.
TokenPair
.
Remote
TokenAddress
)
require
.
Equal
(
t
,
big
.
NewInt
(
params
.
Ether
),
deposit
.
Tx
.
Amount
.
Int
)
require
.
Equal
(
t
,
aliceAddr
,
deposit
.
Tx
.
FromAddress
)
require
.
Equal
(
t
,
aliceAddr
,
deposit
.
Tx
.
ToAddress
)
...
...
@@ -185,8 +185,8 @@ func TestE2EBridgeTransfersStandardBridgeETHWithdrawal(t *testing.T) {
withdrawal
:=
aliceWithdrawals
[
0
]
.
L2BridgeWithdrawal
require
.
Equal
(
t
,
withdrawalHash
,
withdrawal
.
TransactionWithdrawalHash
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
L
1
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
L2
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
L
ocal
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
Remote
TokenAddress
)
require
.
Equal
(
t
,
big
.
NewInt
(
params
.
Ether
),
withdrawal
.
Tx
.
Amount
.
Int
)
require
.
Equal
(
t
,
aliceAddr
,
withdrawal
.
Tx
.
FromAddress
)
require
.
Equal
(
t
,
aliceAddr
,
withdrawal
.
Tx
.
ToAddress
)
...
...
@@ -268,8 +268,8 @@ func TestE2EBridgeTransfersL2ToL1MessagePasserReceive(t *testing.T) {
withdrawal
:=
aliceWithdrawals
[
0
]
.
L2BridgeWithdrawal
require
.
Equal
(
t
,
withdrawalHash
,
withdrawal
.
TransactionWithdrawalHash
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
L
1
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
L2
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
L
ocal
TokenAddress
)
require
.
Equal
(
t
,
predeploys
.
LegacyERC20ETHAddr
,
withdrawal
.
TokenPair
.
Remote
TokenAddress
)
require
.
Equal
(
t
,
big
.
NewInt
(
params
.
Ether
),
withdrawal
.
Tx
.
Amount
.
Int
)
require
.
Equal
(
t
,
aliceAddr
,
withdrawal
.
Tx
.
FromAddress
)
require
.
Equal
(
t
,
aliceAddr
,
withdrawal
.
Tx
.
ToAddress
)
...
...
indexer/processor/l1_processor.go
View file @
56aac2c7
...
...
@@ -249,8 +249,6 @@ func l1ProcessContractEventsBridgeTransactions(processLog log.Logger, db *databa
SourceHash
:
depositTx
.
SourceHash
,
L2TransactionHash
:
types
.
NewTx
(
depositTx
)
.
Hash
(),
InitiatedL1EventGUID
:
depositEvent
.
Event
.
GUID
,
Version
:
database
.
U256
{
Int
:
depositEvent
.
Version
},
OpaqueData
:
depositEvent
.
OpaqueData
,
GasLimit
:
database
.
U256
{
Int
:
new
(
big
.
Int
)
.
SetUint64
(
depositTx
.
Gas
)},
Tx
:
database
.
Transaction
{
FromAddress
:
depositTx
.
From
,
...
...
@@ -465,7 +463,7 @@ func l1ProcessContractEventsStandardBridge(processLog log.Logger, db *database.D
BridgeTransfer
:
database
.
BridgeTransfer
{
CrossDomainMessageHash
:
&
initiatedBridgeEvent
.
CrossDomainMessageHash
,
// TODO index the tokens pairs if they don't exist
TokenPair
:
database
.
TokenPair
{
L
1TokenAddress
:
initiatedBridgeEvent
.
LocalToken
,
L2
TokenAddress
:
initiatedBridgeEvent
.
RemoteToken
},
TokenPair
:
database
.
TokenPair
{
L
ocalTokenAddress
:
initiatedBridgeEvent
.
LocalToken
,
Remote
TokenAddress
:
initiatedBridgeEvent
.
RemoteToken
},
Tx
:
database
.
Transaction
{
FromAddress
:
initiatedBridgeEvent
.
From
,
ToAddress
:
initiatedBridgeEvent
.
To
,
...
...
@@ -506,7 +504,7 @@ func l1ProcessContractEventsStandardBridge(processLog log.Logger, db *database.D
// sanity check on the bridge fields
if
finalizedWithdrawalEvent
.
From
!=
withdrawal
.
Tx
.
FromAddress
||
finalizedWithdrawalEvent
.
To
!=
withdrawal
.
Tx
.
ToAddress
||
finalizedWithdrawalEvent
.
Amount
.
Cmp
(
withdrawal
.
Tx
.
Amount
.
Int
)
!=
0
||
!
bytes
.
Equal
(
finalizedWithdrawalEvent
.
ExtraData
,
withdrawal
.
Tx
.
Data
)
||
finalizedWithdrawalEvent
.
LocalToken
!=
withdrawal
.
TokenPair
.
L
1TokenAddress
||
finalizedWithdrawalEvent
.
RemoteToken
!=
withdrawal
.
TokenPair
.
L2
TokenAddress
{
finalizedWithdrawalEvent
.
LocalToken
!=
withdrawal
.
TokenPair
.
L
ocalTokenAddress
||
finalizedWithdrawalEvent
.
RemoteToken
!=
withdrawal
.
TokenPair
.
Remote
TokenAddress
{
processLog
.
Crit
(
"bridge finalization fields mismatch with initiated fields!"
,
"tx_withdrawal_hash"
,
withdrawal
.
TransactionWithdrawalHash
,
"cross_domain_message_hash"
,
withdrawal
.
CrossDomainMessageHash
)
}
}
...
...
indexer/processor/l2_processor.go
View file @
56aac2c7
...
...
@@ -355,7 +355,7 @@ func l2ProcessContractEventsStandardBridge(processLog log.Logger, db *database.D
TransactionWithdrawalHash
:
msgPassedEvent
.
WithdrawalHash
,
BridgeTransfer
:
database
.
BridgeTransfer
{
CrossDomainMessageHash
:
&
initiatedBridgeEvent
.
CrossDomainMessageHash
,
TokenPair
:
database
.
TokenPair
{
L
1TokenAddress
:
initiatedBridgeEvent
.
LocalToken
,
L2
TokenAddress
:
initiatedBridgeEvent
.
RemoteToken
},
TokenPair
:
database
.
TokenPair
{
L
ocalTokenAddress
:
initiatedBridgeEvent
.
LocalToken
,
Remote
TokenAddress
:
initiatedBridgeEvent
.
RemoteToken
},
Tx
:
database
.
Transaction
{
FromAddress
:
initiatedBridgeEvent
.
From
,
ToAddress
:
initiatedBridgeEvent
.
To
,
...
...
@@ -398,7 +398,7 @@ func l2ProcessContractEventsStandardBridge(processLog log.Logger, db *database.D
// sanity check on the bridge fields
if
finalizedDepositEvent
.
From
!=
deposit
.
Tx
.
FromAddress
||
finalizedDepositEvent
.
To
!=
deposit
.
Tx
.
ToAddress
||
finalizedDepositEvent
.
Amount
.
Cmp
(
deposit
.
Tx
.
Amount
.
Int
)
!=
0
||
!
bytes
.
Equal
(
finalizedDepositEvent
.
ExtraData
,
deposit
.
Tx
.
Data
)
||
finalizedDepositEvent
.
LocalToken
!=
deposit
.
TokenPair
.
L
1TokenAddress
||
finalizedDepositEvent
.
RemoteToken
!=
deposit
.
TokenPair
.
L2
TokenAddress
{
finalizedDepositEvent
.
LocalToken
!=
deposit
.
TokenPair
.
L
ocalTokenAddress
||
finalizedDepositEvent
.
RemoteToken
!=
deposit
.
TokenPair
.
Remote
TokenAddress
{
processLog
.
Error
(
"bridge finalization fields mismatch with initiated fields!"
,
"tx_source_hash"
,
deposit
.
TransactionSourceHash
,
"cross_domain_message_hash"
,
deposit
.
CrossDomainMessageHash
)
return
errors
.
New
(
"bridge tx mismatch"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment