Commit 63adcd53 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into jg/blocktime_test

parents f78901da ea396762
...@@ -84,7 +84,7 @@ func NewBatchSubmitter(cfg Config, l log.Logger) (*BatchSubmitter, error) { ...@@ -84,7 +84,7 @@ func NewBatchSubmitter(cfg Config, l log.Logger) (*BatchSubmitter, error) {
signer := func(chainID *big.Int) SignerFn { signer := func(chainID *big.Int) SignerFn {
s := types.LatestSignerForChainID(chainID) s := types.LatestSignerForChainID(chainID)
return func(rawTx types.TxData) (*types.Transaction, error) { return func(_ context.Context, rawTx types.TxData) (*types.Transaction, error) {
return types.SignNewTx(sequencerPrivKey, s, rawTx) return types.SignNewTx(sequencerPrivKey, s, rawTx)
} }
} }
......
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
const networkTimeout = 2 * time.Second // How long a single network request can take. TODO: put in a config somewhere const networkTimeout = 2 * time.Second // How long a single network request can take. TODO: put in a config somewhere
type SignerFn func(rawTx types.TxData) (*types.Transaction, error) type SignerFn func(ctx context.Context, rawTx types.TxData) (*types.Transaction, error)
// TransactionManager wraps the simple txmgr package to make it easy to send & wait for transactions // TransactionManager wraps the simple txmgr package to make it easy to send & wait for transactions
type TransactionManager struct { type TransactionManager struct {
...@@ -121,7 +121,7 @@ func (t *TransactionManager) CraftTx(ctx context.Context, data []byte) (*types.T ...@@ -121,7 +121,7 @@ func (t *TransactionManager) CraftTx(ctx context.Context, data []byte) (*types.T
} }
rawTx.Gas = gas rawTx.Gas = gas
return t.signerFn(rawTx) return t.signerFn(ctx, rawTx)
} }
// UpdateGasPrice signs an otherwise identical txn to the one provided but with // UpdateGasPrice signs an otherwise identical txn to the one provided but with
...@@ -146,5 +146,5 @@ func (t *TransactionManager) UpdateGasPrice(ctx context.Context, tx *types.Trans ...@@ -146,5 +146,5 @@ func (t *TransactionManager) UpdateGasPrice(ctx context.Context, tx *types.Trans
// Only log the new tip/fee cap because the updateGasPrice closure reuses the same initial transaction // Only log the new tip/fee cap because the updateGasPrice closure reuses the same initial transaction
t.log.Trace("updating gas price", "tip_cap", gasTipCap, "fee_cap", gasFeeCap) t.log.Trace("updating gas price", "tip_cap", gasTipCap, "fee_cap", gasFeeCap)
return t.signerFn(rawTx) return t.signerFn(ctx, rawTx)
} }
package actions package actions
import ( import (
"context"
"crypto/ecdsa" "crypto/ecdsa"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -32,6 +34,7 @@ type L2Proposer struct { ...@@ -32,6 +34,7 @@ type L2Proposer struct {
func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Client, rollupCl *sources.RollupClient) *L2Proposer { func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Client, rollupCl *sources.RollupClient) *L2Proposer {
chainID, err := l1.ChainID(t.Ctx()) chainID, err := l1.ChainID(t.Ctx())
require.NoError(t, err) require.NoError(t, err)
signer := opcrypto.PrivateKeySignerFn(cfg.ProposerKey, chainID)
dr, err := proposer.NewDriver(proposer.DriverConfig{ dr, err := proposer.NewDriver(proposer.DriverConfig{
Log: log, Log: log,
Name: "proposer", Name: "proposer",
...@@ -40,7 +43,9 @@ func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Cl ...@@ -40,7 +43,9 @@ func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Cl
AllowNonFinalized: cfg.AllowNonFinalized, AllowNonFinalized: cfg.AllowNonFinalized,
L2OOAddr: cfg.OutputOracleAddr, L2OOAddr: cfg.OutputOracleAddr,
From: crypto.PubkeyToAddress(cfg.ProposerKey.PublicKey), From: crypto.PubkeyToAddress(cfg.ProposerKey.PublicKey),
SignerFn: opcrypto.PrivateKeySignerFn(cfg.ProposerKey, chainID), SignerFn: func(_ context.Context, addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
return signer(addr, tx)
},
}) })
require.NoError(t, err) require.NoError(t, err)
return &L2Proposer{ return &L2Proposer{
......
...@@ -22,6 +22,8 @@ import ( ...@@ -22,6 +22,8 @@ import (
var bigOne = big.NewInt(1) var bigOne = big.NewInt(1)
var supportedL2OutputVersion = eth.Bytes32{} var supportedL2OutputVersion = eth.Bytes32{}
type SignerFn func(context.Context, common.Address, *types.Transaction) (*types.Transaction, error)
type DriverConfig struct { type DriverConfig struct {
Log log.Logger Log log.Logger
Name string Name string
...@@ -44,7 +46,7 @@ type DriverConfig struct { ...@@ -44,7 +46,7 @@ type DriverConfig struct {
From common.Address From common.Address
// SignerFn is the function used to sign transactions // SignerFn is the function used to sign transactions
SignerFn bind.SignerFn SignerFn SignerFn
} }
type Driver struct { type Driver struct {
...@@ -182,8 +184,10 @@ func (d *Driver) CraftTx(ctx context.Context, start, end, nonce *big.Int) (*type ...@@ -182,8 +184,10 @@ func (d *Driver) CraftTx(ctx context.Context, start, end, nonce *big.Int) (*type
} }
opts := &bind.TransactOpts{ opts := &bind.TransactOpts{
From: d.cfg.From, From: d.cfg.From,
Signer: d.cfg.SignerFn, Signer: func(addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
return d.cfg.SignerFn(ctx, addr, tx)
},
Context: ctx, Context: ctx,
Nonce: nonce, Nonce: nonce,
NoSend: true, NoSend: true,
...@@ -225,8 +229,10 @@ func (d *Driver) CraftTx(ctx context.Context, start, end, nonce *big.Int) (*type ...@@ -225,8 +229,10 @@ func (d *Driver) CraftTx(ctx context.Context, start, end, nonce *big.Int) (*type
// NOTE: This method SHOULD NOT publish the resulting transaction. // NOTE: This method SHOULD NOT publish the resulting transaction.
func (d *Driver) UpdateGasPrice(ctx context.Context, tx *types.Transaction) (*types.Transaction, error) { func (d *Driver) UpdateGasPrice(ctx context.Context, tx *types.Transaction) (*types.Transaction, error) {
opts := &bind.TransactOpts{ opts := &bind.TransactOpts{
From: d.cfg.From, From: d.cfg.From,
Signer: d.cfg.SignerFn, Signer: func(addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
return d.cfg.SignerFn(ctx, addr, tx)
},
Context: ctx, Context: ctx,
Nonce: new(big.Int).SetUint64(tx.Nonce()), Nonce: new(big.Int).SetUint64(tx.Nonce()),
NoSend: true, NoSend: true,
......
...@@ -15,8 +15,8 @@ import ( ...@@ -15,8 +15,8 @@ import (
hdwallet "github.com/ethereum-optimism/go-ethereum-hdwallet" hdwallet "github.com/ethereum-optimism/go-ethereum-hdwallet"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -161,13 +161,16 @@ func NewL2OutputSubmitter( ...@@ -161,13 +161,16 @@ func NewL2OutputSubmitter(
} }
} }
signer := func(chainID *big.Int) bind.SignerFn { signer := func(chainID *big.Int) SignerFn {
return opcrypto.PrivateKeySignerFn(l2OutputPrivKey, chainID) s := opcrypto.PrivateKeySignerFn(l2OutputPrivKey, chainID)
return func(_ context.Context, addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
return s(addr, tx)
}
} }
return NewL2OutputSubmitterWithSigner(cfg, crypto.PubkeyToAddress(l2OutputPrivKey.PublicKey), signer, gitVersion, l) return NewL2OutputSubmitterWithSigner(cfg, crypto.PubkeyToAddress(l2OutputPrivKey.PublicKey), signer, gitVersion, l)
} }
type SignerFactory func(chainID *big.Int) bind.SignerFn type SignerFactory func(chainID *big.Int) SignerFn
func NewL2OutputSubmitterWithSigner( func NewL2OutputSubmitterWithSigner(
cfg Config, cfg Config,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment