Skip to content

Commit

Permalink
Merge branch 'btc-keysign-schedule' of https://github.com/zeta-chain/…
Browse files Browse the repository at this point in the history
…node into btc-keysign-schedule
  • Loading branch information
ws4charlie committed Sep 20, 2023
2 parents 85776b6 + f4610db commit 51c36c8
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 165 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ build-testnet-ubuntu: go.sum

install: go.sum
@echo "--> Installing zetacored & zetaclientd"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

install-zetaclient: go.sum
@echo "--> Installing zetaclientd"
Expand Down
6 changes: 4 additions & 2 deletions contrib/localnet/orchestrator/smoketest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) {
bankClient := banktypes.NewQueryClient(grpcConn)
observerClient := observertypes.NewQueryClient(grpcConn)

//Wait for Genesis
time.Sleep(20 * time.Second)

// initialize client to send messages to ZetaChain
zetaTxServer, err := NewZetaTxServer(
"http://zetacore0:26657",
Expand All @@ -158,8 +161,7 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) {
panic(err)
}

// Wait for Genesis and keygen to be completed. ~ height 30
time.Sleep(20 * time.Second)
//Wait for keygen to be completed. ~ height 30
for {
time.Sleep(5 * time.Second)
response, err := cctxClient.LastZetaHeight(context.Background(), &crosschaintypes.QueryLastZetaHeightRequest{})
Expand Down
129 changes: 62 additions & 67 deletions rpc/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,14 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"

"github.com/ethereum/go-ethereum/rpc"

ethermint "github.com/evmos/ethermint/types"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
"github.com/zeta-chain/zetacore/rpc/backend"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/debug"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/eth"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/eth/filters"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/miner"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/net"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/personal"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/txpool"
"github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/web3"

rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
)

// RPC namespaces and API version
Expand All @@ -47,8 +40,8 @@ const (

Web3Namespace = "web3"
EthNamespace = "eth"
PersonalNamespace = "personal"
NetNamespace = "net"
PersonalNamespace = "personal"
TxPoolNamespace = "txpool"
DebugNamespace = "debug"
MinerNamespace = "miner"
Expand Down Expand Up @@ -112,64 +105,66 @@ func init() {
},
}
},
PersonalNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
return []rpc.API{
{
Namespace: PersonalNamespace,
Version: apiVersion,
Service: personal.NewAPI(ctx.Logger, evmBackend),
Public: false,
},
}
},
TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API {
return []rpc.API{
{
Namespace: TxPoolNamespace,
Version: apiVersion,
Service: txpool.NewPublicAPI(ctx.Logger),
Public: true,
},
}
},
DebugNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
return []rpc.API{
{
Namespace: DebugNamespace,
Version: apiVersion,
Service: debug.NewAPI(ctx, evmBackend),
Public: true,
},
}
},
MinerNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
return []rpc.API{
{
Namespace: MinerNamespace,
Version: apiVersion,
Service: miner.NewPrivateAPI(ctx, evmBackend),
Public: false,
},
}
},
// Disabled
// NOTE: Public field of API is deprecated and defined only for compatibility.
//PersonalNamespace: func(ctx *server.Context,
// clientCtx client.Context,
// _ *rpcclient.WSClient,
// allowUnprotectedTxs bool,
// indexer ethermint.EVMTxIndexer,
//) []rpc.API {
// evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
// return []rpc.API{
// {
// Namespace: PersonalNamespace,
// Version: apiVersion,
// Service: personal.NewAPI(ctx.Logger, evmBackend),
// Public: false,
// },
// }
//},
//TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API {
// return []rpc.API{
// {
// Namespace: TxPoolNamespace,
// Version: apiVersion,
// Service: txpool.NewPublicAPI(ctx.Logger),
// Public: true,
// },
// }
//},
//DebugNamespace: func(ctx *server.Context,
// clientCtx client.Context,
// _ *rpcclient.WSClient,
// allowUnprotectedTxs bool,
// indexer ethermint.EVMTxIndexer,
//) []rpc.API {
// evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
// return []rpc.API{
// {
// Namespace: DebugNamespace,
// Version: apiVersion,
// Service: debug.NewAPI(ctx, evmBackend),
// Public: true,
// },
// }
//},
//MinerNamespace: func(ctx *server.Context,
// clientCtx client.Context,
// _ *rpcclient.WSClient,
// allowUnprotectedTxs bool,
// indexer ethermint.EVMTxIndexer,
//) []rpc.API {
// evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
// return []rpc.API{
// {
// Namespace: MinerNamespace,
// Version: apiVersion,
// Service: miner.NewPrivateAPI(ctx, evmBackend),
// Public: false,
// },
// }
//},
}
}

