Skip to content

Commit

Permalink
feat(eth-rpc): RPC backend, Ethereum tracer, KV indexer, and RPC APIs (
Browse files Browse the repository at this point in the history
…#1861)

* Squashed commit of the following:

commit 045cf6d
Merge: db03210 ffcea96
Author: Unique-Divine <[email protected]>
Date:   Sun May 5 15:21:16 2024 -0500

    Merge branch 'main' into ud/evm-rpc

commit db03210
Author: Unique-Divine <[email protected]>
Date:   Sun May 5 15:18:59 2024 -0500

    test(eth-rpc): more tests

commit 14f8a2c
Author: Unique-Divine <[email protected]>
Date:   Sun Apr 28 17:21:18 2024 -0500

    test(eth): more tests

commit 433780d
Merge: 4f28f8f 29e2acd
Author: Unique-Divine <[email protected]>
Date:   Sun Apr 28 14:53:34 2024 -0500

    Merge branch 'main' into ud/evm-rpc

commit 4f28f8f
Author: Unique-Divine <[email protected]>
Date:   Sun Apr 28 14:51:54 2024 -0500

    test(eth): eip712 more tests

commit bfac1e8
Author: Unique-Divine <[email protected]>
Date:   Sun Apr 28 14:29:27 2024 -0500

    refactor(eth): ethtypes -> eth

commit b32d385
Author: Unique-Divine <[email protected]>
Date:   Sun Apr 28 14:24:26 2024 -0500

    refactor(eth): evm/types -> evm

commit a336983
Author: Unique-Divine <[email protected]>
Date:   Sat Apr 27 15:58:05 2024 -0500

    refactor(eth): rpc/types -> rpc

commit c3a6215
Merge: fe913dc 31bb3bb
Author: Unique-Divine <[email protected]>
Date:   Sat Apr 27 13:13:37 2024 -0500

    Merge branch 'ud/evm' into ud/evm-rpc

commit 31bb3bb
Merge: 1a05061 072de03
Author: Unique Divine <[email protected]>
Date:   Sat Apr 27 20:12:14 2024 +0200

    Merge branch 'main' into ud/evm

commit fe913dc
Author: Unique-Divine <[email protected]>
Date:   Sat Apr 27 09:10:03 2024 -0500

    test,refactor(eth): remove unnecessary nesting + more tests

commit 372df12
Author: Unique-Divine <[email protected]>
Date:   Sat Apr 27 07:41:04 2024 -0500

    ci: add CODECOV_TOKEN env var to secrets

commit ac0701a
Author: Unique-Divine <[email protected]>
Date:   Sat Apr 27 07:26:57 2024 -0500

    test(eth-rpc): more tests for types dir

commit 176b6c6
Author: Unique-Divine <[email protected]>
Date:   Fri Apr 26 20:54:04 2024 -0500

    chore: linter

commit 36730c5
Author: Unique-Divine <[email protected]>
Date:   Fri Apr 26 20:48:58 2024 -0500

    feat(eth-rpc): Conversion types and functions between Ethereum txs and blocks and Tendermint ones.

commit 1a05061
Author: Unique-Divine <[email protected]>
Date:   Fri Apr 26 08:11:57 2024 +0200

    feat(eth-pubsub): Implement in-memory EventBus for real-time topic management and event distribution

* feat(eth-rpc): RPC backend, Ethereum tracer, KV indexer, and RPC APIs

* fix(indexer): register eth and evm types during test setup
  • Loading branch information
Unique-Divine authored May 6, 2024
1 parent 2bd7a14 commit 83da4ad
Show file tree
Hide file tree
Showing 76 changed files with 15,834 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ coverage:
status:
project:
default:
if_not_found: success
target: 66%
if_not_found: success
threshold: 1% # Allow coverage to drop by X%, posting a success status.
# removed_code_behavior: Takes values [off, removals_only, adjust_base]
removed_code_behavior: adjust_base
patch:
default:
target: 69%
target: 0%

comment: # this is a top-level key
layout: " diff, flags, files"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1841](https://github.com/NibiruChain/nibiru/pull/1841) - feat(eth): Collections encoders for bytes, Ethereum addresses, and Ethereum hashes
- [#1855](https://github.com/NibiruChain/nibiru/pull/1855) - feat(eth-pubsub): Implement in-memory EventBus for real-time topic management and event distribution
- [#1856](https://github.com/NibiruChain/nibiru/pull/1856) - feat(eth-rpc): Conversion types and functions between Ethereum txs and blocks and Tendermint ones.
- [#1861](https://github.com/NibiruChain/nibiru/pull/1861) - feat(eth-rpc): RPC backend, Ethereum tracer, KV indexer, and RPC APIs

#### Dapp modules: perp, spot, oracle, etc

Expand Down
20 changes: 10 additions & 10 deletions app/ante/fixed_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/NibiruChain/nibiru/app"
"github.com/NibiruChain/nibiru/app/ante"
"github.com/NibiruChain/nibiru/app/appconst"
"github.com/NibiruChain/nibiru/x/common/testutil"
"github.com/NibiruChain/nibiru/x/common/testutil/testapp"
oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
Expand Down Expand Up @@ -64,7 +64,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
&types.MsgSend{
FromAddress: addr.String(),
ToAddress: addr.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 100)),
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
},
},
expectedGas: 1042,
Expand All @@ -76,7 +76,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
&types.MsgSend{
FromAddress: addr.String(),
ToAddress: addr.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 100)),
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
},
&oracletypes.MsgAggregateExchangeRatePrevote{
Hash: "",
Expand All @@ -99,7 +99,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
&types.MsgSend{
FromAddress: addr.String(),
ToAddress: addr.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 100)),
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
},
},
expectedGas: 1042,
Expand All @@ -111,7 +111,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
&types.MsgSend{
FromAddress: addr.String(),
ToAddress: addr.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 100)),
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
},
&oracletypes.MsgAggregateExchangeRateVote{
Salt: "dummySalt",
Expand Down Expand Up @@ -171,7 +171,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
&types.MsgSend{
FromAddress: addr.String(),
ToAddress: addr.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 100)),
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
},
&oracletypes.MsgAggregateExchangeRatePrevote{
Hash: "",
Expand All @@ -188,12 +188,12 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
&types.MsgSend{
FromAddress: addr.String(),
ToAddress: addr.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 100)),
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
},
&types.MsgSend{
FromAddress: addr.String(),
ToAddress: addr.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 200)),
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 200)),
},
},
expectedGas: 62288,
Expand All @@ -208,7 +208,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder()

