diff --git a/docs/concepts/token.md b/docs/concepts/token.md index d7b2b73a0..18f1076b0 100644 --- a/docs/concepts/token.md +++ b/docs/concepts/token.md @@ -10,14 +10,14 @@ order: 4 Plug Chain is a Cosmos SDK based chain with full PVM support. Due to this architecture, tokens and assets in the network may come from different independent sources: bank module, token module, evm module. `bank module, token module tokens belong to the PRC-10 protocol`, `pvm module belongs to the PRC-20 protocol`. -##PLUGCN +## PC -The `plugcn` token belongs to the native token of the bank module, which can be used for pledge, IBC transfer, community governance, handling fee, etc. +The `pc` token belongs to the native token of the bank module, which can be used for pledge, IBC transfer, community governance, handling fee, etc. ## PRC-10 PRC-10 is a token built into the Plug Chain public chain. PRC-10 is a technical token standard supported by the Plug Chain blockchain itself. It does not use a PVM virtual machine. In the Plug Chain network, each account can pass [`x/prc10`](../cli-client/token.md) module issues PRC-10 tokens. Users can lock their tokens individually. To issue tokens, the issuer needs to specify the token name, total size, precision, description, etc. -Tokens `plugcn`, `dhw1`, `kingdm`, `joey`, etc. belong to PRC-10 protocol tokens +Tokens `pc`, `dhw1`, `kingdm`, `joey`, etc. belong to PRC-10 protocol tokens ## PRC-20 diff --git a/docs/concepts/validator-faq.md b/docs/concepts/validator-faq.md index d6a361144..c6fe6fdfd 100644 --- a/docs/concepts/validator-faq.md +++ b/docs/concepts/validator-faq.md @@ -99,7 +99,7 @@ Self-delegation is delegation from a validator to himself. This amount can be in ### Is there a minimum amount of plugchaind that must be delegated to be an active (=bonded) validator -The minimum mortgage `1plugcn`, on the chain is `1*10^6 uplugcn`, you can create a validator, but whether you can become an active validator depends on whether the number of your mortgage (including delegated) exceeds the 100th validator. +The minimum mortgage `1pc`, on the chain is `1*10^6 uplugcn`, you can create a validator, but whether you can become an active validator depends on whether the number of your mortgage (including delegated) exceeds the 100th validator. ### Can a validator run away with their delegators' funds diff --git a/docs/daemon/local-testnet.md b/docs/daemon/local-testnet.md index f8353f616..21ac8981c 100644 --- a/docs/daemon/local-testnet.md +++ b/docs/daemon/local-testnet.md @@ -62,10 +62,10 @@ plugchaind collect-gentxs ### plugchaind start -Change the default token denom to `plugcn` +Change the default token denom to `pc` ```bash -sed -i 's/stake/plugcn/g' $HOME/.plugchain/config/genesis.json +sed -i 's/stake/pc/g' $HOME/.plugchain/config/genesis.json ``` Now it‘s ready to start `plugchaind` diff --git a/docs/get-started/intro.md b/docs/get-started/intro.md index 0dfc5773c..8b4ff7466 100644 --- a/docs/get-started/intro.md +++ b/docs/get-started/intro.md @@ -20,12 +20,12 @@ Client-facing, programming language specific SDKs will also be available to make ## Plug Chain Token -The *Plug Chain* hub has its own native token, called *plugcn* , which has three roles in the network. +The *Plug Chain* hub has its own native token, called *pc* , which has three roles in the network. -** Mortgage. ** Similar to the ATOM token in the Cosmos Hub, the *plugcn* token will be used as a collateral token to protect the safe operation of the PoS blockchain. +** Mortgage. ** Similar to the ATOM token in the Cosmos Hub, the *pc* token will be used as a collateral token to protect the safe operation of the PoS blockchain. -* **transaction fee. ** *plugcn* tokens will also be used to pay for all transactions in the *Plug Chain* network. +* **transaction fee. ** *pc* tokens will also be used to pay for all transactions in the *Plug Chain* network. -**Service charge. ** Service providers in the *Plug Chain* network need to charge service fees in units of *plugcn* tokens. +**Service charge. ** Service providers in the *Plug Chain* network need to charge service fees in units of *pc* tokens. The *Plug Chain* network will eventually support all whitelisted fee tokens, which can be used to pay transaction fees and service fees. diff --git a/docs/pvm/cosmoswap.md b/docs/pvm/cosmoswap.md index df8a5f48e..25e4402af 100644 --- a/docs/pvm/cosmoswap.md +++ b/docs/pvm/cosmoswap.md @@ -33,7 +33,7 @@ Parameter Description: | token | address | Token contract address | | amountTokenDesired | uint256 | Amount of tokens injected into the pool | | amountTokenMin | uint256 | The minimum number of tokens to withdraw from the pool, the minimum value can be 0 | -| amountPLUGMin | uint256 | The minimum amount of `plugcn` in the pool, the minimum can be filled in 0 | +| amountPLUGMin | uint256 | The minimum amount of `pc` in the pool, the minimum can be filled in 0 | | to | address | LP output address, usually from address | | deadline | uint256 | UTC time zone timestamp must be greater than current time | diff --git a/docs/zh/concepts/token.md b/docs/zh/concepts/token.md index 0f85a7ec7..397de44c4 100644 --- a/docs/zh/concepts/token.md +++ b/docs/zh/concepts/token.md @@ -14,12 +14,12 @@ Plug Chain 是一个基于 Cosmos SDK 的链,具有完整的 PVM 支持。由 在 Plug Chain 上用于质押、治理和 gas 消耗的面额是PLUGCN. PLUGCN提供以下效用:保护权益证明链、用于治理提案的代币、费用分配以及作为在 PVM 上运行智能合约的气体手段。 -$$ 1 plugcn = 1 ~ * ~ 10^{6} uplugcn $$ +$$ 1 pc = 1 ~ * ~ 10^{6} uplugcn $$ ## PRC-10 PRC-10是一种是通过 Plug Chain 公链内置的通证。 PRC-10是 Plug Chain 区块链本身支持的技术代币标准,没有使用PVM虚拟机, 在 Plug Chain 网络中,每个帐户都能够通过[`x/prc10`](../cli-client/token.md)模块发行PRC-10代币。 用户可以单独锁定其代币。 要发放代币,发行者需要指定代币名称、总大小、精度、描述、等信息。 -代币 `plugcn`,`dhw1`,`kingdm`,`joey`等都属于 PRC-10 协议代币 +代币 `pc`,`dhw1`,`kingdm`,`joey`等都属于 PRC-10 协议代币 ## PRC-20 diff --git a/docs/zh/concepts/validator-faq.md b/docs/zh/concepts/validator-faq.md index 1d3fe98ba..5aade2f35 100644 --- a/docs/zh/concepts/validator-faq.md +++ b/docs/zh/concepts/validator-faq.md @@ -92,7 +92,7 @@ order: 10 ### 想要成为活跃的验证人最少要抵押多少plug -最低抵押 `1plugcn`,链上为 `1*10^6 uplugcn` 即可创建验证人,但能否成为活跃的验证人取决于您的抵押(包括受委托)数量是否超过第100名验证人。 +最低抵押 `1pc`,链上为 `1*10^6 uplugcn` 即可创建验证人,但能否成为活跃的验证人取决于您的抵押(包括受委托)数量是否超过第100名验证人。 ### 验证人可以卷走委托人的资金吗 diff --git a/docs/zh/daemon/local-testnet.md b/docs/zh/daemon/local-testnet.md index a989c2708..398c7826d 100644 --- a/docs/zh/daemon/local-testnet.md +++ b/docs/zh/daemon/local-testnet.md @@ -62,10 +62,10 @@ plugchaind collect-gentxs ### plugchaind start -修改默认token为 `plugcn` +修改默认token为 `pc` ```bash -sed -i 's/stake/plugcn/g' $HOME/.plugchain/config/genesis.json +sed -i 's/stake/pc/g' $HOME/.plugchain/config/genesis.json ``` 现在可以启动 `plugchaind` 了 diff --git a/docs/zh/features/distribution.md b/docs/zh/features/distribution.md index 0dddfbbf6..b19e22ed9 100644 --- a/docs/zh/features/distribution.md +++ b/docs/zh/features/distribution.md @@ -10,7 +10,7 @@ ### 收益的来源 1. 交易所产生的交易费 `fees`(由交易的第一个签名者支付`fees`) -2. 通胀的代币 `plugcn`(目前Plug Chain系统设置的通胀为13%每年,通证总量为`20亿`) +2. 通胀的代币 `pc`(目前Plug Chain系统设置的通胀为13%每年,通证总量为`20亿`) ### 收益的去向 diff --git a/docs/zh/features/governance.md b/docs/zh/features/governance.md index 41c8e3216..381a68ef9 100644 --- a/docs/zh/features/governance.md +++ b/docs/zh/features/governance.md @@ -10,7 +10,7 @@ - **投票:** - 一旦抵押数量达到某个特定值(`最小抵押`),提议将被确认,对该提议的投票也将开启。之后,质押的 plugcn 持有者可以发送 `TxGovVote` 交易对此提议进行投票。 + 一旦抵押数量达到某个特定值(`最小抵押`),提议将被确认,对该提议的投票也将开启。之后,质押的 pc 持有者可以发送 `TxGovVote` 交易对此提议进行投票。 - 当提议涉及软件升级时,流程请参考 [`Upgrade`](./upgrade.md) @@ -18,7 +18,7 @@ #### 提交提议的权利 -无论质押与否,任何 plugcn 持有者均可通过发送 `TxGovProposal` 交易来提交提议。一旦被提交,将生成一个唯一的 `proposalID` 来标识提议。 +无论质押与否,任何 pc 持有者均可通过发送 `TxGovProposal` 交易来提交提议。一旦被提交,将生成一个唯一的 `proposalID` 来标识提议。 #### 提议类型 @@ -54,15 +54,15 @@ #### 参与者 -_参与者_ 是对提议有投票权利的用户。在 Plug Chain Hub 上,参与者是质押的 plugcn 持有者。未质押的 plugcn 持有者和其他用户无权参与治理。但是他们能提交提议及抵押。 +_参与者_ 是对提议有投票权利的用户。在 Plug Chain Hub 上,参与者是质押的 pc 持有者。未质押的 pc 持有者和其他用户无权参与治理。但是他们能提交提议及抵押。 注意,对于一个特定的验证人,如果一些参与者满足以下条件,则这些参与者可以被禁止为一个提议投票: -- 在提议进入投票期后,参与者对该验证人质押或解质押 plugcn +- 在提议进入投票期后,参与者对该验证人质押或解质押 pc - 在提议进入投票期后,参与者成为验证人 -但是这不阻止参与者用质押到其他验证人的 plugcn 进行投票。例如,在一个提议进入投票期之前,参与者质押一些 plugcn 到验证人 A;在该提议进入投票期之后,质押另一些 plugcn 到验证人 B;则仅仅在验证人 B 下的投票将被禁止。 +但是这不阻止参与者用质押到其他验证人的 pc 进行投票。例如,在一个提议进入投票期之前,参与者质押一些 pc 到验证人 A;在该提议进入投票期之后,质押另一些 pc 到验证人 B;则仅仅在验证人 B 下的投票将被禁止。 #### 投票期 @@ -93,7 +93,7 @@ _注意: 在 UI 端,我们可以为一些紧急的提议增加一个 `Not Urge 阈值初始被设置为 50%,如果超过 1/3 的投票(排除 `弃权` 投票)是 `否决` 票,有一定的否决概率。这意味着在投票期结束时,如果 `赞成` 投票(排除 `弃权` 投票)的比例大于 50%,并且 `否决` 投票(排除 `弃权` 投票)的比例小于 1/3,则提议将被接受。 -在投票期结束之前,如果满足一个特殊条件,提议可以被接受。即,如果 `赞成` 投票与 `InitTotalVotingPower`(`初始总投票权`)的比例超过 2:3,提议将立即被接受,即使 `投票期` 还没结束。`初始总投票权` 是投票开启时所有质押的 plugcn 持有人的总投票权。这个条件存在以至于在紧急情况下网络可以快速做出反应。 +在投票期结束之前,如果满足一个特殊条件,提议可以被接受。即,如果 `赞成` 投票与 `InitTotalVotingPower`(`初始总投票权`)的比例超过 2:3,提议将立即被接受,即使 `投票期` 还没结束。`初始总投票权` 是投票开启时所有质押的 pc 持有人的总投票权。这个条件存在以至于在紧急情况下网络可以快速做出反应。 #### 继承 diff --git a/docs/zh/features/mint.md b/docs/zh/features/mint.md index 9718435d6..9c33aa67c 100644 --- a/docs/zh/features/mint.md +++ b/docs/zh/features/mint.md @@ -28,9 +28,9 @@ AnnualInflationAmount = inflationBasement * inflationRate blockInflationAmount = AnnualInflationAmount * blockCostTime / (year) ``` -`inflationBasement` 的值被定义在 genesis 文件中. 默认情况下,genesis 里面写入的值是 `15989000000uplugcn`(159.89亿个 plug,`1 plugcn` 等于 `1*10^6 uplugcn`)。 +`inflationBasement` 的值被定义在 genesis 文件中. 默认情况下,genesis 里面写入的值是 `15989000000uplugcn`(159.89亿个 plug,`1 pc` 等于 `1*10^6 uplugcn`)。 -假设 `blockCostTime` 是5000毫秒,通胀比例 `inflationRate` 是 `13%`,那么这个块增发的 token 数量是 `329000000uplugcn`(`329plugcn`) +假设 `blockCostTime` 是5000毫秒,通胀比例 `inflationRate` 是 `13%`,那么这个块增发的 token 数量是 `329000000uplugcn`(`329pc`) ## 对用户的影响 diff --git a/docs/zh/get-started/intro.md b/docs/zh/get-started/intro.md index b81dbdc04..75278f19e 100644 --- a/docs/zh/get-started/intro.md +++ b/docs/zh/get-started/intro.md @@ -21,13 +21,13 @@ order: 1 ## Plug Chain 通证 -*Plug Chain* 枢纽有自己的原生通证,称为 *plugcn* ,在网络中有三个作用。 +*Plug Chain* 枢纽有自己的原生通证,称为 *pc* ,在网络中有三个作用。 -* **抵押。** 与Cosmos Hub中的ATOM通证类似,*plugcn* 通证将用作抵押通证以保护PoS区块链的安全运行。 +* **抵押。** 与Cosmos Hub中的ATOM通证类似,*pc* 通证将用作抵押通证以保护PoS区块链的安全运行。 -* **交易费用。** *plugcn* 通证也将用于支付*Plug Chain* 网络中所有交易的费用。 +* **交易费用。** *pc* 通证也将用于支付*Plug Chain* 网络中所有交易的费用。 -* **服务费。** *Plug Chain* 网络中的服务提供者需要以*plugcn* 通证为单位收取服务费。 +* **服务费。** *Plug Chain* 网络中的服务提供者需要以*pc* 通证为单位收取服务费。 *Plug Chain* 网络最终将支持所有列入白名单的费用通证,它们可用于支付交易费用和服务费用。 diff --git a/docs/zh/pvm/cosmoswap.md b/docs/zh/pvm/cosmoswap.md index c3494bfbc..ebad364cd 100644 --- a/docs/zh/pvm/cosmoswap.md +++ b/docs/zh/pvm/cosmoswap.md @@ -34,7 +34,7 @@ addLiquidityPLUG(address token,uint256 amountTokenDesired,uint256 amountTokenMin | token | address | 代币合约地址 | | amountTokenDesired | uint256 | 注入池子token代币数量 | | amountTokenMin | uint256 | 最低提出池子token代币数量,最低可填写0 | -| amountPLUGMin | uint256 | 最低提出池子`plugcn`数量,最低可填写0 | +| amountPLUGMin | uint256 | 最低提出池子`pc`数量,最低可填写0 | | to | address | LP输出地址,一般为from地址 | | deadline | uint256 | UTC时区的时间戳 必须大于当前时间 | diff --git a/rpc/apis.go b/rpc/apis.go index f23376d44..c81de14c2 100644 --- a/rpc/apis.go +++ b/rpc/apis.go @@ -46,16 +46,21 @@ const ( ) // APICreator creates the JSON-RPC API implementations. -type APICreator = func(*server.Context, client.Context, *rpcclient.WSClient) []rpc.API +type APICreator = func( + ctx *server.Context, + clientCtx client.Context, + tendermintWebsocketClient *rpcclient.WSClient, + allowUnprotectedTxs bool, +) []rpc.API // apiCreators defines the JSON-RPC API namespaces. var apiCreators map[string]APICreator func init() { apiCreators = map[string]APICreator{ - EthNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient) []rpc.API { + EthNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API { nonceLock := new(types.AddrLocker) - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx) + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs) return []rpc.API{ { Namespace: EthNamespace, @@ -71,7 +76,7 @@ func init() { }, } }, - Web3Namespace: func(*server.Context, client.Context, *rpcclient.WSClient) []rpc.API { + Web3Namespace: func(*server.Context, client.Context, *rpcclient.WSClient, bool) []rpc.API { return []rpc.API{ { Namespace: Web3Namespace, @@ -81,7 +86,7 @@ func init() { }, } }, - NetNamespace: func(_ *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API { + NetNamespace: func(_ *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, _ bool) []rpc.API { return []rpc.API{ { Namespace: NetNamespace, @@ -91,8 +96,8 @@ func init() { }, } }, - PersonalNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API { - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx) + PersonalNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API { + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs) return []rpc.API{ { Namespace: PersonalNamespace, @@ -102,7 +107,7 @@ func init() { }, } }, - TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient) []rpc.API { + TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool) []rpc.API { return []rpc.API{ { Namespace: TxPoolNamespace, @@ -112,8 +117,8 @@ func init() { }, } }, - DebugNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API { - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx) + DebugNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API { + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs) return []rpc.API{ { Namespace: DebugNamespace, @@ -123,8 +128,8 @@ func init() { }, } }, - MinerNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API { - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx) + MinerNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API { + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs) return []rpc.API{ { Namespace: MinerNamespace, @@ -134,9 +139,9 @@ func init() { }, } }, - RPCNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient) []rpc.API { + RPCNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API { nonceLock := new(types.AddrLocker) - evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx) + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs) return []rpc.API{ { Namespace: RPCNamespace, @@ -150,12 +155,12 @@ func init() { } // GetRPCAPIs returns the list of all APIs -func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, selectedAPIs []string) []rpc.API { +func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool, selectedAPIs []string) []rpc.API { var apis []rpc.API for _, ns := range selectedAPIs { if creator, ok := apiCreators[ns]; ok { - apis = append(apis, creator(ctx, clientCtx, tmWSClient)...) + apis = append(apis, creator(ctx, clientCtx, tmWSClient, allowUnprotectedTxs)...) } else { ctx.Logger.Error("invalid namespace value", "namespace", ns) } diff --git a/rpc/backend/backend.go b/rpc/backend/backend.go index be8f5b78e..8aeafb7af 100644 --- a/rpc/backend/backend.go +++ b/rpc/backend/backend.go @@ -45,6 +45,7 @@ type EVMBackend interface { RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection RPCTxFeeCap() float64 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for send-transaction variants. The unit is ether. + UnprotectedAllowed() bool RPCMinGasPrice() int64 SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) @@ -86,16 +87,17 @@ var _ BackendI = (*Backend)(nil) // Backend implements the BackendI interface type Backend struct { - ctx context.Context - clientCtx client.Context - queryClient *types.QueryClient // gRPC query client - logger log.Logger - chainID *big.Int - cfg config.Config + ctx context.Context + clientCtx client.Context + queryClient *types.QueryClient // gRPC query client + logger log.Logger + chainID *big.Int + cfg config.Config + allowUnprotectedTxs bool } // NewBackend creates a new Backend instance for cosmos and ethereum namespaces -func NewBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context) *Backend { +func NewBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context, allowUnprotectedTxs bool) *Backend { chainID, err := ethermint.ParseChainID(clientCtx.ChainID) if err != nil { panic(err) @@ -104,11 +106,12 @@ func NewBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context appConf := config.GetConfig(ctx.Viper) return &Backend{ - ctx: context.Background(), - clientCtx: clientCtx, - queryClient: types.NewQueryClient(clientCtx), - logger: logger.With("module", "backend"), - chainID: chainID, - cfg: appConf, + ctx: context.Background(), + clientCtx: clientCtx, + queryClient: types.NewQueryClient(clientCtx), + logger: logger.With("module", "backend"), + chainID: chainID, + cfg: appConf, + allowUnprotectedTxs: allowUnprotectedTxs, } } diff --git a/rpc/backend/evm_backend.go b/rpc/backend/evm_backend.go index 972c2c5e9..6eeb492f2 100644 --- a/rpc/backend/evm_backend.go +++ b/rpc/backend/evm_backend.go @@ -744,7 +744,15 @@ func (b *Backend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, e return common.Hash{}, err } - txHash := msg.AsTransaction().Hash() + ethTx := msg.AsTransaction() + + // check the local node config in case unprotected txs are disabled + if !b.UnprotectedAllowed() && !ethTx.Protected() { + // Ensure only eip155 signed transactions are submitted if EIP155Required is set. + return common.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC") + } + + txHash := ethTx.Hash() // Broadcast transaction in sync mode (default) // NOTE: If error is encountered on the node, the broadcast will not return an error @@ -1051,3 +1059,9 @@ func (b *Backend) GetEthereumMsgsFromTendermintBlock(block *tmrpctypes.ResultBlo return result } + +// UnprotectedAllowed returns the node configuration value for allowing +// unprotected transactions (i.e not replay-protected) +func (b Backend) UnprotectedAllowed() bool { + return b.allowUnprotectedTxs +} diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index 31da50fa4..4865e20d5 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -504,6 +504,12 @@ func (e *PublicAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) return common.Hash{}, err } + // check the local node config in case unprotected txs are disabled + if !e.backend.UnprotectedAllowed() && !tx.Protected() { + // Ensure only eip155 signed transactions are submitted if EIP155Required is set. + return common.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC") + } + ethereumTx := &evmtypes.MsgEthereumTx{} if err := ethereumTx.FromEthereumTx(tx); err != nil { e.logger.Error("transaction converting failed", "error", err.Error()) diff --git a/rpc/namespaces/ethereum/eth/filters/filter_system.go b/rpc/namespaces/ethereum/eth/filters/filter_system.go index a990074e5..06642d972 100644 --- a/rpc/namespaces/ethereum/eth/filters/filter_system.go +++ b/rpc/namespaces/ethereum/eth/filters/filter_system.go @@ -22,8 +22,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/evmos/ethermint/rpc/ethereum/pubsub" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/oracleNetworkProtocol/plugchain/rpc/ethereum/pubsub" ) var ( diff --git a/rpc/namespaces/ethereum/miner/api.go b/rpc/namespaces/ethereum/miner/api.go index 1a873af4e..8cfef251f 100644 --- a/rpc/namespaces/ethereum/miner/api.go +++ b/rpc/namespaces/ethereum/miner/api.go @@ -21,9 +21,9 @@ import ( "github.com/tendermint/tendermint/libs/log" tmtypes "github.com/tendermint/tendermint/types" - "github.com/evmos/ethermint/server/config" "github.com/oracleNetworkProtocol/plugchain/rpc/backend" rpctypes "github.com/oracleNetworkProtocol/plugchain/rpc/types" + "github.com/oracleNetworkProtocol/plugchain/server/config" ) // API is the private miner prefixed set of APIs in the Miner JSON-RPC spec. diff --git a/rpc/websockets.go b/rpc/websockets.go index 44b90cb63..9efc1bd7e 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -26,11 +26,11 @@ import ( rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" tmtypes "github.com/tendermint/tendermint/types" - "github.com/evmos/ethermint/rpc/ethereum/pubsub" - rpcfilters "github.com/evmos/ethermint/rpc/namespaces/ethereum/eth/filters" - "github.com/evmos/ethermint/server/config" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/oracleNetworkProtocol/plugchain/rpc/ethereum/pubsub" + rpcfilters "github.com/oracleNetworkProtocol/plugchain/rpc/namespaces/ethereum/eth/filters" "github.com/oracleNetworkProtocol/plugchain/rpc/types" + "github.com/oracleNetworkProtocol/plugchain/server/config" ) type WebsocketsServer interface { diff --git a/scripts/setup-localnet.sh b/scripts/setup-localnet.sh index f08b9a055..73512de23 100755 --- a/scripts/setup-localnet.sh +++ b/scripts/setup-localnet.sh @@ -33,7 +33,7 @@ cat $NODEDIR/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["den cat $NODEDIR/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uplugcn"' > $NODEDIR/config/tmp_genesis.json && mv $NODEDIR/config/tmp_genesis.json $NODEDIR/config/genesis.json cat $NODEDIR/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uplugcn"' > $NODEDIR/config/tmp_genesis.json && mv $NODEDIR/config/tmp_genesis.json $NODEDIR/config/genesis.json cat $NODEDIR/config/genesis.json | jq '.app_state["evm"]["params"]["evm_denom"]="uplugcn"' > $NODEDIR/config/tmp_genesis.json && mv $NODEDIR/config/tmp_genesis.json $NODEDIR/config/genesis.json -# cat $NODEDIR/config/genesis.json | jq '.app_state["feemarket"]["params"]["initial_base_fee"]="1000"' > $NODEDIR/config/tmp_genesis.json && mv $NODEDIR/config/tmp_genesis.json $NODEDIR/config/genesis.json +cat $NODEDIR/config/genesis.json | jq '.app_state["feemarket"]["params"]["base_fee"]="7"' > $NODEDIR/config/tmp_genesis.json && mv $NODEDIR/config/tmp_genesis.json $NODEDIR/config/genesis.json cat $NODEDIR/config/genesis.json | jq '.app_state["liquidity"]["params"]["pool_creation_fee"][0]["denom"]="uplugcn"' > $NODEDIR/config/tmp_genesis.json && mv $NODEDIR/config/tmp_genesis.json $NODEDIR/config/genesis.json # disable produce empty block diff --git a/server/config/config.go b/server/config/config.go index ed0f463bd..3b0a7b2f2 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -47,6 +47,8 @@ const ( DefaultHTTPTimeout = 30 * time.Second DefaultHTTPIdleTimeout = 120 * time.Second + // DefaultAllowUnprotectedTxs value is false + DefaultAllowUnprotectedTxs = false ) var evmTracers = []string{"json", "markdown", "struct", "access_list"} @@ -98,6 +100,9 @@ type JSONRPCConfig struct { HTTPTimeout time.Duration `mapstructure:"http-timeout"` // HTTPIdleTimeout is the idle timeout of http json-rpc server. HTTPIdleTimeout time.Duration `mapstructure:"http-idle-timeout"` + // AllowUnprotectedTxs restricts unprotected (non EIP155 signed) transactions to be submitted via + // the node's RPC when global parameter is disabled. + AllowUnprotectedTxs bool `mapstructure:"allow-unprotected-txs"` } // TLSConfig defines the certificate and matching private key for the server. @@ -183,19 +188,20 @@ func GetAPINamespaces() []string { // DefaultJSONRPCConfig returns an EVM config with the JSON-RPC API enabled by default func DefaultJSONRPCConfig() *JSONRPCConfig { return &JSONRPCConfig{ - Enable: true, - API: GetDefaultAPINamespaces(), - Address: DefaultJSONRPCAddress, - WsAddress: DefaultJSONRPCWsAddress, - GasCap: DefaultGasCap, - EVMTimeout: DefaultEVMTimeout, - TxFeeCap: DefaultTxFeeCap, - FilterCap: DefaultFilterCap, - FeeHistoryCap: DefaultFeeHistoryCap, - BlockRangeCap: DefaultBlockRangeCap, - LogsCap: DefaultLogsCap, - HTTPTimeout: DefaultHTTPTimeout, - HTTPIdleTimeout: DefaultHTTPIdleTimeout, + Enable: true, + API: GetDefaultAPINamespaces(), + Address: DefaultJSONRPCAddress, + WsAddress: DefaultJSONRPCWsAddress, + GasCap: DefaultGasCap, + EVMTimeout: DefaultEVMTimeout, + TxFeeCap: DefaultTxFeeCap, + FilterCap: DefaultFilterCap, + FeeHistoryCap: DefaultFeeHistoryCap, + BlockRangeCap: DefaultBlockRangeCap, + LogsCap: DefaultLogsCap, + HTTPTimeout: DefaultHTTPTimeout, + HTTPIdleTimeout: DefaultHTTPIdleTimeout, + AllowUnprotectedTxs: DefaultAllowUnprotectedTxs, } } diff --git a/server/config/toml.go b/server/config/toml.go index cd4258f06..93d3285ad 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -62,6 +62,10 @@ http-timeout = "{{ .JSONRPC.HTTPTimeout }}" # HTTPIdleTimeout is the idle timeout of http json-rpc server. http-idle-timeout = "{{ .JSONRPC.HTTPIdleTimeout }}" +# AllowUnprotectedTxs restricts unprotected (non EIP155 signed) transactions to be submitted via +# the node's RPC when the global parameter is disabled. +allow-unprotected-txs = {{ .JSONRPC.AllowUnprotectedTxs }} + ############################################################################### ### TLS Configuration ### ############################################################################### diff --git a/server/flags/flags.go b/server/flags/flags.go index 53b7ced3a..dc98e86ad 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -32,18 +32,19 @@ const ( // JSON-RPC flags const ( - JSONRPCEnable = "json-rpc.enable" - JSONRPCAPI = "json-rpc.api" - JSONRPCAddress = "json-rpc.address" - JSONWsAddress = "json-rpc.ws-address" - JSONRPCGasCap = "json-rpc.gas-cap" - JSONRPCEVMTimeout = "json-rpc.evm-timeout" - JSONRPCTxFeeCap = "json-rpc.txfee-cap" - JSONRPCFilterCap = "json-rpc.filter-cap" - JSONRPCLogsCap = "json-rpc.logs-cap" - JSONRPCBlockRangeCap = "json-rpc.block-range-cap" - JSONRPCHTTPTimeout = "json-rpc.http-timeout" - JSONRPCHTTPIdleTimeout = "json-rpc.http-idle-timeout" + JSONRPCEnable = "json-rpc.enable" + JSONRPCAPI = "json-rpc.api" + JSONRPCAddress = "json-rpc.address" + JSONWsAddress = "json-rpc.ws-address" + JSONRPCGasCap = "json-rpc.gas-cap" + JSONRPCEVMTimeout = "json-rpc.evm-timeout" + JSONRPCTxFeeCap = "json-rpc.txfee-cap" + JSONRPCFilterCap = "json-rpc.filter-cap" + JSONRPCLogsCap = "json-rpc.logs-cap" + JSONRPCBlockRangeCap = "json-rpc.block-range-cap" + JSONRPCHTTPTimeout = "json-rpc.http-timeout" + JSONRPCHTTPIdleTimeout = "json-rpc.http-idle-timeout" + JSONRPCAllowUnprotectedTxs = "json-rpc.allow-unprotected-txs" ) // EVM flags diff --git a/server/json_rpc.go b/server/json_rpc.go index 1c8593d87..5ffb17daa 100644 --- a/server/json_rpc.go +++ b/server/json_rpc.go @@ -12,9 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/server/types" ethlog "github.com/ethereum/go-ethereum/log" ethrpc "github.com/ethereum/go-ethereum/rpc" - "github.com/evmos/ethermint/rpc" - "github.com/evmos/ethermint/server/config" + "github.com/oracleNetworkProtocol/plugchain/rpc" + + "github.com/oracleNetworkProtocol/plugchain/server/config" ) // StartJSONRPC starts the JSON-RPC server diff --git a/server/start.go b/server/start.go index 75282274a..e4df207a4 100644 --- a/server/start.go +++ b/server/start.go @@ -41,9 +41,9 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - ethdebug "github.com/evmos/ethermint/rpc/namespaces/ethereum/debug" - "github.com/evmos/ethermint/server/config" - srvflags "github.com/evmos/ethermint/server/flags" + ethdebug "github.com/oracleNetworkProtocol/plugchain/rpc/namespaces/ethereum/debug" + "github.com/oracleNetworkProtocol/plugchain/server/config" + srvflags "github.com/oracleNetworkProtocol/plugchain/server/flags" ) // StartCmd runs the service passed in, either stand-alone or in-process with @@ -130,7 +130,7 @@ which accepts a path for the resulting pprof file. cmd.Flags().String(srvflags.Address, "tcp://0.0.0.0:26658", "Listen address") cmd.Flags().String(srvflags.Transport, "socket", "Transport protocol: socket, grpc") cmd.Flags().String(srvflags.TraceStore, "", "Enable KVStore tracing to an output file") - cmd.Flags().String(server.FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 0.01photon;0.0001stake)") + cmd.Flags().String(server.FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g.0.001uplugcn)") cmd.Flags().IntSlice(server.FlagUnsafeSkipUpgrades, []int{}, "Skip a set of upgrade heights to continue the old binary") cmd.Flags().Uint64(server.FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node") cmd.Flags().Uint64(server.FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node") @@ -157,11 +157,12 @@ which accepts a path for the resulting pprof file. cmd.Flags().String(srvflags.JSONRPCAddress, config.DefaultJSONRPCAddress, "the JSON-RPC server address to listen on") cmd.Flags().String(srvflags.JSONWsAddress, config.DefaultJSONRPCWsAddress, "the JSON-RPC WS server address to listen on") cmd.Flags().Uint64(srvflags.JSONRPCGasCap, config.DefaultGasCap, "Sets a cap on gas that can be used in eth_call/estimateGas unit is aphoton (0=infinite)") - cmd.Flags().Float64(srvflags.JSONRPCTxFeeCap, config.DefaultTxFeeCap, "Sets a cap on transaction fee that can be sent via the RPC APIs (1 = default 1 photon)") + cmd.Flags().Float64(srvflags.JSONRPCTxFeeCap, config.DefaultTxFeeCap, "Sets a cap on transaction fee that can be sent via the RPC APIs (1 = default 1 pc)") cmd.Flags().Int32(srvflags.JSONRPCFilterCap, config.DefaultFilterCap, "Sets the global cap for total number of filters that can be created") cmd.Flags().Duration(srvflags.JSONRPCEVMTimeout, config.DefaultEVMTimeout, "Sets a timeout used for eth_call (0=infinite)") cmd.Flags().Duration(srvflags.JSONRPCHTTPTimeout, config.DefaultHTTPTimeout, "Sets a read/write timeout for json-rpc http server (0=infinite)") cmd.Flags().Duration(srvflags.JSONRPCHTTPIdleTimeout, config.DefaultHTTPIdleTimeout, "Sets a idle timeout for json-rpc http server (0=infinite)") + cmd.Flags().Bool(srvflags.JSONRPCAllowUnprotectedTxs, config.DefaultAllowUnprotectedTxs, "Allow for unprotected (non EIP155 signed) transactions to be submitted via the node's RPC when the global parameter is disabled") cmd.Flags().Int32(srvflags.JSONRPCLogsCap, config.DefaultLogsCap, "Sets the max number of results can be returned from single `eth_getLogs` query") cmd.Flags().Int32(srvflags.JSONRPCBlockRangeCap, config.DefaultBlockRangeCap, "Sets the max block range allowed for `eth_getLogs` query")