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
96292c7f
Commit
96292c7f
authored
Jul 12, 2023
by
Felipe Andrade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
round trip receipt
parent
676efd21
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
11 deletions
+57
-11
config.go
op-ufm/pkg/config/config.go
+26
-10
handlers.go
op-ufm/pkg/provider/handlers.go
+31
-1
No files found.
op-ufm/pkg/config/config.go
View file @
96292c7f
...
@@ -38,10 +38,9 @@ type HealthzConfig struct {
...
@@ -38,10 +38,9 @@ type HealthzConfig struct {
}
}
type
WalletConfig
struct
{
type
WalletConfig
struct
{
// default: 420 (Optimism Goerli)
ChainID
big
.
Int
`toml:"chain_id"`
ChainID
big
.
Int
`toml:"chain_id"`
// signer | static
, default: signer
// signer | static
SignerMethod
string
`toml:"signer_method"`
SignerMethod
string
`toml:"signer_method"`
Address
string
`toml:"address"`
Address
string
`toml:"address"`
// private key is used for static signing
// private key is used for static signing
...
@@ -57,10 +56,12 @@ type WalletConfig struct {
...
@@ -57,10 +56,12 @@ type WalletConfig struct {
type
ProviderConfig
struct
{
type
ProviderConfig
struct
{
Disabled
bool
`toml:"disabled"`
Disabled
bool
`toml:"disabled"`
URL
string
`toml:"url"`
URL
string
`toml:"url"`
Wallet
string
`toml:"wallet"`
ReadOnly
bool
`toml:"read_only"`
ReadOnly
bool
`toml:"read_only"`
ReadInterval
TOMLDuration
`toml:"read_interval"`
ReadInterval
TOMLDuration
`toml:"read_interval"`
SendInterval
TOMLDuration
`toml:"send_interval"`
SendInterval
TOMLDuration
`toml:"send_interval"`
Wallet
string
`toml:"wallet"`
ReceiptRetrievalInterval
TOMLDuration
`toml:"receipt_retrieval_interval"`
ReceiptRetrievalTimeout
TOMLDuration
`toml:"receipt_retrieval_timeout"`
}
}
func
New
(
file
string
)
(
*
Config
,
error
)
{
func
New
(
file
string
)
(
*
Config
,
error
)
{
...
@@ -120,6 +121,15 @@ func (c *Config) Validate() error {
...
@@ -120,6 +121,15 @@ func (c *Config) Validate() error {
if
wallet
.
Address
==
""
{
if
wallet
.
Address
==
""
{
return
errors
.
Errorf
(
"wallet [%s] address is missing"
,
name
)
return
errors
.
Errorf
(
"wallet [%s] address is missing"
,
name
)
}
}
if
wallet
.
TxValue
.
BitLen
()
==
0
{
return
errors
.
Errorf
(
"wallet [%s] tx_value is missing"
,
name
)
}
if
wallet
.
GasLimit
==
0
{
return
errors
.
Errorf
(
"wallet [%s] gas_limit is missing"
,
name
)
}
if
wallet
.
GasFeeCap
.
BitLen
()
==
0
{
return
errors
.
Errorf
(
"wallet [%s] gas_fee_cap is missing"
,
name
)
}
}
}
for
name
,
provider
:=
range
c
.
Providers
{
for
name
,
provider
:=
range
c
.
Providers
{
...
@@ -127,14 +137,20 @@ func (c *Config) Validate() error {
...
@@ -127,14 +137,20 @@ func (c *Config) Validate() error {
return
errors
.
Errorf
(
"provider [%s] url is missing"
,
name
)
return
errors
.
Errorf
(
"provider [%s] url is missing"
,
name
)
}
}
if
provider
.
ReadInterval
==
0
{
if
provider
.
ReadInterval
==
0
{
return
errors
.
Errorf
(
"provider [%s] read
interval is missing"
,
name
)
return
errors
.
Errorf
(
"provider [%s] read
_
interval is missing"
,
name
)
}
}
if
provider
.
SendInterval
==
0
{
if
provider
.
SendInterval
==
0
{
return
errors
.
Errorf
(
"provider [%s] send
interval is missing"
,
name
)
return
errors
.
Errorf
(
"provider [%s] send
_
interval is missing"
,
name
)
}
}
if
provider
.
Wallet
==
""
{
if
provider
.
Wallet
==
""
{
return
errors
.
Errorf
(
"provider [%s] wallet is missing"
,
name
)
return
errors
.
Errorf
(
"provider [%s] wallet is missing"
,
name
)
}
}
if
provider
.
SendInterval
==
0
{
return
errors
.
Errorf
(
"provider [%s] receipt_retrieval_interval is missing"
,
name
)
}
if
provider
.
SendInterval
==
0
{
return
errors
.
Errorf
(
"provider [%s] receipt_retrieval_timeout is missing"
,
name
)
}
if
_
,
ok
:=
c
.
Wallets
[
provider
.
Wallet
];
!
ok
{
if
_
,
ok
:=
c
.
Wallets
[
provider
.
Wallet
];
!
ok
{
return
errors
.
Errorf
(
"provider [%s] has an invalid wallet [%s]"
,
name
,
provider
.
Wallet
)
return
errors
.
Errorf
(
"provider [%s] has an invalid wallet [%s]"
,
name
,
provider
.
Wallet
)
}
}
...
...
op-ufm/pkg/provider/handlers.go
View file @
96292c7f
...
@@ -2,9 +2,11 @@ package provider
...
@@ -2,9 +2,11 @@ package provider
import
(
import
(
"context"
"context"
"time"
"github.com/ethereum-optimism/optimism/op-service/tls"
"github.com/ethereum-optimism/optimism/op-service/tls"
signer
"github.com/ethereum-optimism/optimism/op-signer/client"
signer
"github.com/ethereum-optimism/optimism/op-signer/client"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
...
@@ -39,7 +41,35 @@ func (p *Provider) Heartbeat(ctx context.Context) {
...
@@ -39,7 +41,35 @@ func (p *Provider) Heartbeat(ctx context.Context) {
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"cant send transaction"
,
"provider"
,
p
.
name
,
"err"
,
err
)
log
.
Error
(
"cant send transaction"
,
"provider"
,
p
.
name
,
"err"
,
err
)
}
}
log
.
Info
(
"transaction sent"
,
"hash"
,
signedTx
.
Hash
()
.
Hex
())
txHash
:=
signedTx
.
Hash
()
log
.
Info
(
"transaction sent"
,
"hash"
,
txHash
.
Hex
())
sentAt
:=
time
.
Now
()
var
receipt
*
types
.
Receipt
attempt
:=
0
for
receipt
==
nil
{
if
time
.
Since
(
sentAt
)
>=
time
.
Duration
(
p
.
config
.
ReceiptRetrievalTimeout
)
{
log
.
Error
(
"receipt retrieval timedout"
,
"provider"
,
p
.
name
,
"hash"
,
"ellapsed"
,
time
.
Since
(
sentAt
))
break
}
time
.
Sleep
(
time
.
Duration
(
p
.
config
.
ReceiptRetrievalInterval
))
if
attempt
%
10
==
0
{
log
.
Debug
(
"checking for receipt..."
,
"attempt"
,
attempt
,
"ellapsed"
,
time
.
Since
(
sentAt
))
}
receipt
,
err
=
ethClient
.
TransactionReceipt
(
ctx
,
txHash
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
ethereum
.
NotFound
)
{
log
.
Error
(
"cant get receipt for transaction"
,
"provider"
,
p
.
name
,
"hash"
,
txHash
.
Hex
(),
"err"
,
err
)
break
}
attempt
++
}
roundtrip
:=
time
.
Since
(
sentAt
)
log
.
Info
(
"got transaction receipt"
,
"hash"
,
txHash
.
Hex
(),
"roundtrip"
,
roundtrip
,
"blockNumber"
,
receipt
.
BlockNumber
,
"blockHash"
,
receipt
.
BlockHash
,
"gasUsed"
,
receipt
.
GasUsed
)
}
}
func
(
p
*
Provider
)
dial
(
ctx
context
.
Context
)
(
*
ethclient
.
Client
,
error
)
{
func
(
p
*
Provider
)
dial
(
ctx
context
.
Context
)
(
*
ethclient
.
Client
,
error
)
{
...
...
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