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
4cc418b1
Unverified
Commit
4cc418b1
authored
Aug 16, 2023
by
mergify[bot]
Committed by
GitHub
Aug 16, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feat/systemconfig-redeploy
parents
9efc5b8e
5ef43aab
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
26 additions
and
40 deletions
+26
-40
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
20230523_create_schema.sql
indexer/migrations/20230523_create_schema.sql
+4
-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 @
4cc418b1
...
...
@@ -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 @
4cc418b1
...
...
@@ -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 @
4cc418b1
...
...
@@ -24,21 +24,16 @@ type Transaction struct {
}
type
L1TransactionDeposit
struct
{
SourceHash
common
.
Hash
`gorm:"serializer:json;primaryKey"`
L2TransactionHash
common
.
Hash
`gorm:"serializer:json"`
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"`
WithdrawalHash
common
.
Hash
`gorm:"serializer:json;primaryKey"`
Nonce
U256
InitiatedL2EventGUID
uuid
.
UUID
...
...
indexer/database/bridge_transfers.go
View file @
4cc418b1
...
...
@@ -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 @
4cc418b1
...
...
@@ -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 @
4cc418b1
...
...
@@ -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/migrations/20230523_create_schema.sql
View file @
4cc418b1
...
...
@@ -116,10 +116,6 @@ CREATE TABLE IF NOT EXISTS l1_transaction_deposits (
initiated_l1_event_guid
VARCHAR
NOT
NULL
REFERENCES
l1_contract_events
(
guid
),
-- OptimismPortal specific
version
UINT256
NOT
NULL
,
opaque_data
VARCHAR
NOT
NULL
,
-- transaction data
from_address
VARCHAR
NOT
NULL
,
to_address
VARCHAR
NOT
NULL
,
...
...
@@ -197,8 +193,8 @@ CREATE TABLE IF NOT EXISTS l1_bridge_deposits (
-- Deposit information
from_address
VARCHAR
NOT
NULL
,
to_address
VARCHAR
NOT
NULL
,
l1
_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l1_tokens(address), uncomment me in future pr
l2
_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l2_tokens(address), uncomment me in future pr
local
_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l1_tokens(address), uncomment me in future pr
remote
_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l2_tokens(address), uncomment me in future pr
amount
UINT256
NOT
NULL
,
data
VARCHAR
NOT
NULL
,
timestamp
INTEGER
NOT
NULL
CHECK
(
timestamp
>
0
)
...
...
@@ -213,8 +209,8 @@ CREATE TABLE IF NOT EXISTS l2_bridge_withdrawals (
-- Withdrawal information
from_address
VARCHAR
NOT
NULL
,
to_address
VARCHAR
NOT
NULL
,
l1_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l1
_tokens(address), uncomment me in future pr
l2_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l2
_tokens(address), uncomment me in future pr
local_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l2
_tokens(address), uncomment me in future pr
remote_token_address
VARCHAR
NOT
NULL
,
-- REFERENCES l1
_tokens(address), uncomment me in future pr
amount
UINT256
NOT
NULL
,
data
VARCHAR
NOT
NULL
,
timestamp
INTEGER
NOT
NULL
CHECK
(
timestamp
>
0
)
...
...
indexer/processor/l1_processor.go
View file @
4cc418b1
...
...
@@ -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 @
4cc418b1
...
...
@@ -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