Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Pending #571

Merged
merged 83 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
edb9d4b
add PendingBlockNumber -1
araskachoi Oct 6, 2020
f44ddf9
increase block times
araskachoi Oct 6, 2020
feb7a84
update bn
araskachoi Oct 6, 2020
4c44633
Merge branch 'development' of github.com:ChainSafe/ethermint into pen…
araskachoi Oct 7, 2020
0922cbb
get pending balance
araskachoi Oct 9, 2020
2babec4
Merge branch 'development' of github.com:ChainSafe/ethermint into pen…
araskachoi Oct 9, 2020
34bd371
Merge branch 'development' of github.com:ChainSafe/ethermint into pen…
araskachoi Oct 12, 2020
1ea22ea
additional logic to check for pending state
araskachoi Oct 12, 2020
b2b54ba
add multiple balance query
araskachoi Oct 12, 2020
f845650
pending state for getTransactionCount
araskachoi Oct 14, 2020
274a999
fix lint
araskachoi Oct 14, 2020
f70136a
add getBlockTransactionCountByNumber code - commented
araskachoi Oct 19, 2020
f0b4984
cleanup test
araskachoi Oct 19, 2020
ac2d18e
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Oct 20, 2020
7b49761
GetBlockTransactionCountByNumber
araskachoi Oct 20, 2020
f6550be
cleanup
araskachoi Oct 20, 2020
04486f4
getBlockByNumber
araskachoi Oct 21, 2020
9dd8166
GetTransactionByBlockNumberAndIndex
araskachoi Oct 22, 2020
bb7dcfa
merge development branch
araskachoi Oct 23, 2020
676f254
conform to namespace changes
araskachoi Oct 23, 2020
d714225
exportable FormatBlock method
araskachoi Oct 23, 2020
fa7cc7d
eth_getTransactionByHash
araskachoi Oct 26, 2020
d9e8b3a
eth_getTransactionByBlockNumberAndIndex
araskachoi Oct 26, 2020
32e99a5
pending nonce
araskachoi Oct 26, 2020
0bc623d
set nonce for pending and check for invalid
araskachoi Oct 27, 2020
bbace88
WIP: doCall
araskachoi Oct 28, 2020
15769e8
add pending tx test
noot Oct 29, 2020
9826b1c
cleanup + refactor
araskachoi Oct 29, 2020
b4084a5
Merge branch 'pending' of github.com:cosmos/ethermint into pending
araskachoi Oct 29, 2020
77957fd
push first tests and init pending
araskachoi Nov 13, 2020
250cd16
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Nov 13, 2020
1a47621
pending changes (#600)
fedekunze Nov 16, 2020
3188c52
Merge branch 'development' into pending
fedekunze Nov 17, 2020
bea5206
Merge branch 'development' of https://github.com/cosmos/ethermint int…
fedekunze Nov 17, 2020
a152e6f
Merge branch 'pending' of https://github.com/cosmos/ethermint into pe…
fedekunze Nov 17, 2020
0972017
update call and send
fedekunze Nov 17, 2020
4947fa7
comments and minor changes
fedekunze Nov 17, 2020
27ed027
add pending tests into sep package
araskachoi Nov 17, 2020
ed5878a
merge pending
araskachoi Nov 17, 2020
5df5e37
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Nov 20, 2020
ea5be6b
fix latest case for eth_GetBlockTransactionCountByNumber
araskachoi Nov 20, 2020
227adf8
fix repeating null transactions in queue
araskachoi Nov 23, 2020
f3e6cf9
remove repeated structs
araskachoi Nov 24, 2020
0dd8d0e
latestblock case
araskachoi Nov 24, 2020
75d52ad
revert init script back
araskachoi Nov 24, 2020
639c47d
fix to exportable method
araskachoi Nov 24, 2020
533b443
automate pending tests; add make cmd
araskachoi Nov 24, 2020
94fd769
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Nov 24, 2020
e5675bf
move and comment out pending call test
araskachoi Nov 24, 2020
7d1ced4
fix some golint
araskachoi Nov 24, 2020
109b71f
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Nov 24, 2020
fab4a14
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Nov 30, 2020
e4ffeae
fix unlock issue
araskachoi Nov 30, 2020
c8c3464
wip: linter stringer fix?
araskachoi Nov 30, 2020
19610d3
stringer lint
araskachoi Nov 30, 2020
be81555
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Dec 8, 2020
b5de478
set arr instead of append
araskachoi Dec 9, 2020
7cba8d9
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Dec 9, 2020
139cf96
instantiate with length
araskachoi Dec 9, 2020
5bdd6ec
sep if statement
araskachoi Dec 9, 2020
3aebb8a
edit pendingblocknumber note
araskachoi Dec 10, 2020
621ee71
switch statement
araskachoi Dec 10, 2020
cd67495
fix and update tests
araskachoi Dec 10, 2020
a144b52
move tests-pending into tests dir
araskachoi Dec 10, 2020
bff1020
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Dec 10, 2020
555d056
remove commented test
araskachoi Dec 15, 2020
66ba658
revert to appending pendingtx
araskachoi Dec 15, 2020
2ffad82
Update tests/utils.go
araskachoi Dec 15, 2020
6180a11
Update tests/utils.go
araskachoi Dec 15, 2020
a664c65
Update tests/utils.go
araskachoi Dec 15, 2020
c237e59
require no err
araskachoi Dec 15, 2020
6fb1f71
rename var
araskachoi Dec 15, 2020
ad91a12
check result for eth_sendTransaction
araskachoi Dec 15, 2020
4adb1f3
update changelog
araskachoi Dec 15, 2020
10f2b59
Merge branch 'development' of github.com:cosmos/ethermint into pending
araskachoi Dec 15, 2020
2cb7f48
update
araskachoi Dec 15, 2020
0c5dd2e
Update tests/utils.go
araskachoi Dec 15, 2020
2eae733
Update tests/tests-pending/rpc_pending_test.go
araskachoi Dec 15, 2020
8738398
changelog
fedekunze Dec 15, 2020
ab9093e
remove redundant check
araskachoi Dec 15, 2020
843265c
Merge branch 'pending' of https://github.com/cosmos/ethermint into pe…
fedekunze Dec 15, 2020
f4aa06e
Merge branch 'pending' of https://github.com/cosmos/ethermint into pe…
fedekunze Dec 15, 2020
ebb6f63
Merge branch 'development' into pending
fedekunze Dec 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (evm) [\#661](https://github.com/cosmos/ethermint/pull/661) `Balance` field has been removed from the evm module's `GenesisState`.

### Features

* (rpc) [\#571](https://github.com/cosmos/ethermint/pull/571) Add pending queries to JSON-RPC calls. This allows for the querying of pending transactions and other relevant information that pertains to the pending state:
* `eth_getBalance`
* `eth_getTransactionCount`
* `eth_getBlockTransactionCountByNumber`
* `eth_getBlockByNumber`
* `eth_getTransactionByHash`
* `eth_getTransactionByBlockNumberAndIndex`
* `eth_sendTransaction` - the nonce will automatically update to its pending nonce (when none is explicitly provided)

### Improvements

* (evm) [\#661](https://github.com/cosmos/ethermint/pull/661) Add invariant check for account balance and account nonce.
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ test-import:
rm -rf importer/tmp

test-rpc:
./scripts/integration-test-all.sh -q 1 -z 1 -s 2
./scripts/integration-test-all.sh -t "rpc" -q 1 -z 1 -s 2 -m "rpc"

test-rpc-pending:
./scripts/integration-test-all.sh -t "pending" -q 1 -z 1 -s 2 -m "pending"

test-contract:
@type "npm" 2> /dev/null || (echo 'Npm does not exist. Please install node.js and npm."' && exit 1)
Expand Down
15 changes: 15 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ cat $HOME/.ethermintd/config/genesis.json | jq '.app_state["mint"]["params"]["mi
# Enable faucet
cat $HOME/.ethermintd/config/genesis.json | jq '.app_state["faucet"]["enable_faucet"]=true' > $HOME/.ethermintd/config/tmp_genesis.json && mv $HOME/.ethermintd/config/tmp_genesis.json $HOME/.ethermintd/config/genesis.json

# increase block time (?)
cat $HOME/.ethermintd/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="30000"' > $HOME/.ethermintd/config/tmp_genesis.json && mv $HOME/.ethermintd/config/tmp_genesis.json $HOME/.ethermintd/config/genesis.json

if [[ $1 == "pending" ]]; then
echo "pending mode on; block times will be set to 30s."
# sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.ethermintd/config/config.toml
sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.ethermintd/config/config.toml
sed -i 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.ethermintd/config/config.toml
sed -i 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.ethermintd/config/config.toml
sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.ethermintd/config/config.toml
sed -i 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.ethermintd/config/config.toml
sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.ethermintd/config/config.toml
sed -i 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.ethermintd/config/config.toml
fi

# Allocate genesis accounts (cosmos formatted addresses)
ethermintd add-genesis-account $(ethermintcli keys show $KEY -a) 100000000000000000000aphoton

Expand Down
21 changes: 15 additions & 6 deletions rpc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
type Backend interface {
// Used by block filter; also used for polling
BlockNumber() (hexutil.Uint64, error)
LatestBlockNumber() (int64, error)
HeaderByNumber(blockNum rpctypes.BlockNumber) (*ethtypes.Header, error)
HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error)
GetBlockByNumber(blockNum rpctypes.BlockNumber, fullTx bool) (map[string]interface{}, error)
Expand Down Expand Up @@ -60,13 +61,12 @@ func New(clientCtx clientcontext.CLIContext) *EthermintBackend {

// BlockNumber returns the current block number.
func (b *EthermintBackend) BlockNumber() (hexutil.Uint64, error) {
// NOTE: using 0 as min and max height returns the blockchain info up to the latest block.
info, err := b.clientCtx.Client.BlockchainInfo(0, 0)
blockNumber, err := b.LatestBlockNumber()
if err != nil {
return hexutil.Uint64(0), err
}

return hexutil.Uint64(info.LastHeight), nil
return hexutil.Uint64(blockNumber), nil
}

// GetBlockByNumber returns the block identified by number.
Expand Down Expand Up @@ -196,7 +196,7 @@ func (b *EthermintBackend) PendingTransactions() ([]*rpctypes.Transaction, error
return nil, err
}

transactions := make([]*rpctypes.Transaction, pendingTxs.Count)
transactions := make([]*rpctypes.Transaction, 0)
araskachoi marked this conversation as resolved.
Show resolved Hide resolved
for _, tx := range pendingTxs.Txs {
araskachoi marked this conversation as resolved.
Show resolved Hide resolved
ethTx, err := rpctypes.RawTxToEthTx(b.clientCtx, tx)
if err != nil {
Expand All @@ -209,10 +209,8 @@ func (b *EthermintBackend) PendingTransactions() ([]*rpctypes.Transaction, error
if err != nil {
return nil, err
}

transactions = append(transactions, rpcTx)
}

return transactions, nil
}

Expand Down Expand Up @@ -257,3 +255,14 @@ func (b *EthermintBackend) GetLogs(blockHash common.Hash) ([][]*ethtypes.Log, er
func (b *EthermintBackend) BloomStatus() (uint64, uint64) {
return 4096, 0
}

// LatestBlockNumber gets the latest block height in int64 format.
func (b *EthermintBackend) LatestBlockNumber() (int64, error) {
// NOTE: using 0 as min and max height returns the blockchain info up to the latest block.
info, err := b.clientCtx.Client.BlockchainInfo(0, 0)
if err != nil {
return 0, err
}

return info.LastHeight, nil
}
Loading