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
f3be6521
Commit
f3be6521
authored
Jul 10, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address some ci issues
parent
a217c500
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
47 deletions
+52
-47
api_test.go
indexer/api/api_test.go
+45
-2
bridge.go
indexer/database/bridge.go
+3
-3
contract_events.go
indexer/processor/contract_events.go
+2
-40
standard_bridge.go
indexer/processor/standard_bridge.go
+2
-2
No files found.
indexer/api/api_test.go
View file @
f3be6521
package
api
package
api
import
(
import
(
"math/big"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
"testing"
"testing"
...
@@ -25,7 +26,7 @@ func (mbv *MockBridgeView) DepositsByAddress(address common.Address) ([]*databas
...
@@ -25,7 +26,7 @@ func (mbv *MockBridgeView) DepositsByAddress(address common.Address) ([]*databas
{
{
Deposit
:
database
.
Deposit
{
Deposit
:
database
.
Deposit
{
GUID
:
uuid
.
MustParse
(
guid1
),
GUID
:
uuid
.
MustParse
(
guid1
),
InitiatedL1EventGUID
:
guid2
,
InitiatedL1EventGUID
:
uuid
.
MustParse
(
guid2
)
,
Tx
:
database
.
Transaction
{},
Tx
:
database
.
Transaction
{},
TokenPair
:
database
.
TokenPair
{},
TokenPair
:
database
.
TokenPair
{},
},
},
...
@@ -34,13 +35,28 @@ func (mbv *MockBridgeView) DepositsByAddress(address common.Address) ([]*databas
...
@@ -34,13 +35,28 @@ func (mbv *MockBridgeView) DepositsByAddress(address common.Address) ([]*databas
},
nil
},
nil
}
}
// DepositsByAddress mocks returning deposits by an address
func
(
mbv
*
MockBridgeView
)
DepositByMessageNonce
(
nonce
*
big
.
Int
)
(
*
database
.
Deposit
,
error
)
{
return
&
database
.
Deposit
{
GUID
:
uuid
.
MustParse
(
guid1
),
InitiatedL1EventGUID
:
uuid
.
MustParse
(
guid2
),
Tx
:
database
.
Transaction
{},
TokenPair
:
database
.
TokenPair
{},
},
nil
}
// LatestDepositMessageNonce mocks returning the latest cross domain message nonce for a deposit
func
(
mbv
*
MockBridgeView
)
LatestDepositMessageNonce
()
(
*
big
.
Int
,
error
)
{
return
big
.
NewInt
(
0
),
nil
}
// WithdrawalsByAddress mocks returning withdrawals by an address
// WithdrawalsByAddress mocks returning withdrawals by an address
func
(
mbv
*
MockBridgeView
)
WithdrawalsByAddress
(
address
common
.
Address
)
([]
*
database
.
WithdrawalWithTransactionHashes
,
error
)
{
func
(
mbv
*
MockBridgeView
)
WithdrawalsByAddress
(
address
common
.
Address
)
([]
*
database
.
WithdrawalWithTransactionHashes
,
error
)
{
return
[]
*
database
.
WithdrawalWithTransactionHashes
{
return
[]
*
database
.
WithdrawalWithTransactionHashes
{
{
{
Withdrawal
:
database
.
Withdrawal
{
Withdrawal
:
database
.
Withdrawal
{
GUID
:
uuid
.
MustParse
(
guid2
),
GUID
:
uuid
.
MustParse
(
guid2
),
InitiatedL2EventGUID
:
guid1
,
InitiatedL2EventGUID
:
uuid
.
MustParse
(
guid1
)
,
WithdrawalHash
:
common
.
HexToHash
(
"0x456"
),
WithdrawalHash
:
common
.
HexToHash
(
"0x456"
),
Tx
:
database
.
Transaction
{},
Tx
:
database
.
Transaction
{},
TokenPair
:
database
.
TokenPair
{},
TokenPair
:
database
.
TokenPair
{},
...
@@ -50,6 +66,33 @@ func (mbv *MockBridgeView) WithdrawalsByAddress(address common.Address) ([]*data
...
@@ -50,6 +66,33 @@ func (mbv *MockBridgeView) WithdrawalsByAddress(address common.Address) ([]*data
},
nil
},
nil
}
}
// WithdrawalsByMessageNonce mocks returning withdrawals by a withdrawal hash
func
(
mbv
*
MockBridgeView
)
WithdrawalByMessageNonce
(
nonce
*
big
.
Int
)
(
*
database
.
Withdrawal
,
error
)
{
return
&
database
.
Withdrawal
{
GUID
:
uuid
.
MustParse
(
guid2
),
InitiatedL2EventGUID
:
uuid
.
MustParse
(
guid1
),
WithdrawalHash
:
common
.
HexToHash
(
"0x456"
),
Tx
:
database
.
Transaction
{},
TokenPair
:
database
.
TokenPair
{},
},
nil
}
// WithdrawalsByHash mocks returning withdrawals by a withdrawal hash
func
(
mbv
*
MockBridgeView
)
WithdrawalByHash
(
address
common
.
Hash
)
(
*
database
.
Withdrawal
,
error
)
{
return
&
database
.
Withdrawal
{
GUID
:
uuid
.
MustParse
(
guid2
),
InitiatedL2EventGUID
:
uuid
.
MustParse
(
guid1
),
WithdrawalHash
:
common
.
HexToHash
(
"0x456"
),
Tx
:
database
.
Transaction
{},
TokenPair
:
database
.
TokenPair
{},
},
nil
}
// LatestWithdrawalMessageNonce mocks returning the latest cross domain message nonce for a withdrawal
func
(
mbv
*
MockBridgeView
)
LatestWithdrawalMessageNonce
()
(
*
big
.
Int
,
error
)
{
return
big
.
NewInt
(
0
),
nil
}
func
TestHealthz
(
t
*
testing
.
T
)
{
func
TestHealthz
(
t
*
testing
.
T
)
{
api
:=
NewApi
(
&
MockBridgeView
{})
api
:=
NewApi
(
&
MockBridgeView
{})
request
,
err
:=
http
.
NewRequest
(
"GET"
,
"/healthz"
,
nil
)
request
,
err
:=
http
.
NewRequest
(
"GET"
,
"/healthz"
,
nil
)
...
...
indexer/database/bridge.go
View file @
f3be6521
...
@@ -38,7 +38,7 @@ type Deposit struct {
...
@@ -38,7 +38,7 @@ type Deposit struct {
// the message nonce serves as a unique identifier for this
// the message nonce serves as a unique identifier for this
// deposit. Once this generalizes to more than 1 deployed
// deposit. Once this generalizes to more than 1 deployed
// bridge, we need to include the `CrossDomainMessenger` address
// bridge, we need to include the `CrossDomainMessenger` address
// such that the (messenger_addr, nonce) is the unique identifer
// such that the (messenger_addr, nonce) is the unique identif
i
er
// for a bridge msg
// for a bridge msg
SentMessageNonce
U256
SentMessageNonce
U256
...
@@ -61,7 +61,7 @@ type Withdrawal struct {
...
@@ -61,7 +61,7 @@ type Withdrawal struct {
// the message nonce serves as a unique identifier for this
// the message nonce serves as a unique identifier for this
// withdrawal. Once this generalizes to more than 1 deployed
// withdrawal. Once this generalizes to more than 1 deployed
// bridge, we need to include the `CrossDomainMessenger` address
// bridge, we need to include the `CrossDomainMessenger` address
// such that the (messenger_addr, nonce) is the unique identifer
// such that the (messenger_addr, nonce) is the unique identif
i
er
// for a bridge msg
// for a bridge msg
SentMessageNonce
U256
SentMessageNonce
U256
...
@@ -209,7 +209,7 @@ func (db *bridgeDB) MarkFinalizedWithdrawalEvent(guid, finalizedL1EventGuid uuid
...
@@ -209,7 +209,7 @@ func (db *bridgeDB) MarkFinalizedWithdrawalEvent(guid, finalizedL1EventGuid uuid
}
}
if
withdrawal
.
ProvenL1EventGUID
==
nil
{
if
withdrawal
.
ProvenL1EventGUID
==
nil
{
return
errors
.
New
(
fmt
.
Sprintf
(
"withdrawal %s marked finalized prior to being proven"
,
guid
)
)
return
fmt
.
Errorf
(
"withdrawal %s marked finalized prior to being proven"
,
guid
)
}
}
withdrawal
.
FinalizedL1EventGUID
=
&
finalizedL1EventGuid
withdrawal
.
FinalizedL1EventGUID
=
&
finalizedL1EventGuid
...
...
indexer/processor/contract_events.go
View file @
f3be6521
...
@@ -45,48 +45,10 @@ func (p *ProcessedContractEvents) AddLog(log *types.Log, time uint64) *database.
...
@@ -45,48 +45,10 @@ func (p *ProcessedContractEvents) AddLog(log *types.Log, time uint64) *database.
return
&
contractEvent
return
&
contractEvent
}
}
func
DecodeFromProcessedContractEvents
[
ABI
any
](
p
*
ProcessedContractEvents
,
name
string
,
contractAbi
*
abi
.
ABI
)
([]
*
ABI
,
error
)
{
eventAbi
,
ok
:=
contractAbi
.
Events
[
name
]
if
!
ok
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"event %s not present in supplied ABI"
,
name
))
}
decodedEvents
:=
[]
*
ABI
{}
for
_
,
event
:=
range
p
.
eventsBySignature
[
eventAbi
.
ID
]
{
log
:=
p
.
eventLog
[
event
.
GUID
]
var
decodedEvent
ABI
err
:=
contractAbi
.
UnpackIntoInterface
(
&
decodedEvent
,
name
,
log
.
Data
)
if
err
!=
nil
{
return
nil
,
err
}
// handle topics if present
if
len
(
log
.
Topics
)
>
1
{
var
indexedArgs
abi
.
Arguments
for
_
,
arg
:=
range
eventAbi
.
Inputs
{
if
arg
.
Indexed
{
indexedArgs
=
append
(
indexedArgs
,
arg
)
}
}
// The first topic (event signature) is ommitted
err
:=
abi
.
ParseTopics
(
&
decodedEvent
,
indexedArgs
,
log
.
Topics
[
1
:
])
if
err
!=
nil
{
return
nil
,
err
}
}
decodedEvents
=
append
(
decodedEvents
,
&
decodedEvent
)
}
return
decodedEvents
,
nil
}
func
UnpackLog
(
out
interface
{},
log
*
types
.
Log
,
name
string
,
contractAbi
*
abi
.
ABI
)
error
{
func
UnpackLog
(
out
interface
{},
log
*
types
.
Log
,
name
string
,
contractAbi
*
abi
.
ABI
)
error
{
eventAbi
,
ok
:=
contractAbi
.
Events
[
name
]
eventAbi
,
ok
:=
contractAbi
.
Events
[
name
]
if
!
ok
{
if
!
ok
{
return
errors
.
New
(
fmt
.
Sprintf
(
"event %s not present in supplied ABI"
,
name
)
)
return
fmt
.
Errorf
(
"event %s not present in supplied ABI"
,
name
)
}
else
if
len
(
log
.
Topics
)
==
0
{
}
else
if
len
(
log
.
Topics
)
==
0
{
return
errors
.
New
(
"anonymous events are not supported"
)
return
errors
.
New
(
"anonymous events are not supported"
)
}
else
if
log
.
Topics
[
0
]
!=
eventAbi
.
ID
{
}
else
if
log
.
Topics
[
0
]
!=
eventAbi
.
ID
{
...
@@ -107,7 +69,7 @@ func UnpackLog(out interface{}, log *types.Log, name string, contractAbi *abi.AB
...
@@ -107,7 +69,7 @@ func UnpackLog(out interface{}, log *types.Log, name string, contractAbi *abi.AB
}
}
}
}
// The first topic (event signature) is om
m
itted
// The first topic (event signature) is omitted
err
:=
abi
.
ParseTopics
(
out
,
indexedArgs
,
log
.
Topics
[
1
:
])
err
:=
abi
.
ParseTopics
(
out
,
indexedArgs
,
log
.
Topics
[
1
:
])
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
indexer/processor/standard_bridge.go
View file @
f3be6521
...
@@ -18,7 +18,7 @@ var (
...
@@ -18,7 +18,7 @@ var (
)
)
type
StandardBridgeInitiatedEvent
struct
{
type
StandardBridgeInitiatedEvent
struct
{
// We hardcode to ERC20 since ETH can be ps
ue
do-represented as an ERC20 utilizing
// We hardcode to ERC20 since ETH can be ps
eu
do-represented as an ERC20 utilizing
// the hardcoded ETH address
// the hardcoded ETH address
*
bindings
.
L1StandardBridgeERC20BridgeInitiated
*
bindings
.
L1StandardBridgeERC20BridgeInitiated
...
@@ -27,7 +27,7 @@ type StandardBridgeInitiatedEvent struct {
...
@@ -27,7 +27,7 @@ type StandardBridgeInitiatedEvent struct {
}
}
type
StandardBridgeFinalizedEvent
struct
{
type
StandardBridgeFinalizedEvent
struct
{
// We hardcode to ERC20 since ETH can be ps
ue
do-represented as an ERC20 utilizing
// We hardcode to ERC20 since ETH can be ps
eu
do-represented as an ERC20 utilizing
// the hardcoded ETH address
// the hardcoded ETH address
*
bindings
.
L1StandardBridgeERC20BridgeFinalized
*
bindings
.
L1StandardBridgeERC20BridgeFinalized
...
...
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