Expand Down
10 changes: 3 additions & 7 deletions rpc/namespaces/ethereum/debug/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ import (
"sync"
"time"

"github.com/davecgh/go-spew/spew"

evmtypes "github.com/evmos/ethermint/x/evm/types"

stderrors "github.com/pkg/errors"

"github.com/cosmos/cosmos-sdk/server"

"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/rlp"
evmtypes "github.com/evmos/ethermint/x/evm/types"
stderrors "github.com/pkg/errors"
"github.com/tendermint/tendermint/libs/log"
"github.com/zeta-chain/zetacore/rpc/backend"
rpctypes "github.com/zeta-chain/zetacore/rpc/types"
Expand Down
60 changes: 30 additions & 30 deletions rpc/namespaces/ethereum/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,14 @@ package eth
import (
"context"

"github.com/ethereum/go-ethereum/signer/core/apitypes"

"github.com/ethereum/go-ethereum/rpc"

"github.com/tendermint/tendermint/libs/log"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"

"github.com/zeta-chain/zetacore/rpc/backend"

"github.com/ethereum/go-ethereum/rpc"
ethermint "github.com/evmos/ethermint/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/zeta-chain/zetacore/rpc/backend"
rpctypes "github.com/zeta-chain/zetacore/rpc/types"
)

Expand Down Expand Up @@ -67,7 +61,6 @@ type EthereumAPI interface {
// Allows developers to both send ETH from one address to another, write data
// on-chain, and interact with smart contracts.
SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)
// eth_sendPrivateTransaction
// eth_cancel PrivateTransaction

Expand Down Expand Up @@ -111,9 +104,7 @@ type EthereumAPI interface {
// Other
Syncing() (interface{}, error)
Coinbase() (string, error)
Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)
SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)
FillTransaction(args evmtypes.TransactionArgs) (*rpctypes.SignTransactionResult, error)
Resend(ctx context.Context, args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error)
GetPendingTransactions() ([]*rpctypes.RPCTransaction, error)
Expand All @@ -125,6 +116,11 @@ type EthereumAPI interface {
// eth_getWork (on Ethereum.org)
// eth_submitWork (on Ethereum.org)
// eth_submitHashrate (on Ethereum.org)

// Disabled APIs for security reasons
//SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)
//Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
//SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)
}

var _ EthereumAPI = (*PublicAPI)(nil)
Expand Down Expand Up @@ -230,12 +226,6 @@ func (e *PublicAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
return e.backend.SendRawTransaction(data)
}

// SendTransaction sends an Ethereum transaction.
func (e *PublicAPI) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) {
e.logger.Debug("eth_sendTransaction", "args", args.String())
return e.backend.SendTransaction(args)
}

///////////////////////////////////////////////////////////////////////////////
/// Account Information ///
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -416,12 +406,6 @@ func (e *PublicAPI) Coinbase() (string, error) {
return ethAddr.Hex(), nil
}

// Sign signs the provided data using the private key of address via Geth's signature standard.
func (e *PublicAPI) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) {
e.logger.Debug("eth_sign", "address", address.Hex(), "data", common.Bytes2Hex(data))
return e.backend.Sign(address, data)
}

// GetTransactionLogs returns the logs given a transaction hash.
func (e *PublicAPI) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error) {
e.logger.Debug("eth_getTransactionLogs", "hash", txHash)
Expand All @@ -448,12 +432,6 @@ func (e *PublicAPI) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, err
return backend.TxLogsFromEvents(resBlockResult.TxsResults[res.TxIndex].Events, int(res.MsgIndex))
}

// SignTypedData signs EIP-712 conformant typed data
func (e *PublicAPI) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) {
e.logger.Debug("eth_signTypedData", "address", address.Hex(), "data", typedData)
return e.backend.SignTypedData(address, typedData)
}

// FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields)
// on a given unsigned transaction, and returns it to the caller for further
// processing (signing + broadcast).
Expand Down Expand Up @@ -527,3 +505,25 @@ func (e *PublicAPI) GetPendingTransactions() ([]*rpctypes.RPCTransaction, error)

return result, nil
}

///////////////////////////////////////////////////////////////////////////////
/// Disabled ///
///////////////////////////////////////////////////////////////////////////////

//// SendTransaction sends an Ethereum transaction.
//func (e *PublicAPI) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) {
// e.logger.Debug("eth_sendTransaction", "args", args.String())
// return e.backend.SendTransaction(args)
//}
//
//// Sign signs the provided data using the private key of address via Geth's signature standard.
//func (e *PublicAPI) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) {
// e.logger.Debug("eth_sign", "address", address.Hex(), "data", common.Bytes2Hex(data))
// return e.backend.Sign(address, data)
//}
//
//// SignTypedData signs EIP-712 conformant typed data
//func (e *PublicAPI) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) {
// e.logger.Debug("eth_signTypedData", "address", address.Hex(), "data", typedData)
// return e.backend.SignTypedData(address, typedData)
//}
14 changes: 5 additions & 9 deletions rpc/namespaces/ethereum/eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,16 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/client"
"github.com/zeta-chain/zetacore/rpc/types"

"github.com/tendermint/tendermint/libs/log"

coretypes "github.com/tendermint/tendermint/rpc/core/types"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/rpc"

evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/tendermint/tendermint/libs/log"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/zeta-chain/zetacore/rpc/types"
)

// FilterAPI gathers
Expand Down
16 changes: 6 additions & 10 deletions rpc/namespaces/ethereum/eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,19 @@ import (
"sync"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/rpc"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/pkg/errors"

tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/rpc"

sdk "github.com/cosmos/cosmos-sdk/types"

evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/zeta-chain/zetacore/rpc/ethereum/pubsub"
)

Expand Down
Loading

0 comments on commit 51c36c8

Please sign in to comment.