Skip to content

Commit

Permalink
Remove dead signer code (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshklop authored Oct 23, 2024
1 parent 017951a commit 2f8bb43
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 239 deletions.
8 changes: 1 addition & 7 deletions adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@ import (
"fmt"

bfttypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
rolluptypes "github.com/polymerdao/monomer/x/rollup/types"
)

var PrivKey = secp256k1.GenPrivKeyFromSecret([]byte("monomer"))

var errL1AttributesNotFound = errors.New("L1 attributes tx not found")

type TxSigner func([]sdktypes.Msg) (bfttypes.Tx, error)

// AdaptPayloadTxsToCosmosTxs assumes the deposit transactions come first.
func AdaptPayloadTxsToCosmosTxs(ethTxs []hexutil.Bytes, _ TxSigner, _ string) (bfttypes.Txs, error) {
func AdaptPayloadTxsToCosmosTxs(ethTxs []hexutil.Bytes) (bfttypes.Txs, error) {
if len(ethTxs) == 0 {
return bfttypes.Txs{}, nil
}
Expand Down
5 changes: 0 additions & 5 deletions docs/docs/learn/deposits.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ In the `x/rollup` module, Monomer defines a custom Cosmos-SDK message type to ca
```go
// MsgApplyL1Txs defines the message for applying all L1 system and user deposit txs.
message MsgApplyL1Txs {
option (cosmos.msg.v1.signer) = "from_address";

// Array of bytes where each bytes is a eth.Transaction.MarshalBinary tx.
// The first tx must be the L1 system deposit tx, and the rest are user txs if present.
repeated bytes tx_bytes = 1;

// The cosmos address of the L1 system and user deposit tx signer.
string from_address = 2;
}
```

Expand Down
55 changes: 0 additions & 55 deletions e2e/mocks.go

This file was deleted.

14 changes: 0 additions & 14 deletions e2e/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"github.com/cometbft/cometbft/config"
bftclient "github.com/cometbft/cometbft/rpc/client/http"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
opbindings "github.com/ethereum-optimism/optimism/op-bindings/bindings"
opgenesis "github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
ope2econfig "github.com/ethereum-optimism/optimism/op-e2e/config"
Expand Down Expand Up @@ -265,17 +263,6 @@ func (s *stack) runMonomer(ctx context.Context, env *environment.Env, genesisTim
return fmt.Errorf("new test app: %v", err)
}

sdkclient, err := client.NewClientFromNode(s.monomerCometURL.String())
if err != nil {
return fmt.Errorf("new client from node: %v", err)
}
appchainCtx := client.Context{}.
WithChainID(chainID.String()).
WithClient(sdkclient).
WithAccountRetriever(mockAccountRetriever{}).
WithTxConfig(testutil.MakeTestTxConfig()).
WithCodec(testutil.MakeTestEncodingConfig().Codec)

blockPebbleDB, err := pebble.Open("", &pebble.Options{
FS: vfs.NewMem(),
})
Expand All @@ -294,7 +281,6 @@ func (s *stack) runMonomer(ctx context.Context, env *environment.Env, genesisTim
ethstatedb := state.NewDatabaseWithNodeDB(rawDB, trieDB)
n := node.New(
app,
&appchainCtx,
&genesis.Genesis{
AppState: app.DefaultGenesis(),
ChainID: chainID,
Expand Down
11 changes: 1 addition & 10 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import (
"time"

abci "github.com/cometbft/cometbft/abci/types"
appchainClient "github.com/cosmos/cosmos-sdk/client"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/polymerdao/monomer"
"github.com/polymerdao/monomer/builder"
"github.com/polymerdao/monomer/engine/signer"
"github.com/polymerdao/monomer/monomerdb"
)

Expand All @@ -32,7 +30,6 @@ type EngineAPI struct {
builder *builder.Builder
txValidator TxValidator
blockStore DB
signer *signer.Signer
currentPayloadAttributes *monomer.PayloadAttributes
metrics Metrics
lock sync.RWMutex
Expand All @@ -46,12 +43,10 @@ func NewEngineAPI(
b *builder.Builder,
txValidator TxValidator,
blockStore DB,
appchainCtx *appchainClient.Context,
metrics Metrics,
) *EngineAPI {
return &EngineAPI{
txValidator: txValidator,
signer: signer.New(appchainCtx, monomer.PrivKey),
blockStore: blockStore,
builder: b,
metrics: metrics,
Expand Down Expand Up @@ -178,11 +173,7 @@ func (e *EngineAPI) ForkchoiceUpdatedV3(
return nil, engine.InvalidPayloadAttributes.With(errors.New("gas limit not provided"))
}

cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs(
pa.Transactions,
e.signer.Sign,
e.signer.AccountAddress().String(),
)
cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs(pa.Transactions)
if err != nil {
return nil, engine.InvalidPayloadAttributes.With(fmt.Errorf("convert payload attributes txs to cosmos txs: %v", err))
}
Expand Down
110 changes: 0 additions & 110 deletions engine/signer/signer.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ require (
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.4.0
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/mod v0.18.0
golang.org/x/sync v0.7.0
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.2
Expand Down Expand Up @@ -312,6 +311,7 @@ require (
go.uber.org/zap v1.27.0 // indirect
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
Expand Down
1 change: 0 additions & 1 deletion integrations/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ func startMonomerNode(
}
n := node.New(
wrappedApp,
clientCtx,
&genesis.Genesis{
ChainID: monomer.ChainID(l2ChainID),
AppState: appState,
Expand Down
2 changes: 1 addition & 1 deletion mempool/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestMempool(t *testing.T) {
depositTxBytes, err := depositTx.MarshalBinary()
require.NoError(t, err)

cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs([]hexutil.Bytes{depositTxBytes}, nil, "")
cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs([]hexutil.Bytes{depositTxBytes})
require.NoError(t, err)
require.ErrorContains(t, pool.Enqueue(cosmosTxs[0]), "deposit txs are not allowed in the pool")
})
Expand Down
5 changes: 0 additions & 5 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
jsonrpctypes "github.com/cometbft/cometbft/rpc/jsonrpc/types"
bfttypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client"
opeth "github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
Expand Down Expand Up @@ -57,7 +56,6 @@ type DB interface {

type Node struct {
app monomer.Application
appchainCtx *client.Context
genesis *genesis.Genesis
engineWS net.Listener
cometHTTPAndWS net.Listener
Expand All @@ -71,7 +69,6 @@ type Node struct {

func New(
app monomer.Application,
appchainCtx *client.Context,
g *genesis.Genesis,
engineWS net.Listener,
cometHTTPAndWS net.Listener,
Expand All @@ -84,7 +81,6 @@ func New(
) *Node {
return &Node{
app: app,
appchainCtx: appchainCtx,
genesis: g,
engineWS: engineWS,
cometHTTPAndWS: cometHTTPAndWS,
Expand Down Expand Up @@ -124,7 +120,6 @@ func (n *Node) Run(ctx context.Context, env *environment.Env) error {
builder.New(mpool, n.app, n.blockdb, txStore, eventBus, n.genesis.ChainID, n.ethstatedb),
n.app,
n.blockdb,
n.appchainCtx,
engineMetrics,
),
},
Expand Down
1 change: 0 additions & 1 deletion node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func TestRun(t *testing.T) {
ethstatedb := testutils.NewEthStateDB(t)
n := node.New(
app,
nil,
&genesis.Genesis{
ChainID: chainID,
AppState: testapp.MakeGenesisAppState(t, app),
Expand Down
Loading

0 comments on commit 2f8bb43

Please sign in to comment.