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
677bff37
Unverified
Commit
677bff37
authored
Jul 20, 2023
by
OptimismBot
Committed by
GitHub
Jul 20, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6370 from ethereum-optimism/refcell/txmgr-call
feat(op-service): TxManager Call Method
parents
8cf3f96f
c4f2ef45
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
0 deletions
+59
-0
responder_test.go
op-challenger/fault/responder_test.go
+5
-0
l2_proposer.go
op-e2e/actions/l2_proposer.go
+3
-0
TxManager.go
op-service/txmgr/mocks/TxManager.go
+29
-0
txmgr.go
op-service/txmgr/txmgr.go
+13
-0
txmgr_test.go
op-service/txmgr/txmgr_test.go
+9
-0
No files found.
op-challenger/fault/responder_test.go
View file @
677bff37
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
...
@@ -40,6 +41,10 @@ func (m *mockTxManager) Send(ctx context.Context, candidate txmgr.TxCandidate) (
...
@@ -40,6 +41,10 @@ func (m *mockTxManager) Send(ctx context.Context, candidate txmgr.TxCandidate) (
),
nil
),
nil
}
}
func
(
m
*
mockTxManager
)
Call
(
_
context
.
Context
,
_
ethereum
.
CallMsg
,
_
*
big
.
Int
)
([]
byte
,
error
)
{
panic
(
"unimplemented"
)
}
func
(
m
*
mockTxManager
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
func
(
m
*
mockTxManager
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
panic
(
"not implemented"
)
panic
(
"not implemented"
)
}
}
...
...
op-e2e/actions/l2_proposer.go
View file @
677bff37
...
@@ -44,6 +44,9 @@ type fakeTxMgr struct {
...
@@ -44,6 +44,9 @@ type fakeTxMgr struct {
func
(
f
fakeTxMgr
)
From
()
common
.
Address
{
func
(
f
fakeTxMgr
)
From
()
common
.
Address
{
return
f
.
from
return
f
.
from
}
}
func
(
f
fakeTxMgr
)
Call
(
_
context
.
Context
,
_
ethereum
.
CallMsg
,
_
*
big
.
Int
)
([]
byte
,
error
)
{
panic
(
"unimplemented"
)
}
func
(
f
fakeTxMgr
)
BlockNumber
(
_
context
.
Context
)
(
uint64
,
error
)
{
func
(
f
fakeTxMgr
)
BlockNumber
(
_
context
.
Context
)
(
uint64
,
error
)
{
panic
(
"unimplemented"
)
panic
(
"unimplemented"
)
}
}
...
...
op-service/txmgr/mocks/TxManager.go
View file @
677bff37
...
@@ -4,9 +4,12 @@ package mocks
...
@@ -4,9 +4,12 @@ package mocks
import
(
import
(
context
"context"
context
"context"
big
"math/big"
common
"github.com/ethereum/go-ethereum/common"
common
"github.com/ethereum/go-ethereum/common"
ethereum
"github.com/ethereum/go-ethereum"
mock
"github.com/stretchr/testify/mock"
mock
"github.com/stretchr/testify/mock"
txmgr
"github.com/ethereum-optimism/optimism/op-service/txmgr"
txmgr
"github.com/ethereum-optimism/optimism/op-service/txmgr"
...
@@ -43,6 +46,32 @@ func (_m *TxManager) BlockNumber(ctx context.Context) (uint64, error) {
...
@@ -43,6 +46,32 @@ func (_m *TxManager) BlockNumber(ctx context.Context) (uint64, error) {
return
r0
,
r1
return
r0
,
r1
}
}
// Call provides a mock function with given fields: ctx, msg, blockNumber
func
(
_m
*
TxManager
)
Call
(
ctx
context
.
Context
,
msg
ethereum
.
CallMsg
,
blockNumber
*
big
.
Int
)
([]
byte
,
error
)
{
ret
:=
_m
.
Called
(
ctx
,
msg
,
blockNumber
)
var
r0
[]
byte
var
r1
error
if
rf
,
ok
:=
ret
.
Get
(
0
)
.
(
func
(
context
.
Context
,
ethereum
.
CallMsg
,
*
big
.
Int
)
([]
byte
,
error
));
ok
{
return
rf
(
ctx
,
msg
,
blockNumber
)
}
if
rf
,
ok
:=
ret
.
Get
(
0
)
.
(
func
(
context
.
Context
,
ethereum
.
CallMsg
,
*
big
.
Int
)
[]
byte
);
ok
{
r0
=
rf
(
ctx
,
msg
,
blockNumber
)
}
else
{
if
ret
.
Get
(
0
)
!=
nil
{
r0
=
ret
.
Get
(
0
)
.
([]
byte
)
}
}
if
rf
,
ok
:=
ret
.
Get
(
1
)
.
(
func
(
context
.
Context
,
ethereum
.
CallMsg
,
*
big
.
Int
)
error
);
ok
{
r1
=
rf
(
ctx
,
msg
,
blockNumber
)
}
else
{
r1
=
ret
.
Error
(
1
)
}
return
r0
,
r1
}
// From provides a mock function with given fields:
// From provides a mock function with given fields:
func
(
_m
*
TxManager
)
From
()
common
.
Address
{
func
(
_m
*
TxManager
)
From
()
common
.
Address
{
ret
:=
_m
.
Called
()
ret
:=
_m
.
Called
()
...
...
op-service/txmgr/txmgr.go
View file @
677bff37
...
@@ -45,6 +45,10 @@ type TxManager interface {
...
@@ -45,6 +45,10 @@ type TxManager interface {
// NOTE: Send can be called concurrently, the nonce will be managed internally.
// NOTE: Send can be called concurrently, the nonce will be managed internally.
Send
(
ctx
context
.
Context
,
candidate
TxCandidate
)
(
*
types
.
Receipt
,
error
)
Send
(
ctx
context
.
Context
,
candidate
TxCandidate
)
(
*
types
.
Receipt
,
error
)
// Call is used to call a contract.
// Internally, it uses the [ethclient.Client.CallContract] method.
Call
(
ctx
context
.
Context
,
msg
ethereum
.
CallMsg
,
blockNumber
*
big
.
Int
)
([]
byte
,
error
)
// From returns the sending address associated with the instance of the transaction manager.
// From returns the sending address associated with the instance of the transaction manager.
// It is static for a single instance of a TxManager.
// It is static for a single instance of a TxManager.
From
()
common
.
Address
From
()
common
.
Address
...
@@ -59,6 +63,9 @@ type ETHBackend interface {
...
@@ -59,6 +63,9 @@ type ETHBackend interface {
// BlockNumber returns the most recent block number.
// BlockNumber returns the most recent block number.
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
// CallContract executes an eth_call against the provided contract.
CallContract
(
ctx
context
.
Context
,
msg
ethereum
.
CallMsg
,
blockNumber
*
big
.
Int
)
([]
byte
,
error
)
// TransactionReceipt queries the backend for a receipt associated with
// TransactionReceipt queries the backend for a receipt associated with
// txHash. If lookup does not fail, but the transaction is not found,
// txHash. If lookup does not fail, but the transaction is not found,
// nil should be returned for both values.
// nil should be returned for both values.
...
@@ -155,6 +162,12 @@ func (m *SimpleTxManager) Send(ctx context.Context, candidate TxCandidate) (*typ
...
@@ -155,6 +162,12 @@ func (m *SimpleTxManager) Send(ctx context.Context, candidate TxCandidate) (*typ
return
receipt
,
err
return
receipt
,
err
}
}
// Call is used to call a contract.
// Internally, it uses the [ethclient.Client.CallContract] method.
func
(
m
*
SimpleTxManager
)
Call
(
ctx
context
.
Context
,
msg
ethereum
.
CallMsg
,
blockNumber
*
big
.
Int
)
([]
byte
,
error
)
{
return
m
.
backend
.
CallContract
(
ctx
,
msg
,
blockNumber
)
}
// send performs the actual transaction creation and sending.
// send performs the actual transaction creation and sending.
func
(
m
*
SimpleTxManager
)
send
(
ctx
context
.
Context
,
candidate
TxCandidate
)
(
*
types
.
Receipt
,
error
)
{
func
(
m
*
SimpleTxManager
)
send
(
ctx
context
.
Context
,
candidate
TxCandidate
)
(
*
types
.
Receipt
,
error
)
{
if
m
.
cfg
.
TxSendTimeout
!=
0
{
if
m
.
cfg
.
TxSendTimeout
!=
0
{
...
...
op-service/txmgr/txmgr_test.go
View file @
677bff37
...
@@ -194,6 +194,11 @@ func (b *mockBackend) BlockNumber(ctx context.Context) (uint64, error) {
...
@@ -194,6 +194,11 @@ func (b *mockBackend) BlockNumber(ctx context.Context) (uint64, error) {
return
b
.
blockHeight
,
nil
return
b
.
blockHeight
,
nil
}
}
// Call mocks a call to the EVM.
func
(
b
*
mockBackend
)
CallContract
(
ctx
context
.
Context
,
call
ethereum
.
CallMsg
,
blockNumber
*
big
.
Int
)
([]
byte
,
error
)
{
return
nil
,
nil
}
func
(
b
*
mockBackend
)
HeaderByNumber
(
ctx
context
.
Context
,
number
*
big
.
Int
)
(
*
types
.
Header
,
error
)
{
func
(
b
*
mockBackend
)
HeaderByNumber
(
ctx
context
.
Context
,
number
*
big
.
Int
)
(
*
types
.
Header
,
error
)
{
return
&
types
.
Header
{
return
&
types
.
Header
{
BaseFee
:
b
.
g
.
basefee
(),
BaseFee
:
b
.
g
.
basefee
(),
...
@@ -649,6 +654,10 @@ func (b *failingBackend) HeaderByNumber(_ context.Context, _ *big.Int) (*types.H
...
@@ -649,6 +654,10 @@ func (b *failingBackend) HeaderByNumber(_ context.Context, _ *big.Int) (*types.H
},
nil
},
nil
}
}
func
(
b
*
failingBackend
)
CallContract
(
_
context
.
Context
,
_
ethereum
.
CallMsg
,
_
*
big
.
Int
)
([]
byte
,
error
)
{
return
nil
,
errors
.
New
(
"unimplemented"
)
}
func
(
b
*
failingBackend
)
SendTransaction
(
_
context
.
Context
,
_
*
types
.
Transaction
)
error
{
func
(
b
*
failingBackend
)
SendTransaction
(
_
context
.
Context
,
_
*
types
.
Transaction
)
error
{
return
errors
.
New
(
"unimplemented"
)
return
errors
.
New
(
"unimplemented"
)
}
}
...
...
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