// msg and signatures
feeAmount := sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 150))
feeAmount := sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 150))
gasLimit := testdata.NewTestGasLimit()
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)
Expand All @@ -224,7 +224,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {

err = testapp.FundAccount(
suite.app.BankKeeper, suite.ctx, addr,
sdk.NewCoins(sdk.NewInt64Coin(app.BondDenom, 1000)),
sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 1000)),
)
suite.Require().NoError(err)

Expand Down
6 changes: 2 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ import (
)

const (
AccountAddressPrefix = "nibi"
appName = "Nibiru"
BondDenom = "unibi"
DisplayDenom = "NIBI"
appName = "Nibiru"
DisplayDenom = "NIBI"
)

var (
Expand Down
44 changes: 44 additions & 0 deletions app/appconst/appconst.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) 2023-2024 Nibi, Inc.
package appconst

import (
"fmt"
"runtime"
)

const (
BinaryName = "nibiru"
BondDenom = "unibi"
// AccountAddressPrefix: Bech32 prefix for Nibiru accounts.
AccountAddressPrefix = "nibi"
)

// Runtime version vars
var (
AppVersion = ""
GitCommit = ""
BuildDate = ""

GoVersion = ""
GoArch = ""
)

func init() {
if len(AppVersion) == 0 {
AppVersion = "dev"
}

GoVersion = runtime.Version()
GoArch = runtime.GOARCH
}

func Version() string {
return fmt.Sprintf(
"Version %s (%s)\nCompiled at %s using Go %s (%s)",
AppVersion,
GitCommit,
BuildDate,
GoVersion,
GoArch,
)
}
12 changes: 7 additions & 5 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/NibiruChain/nibiru/app/appconst"
)

// BankModule defines a custom wrapper around the x/bank module's AppModuleBasic
Expand All @@ -29,13 +31,13 @@ type BankModule struct {
func (BankModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
denomMetadata := banktypes.Metadata{
Description: "The native staking token of the Nibiru network.",
Base: BondDenom,
Base: appconst.BondDenom,
Name: DisplayDenom,
Display: DisplayDenom,
Symbol: DisplayDenom,
DenomUnits: []*banktypes.DenomUnit{
{
Denom: BondDenom,
Denom: appconst.BondDenom,
Exponent: 0,
Aliases: []string{
"micronibi",
Expand Down Expand Up @@ -65,7 +67,7 @@ var _ module.HasGenesisBasics = (*StakingModule)(nil)
// DefaultGenesis returns custom Nibiru x/staking module genesis state.
func (StakingModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := stakingtypes.DefaultGenesisState()
genState.Params.BondDenom = BondDenom
genState.Params.BondDenom = appconst.BondDenom
genState.Params.MinCommissionRate = sdk.MustNewDecFromStr("0.05")
return cdc.MustMarshalJSON(genState)
}
Expand Down Expand Up @@ -99,7 +101,7 @@ type CrisisModule struct {
// DefaultGenesis returns custom Nibiru x/crisis module genesis state.
func (CrisisModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := crisistypes.DefaultGenesisState()
genState.ConstantFee = sdk.NewCoin(BondDenom, genState.ConstantFee.Amount)
genState.ConstantFee = sdk.NewCoin(appconst.BondDenom, genState.ConstantFee.Amount)
return cdc.MustMarshalJSON(genState)
}

Expand All @@ -113,7 +115,7 @@ type GovModule struct {
func (GovModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := govtypes.DefaultGenesisState()
genState.Params.MinDeposit = sdk.NewCoins(
sdk.NewCoin(BondDenom, govtypes.DefaultMinDepositTokens))
sdk.NewCoin(appconst.BondDenom, govtypes.DefaultMinDepositTokens))
return cdc.MustMarshalJSON(genState)
}

Expand Down
Loading

0 comments on commit 83da4ad

Please sign in to comment.