Skip to content

Commit

Permalink
Merge branch 'main' into fix/local-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang committed Oct 31, 2024
2 parents f602811 + 7b26a2c commit 50c8247
Show file tree
Hide file tree
Showing 55 changed files with 1,159 additions and 380 deletions.
35 changes: 23 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ Zenith](https://code4rena.com/zenith) Audit, running from 2024-10-07 until
period. This section describes code changes that occured after that audit in
preparation for a second audit starting in November 2024.

- [#2074](https://github.com/NibiruChain/nibiru/pull/2074) - fix(evm-keeper): better utilize ERC20 metadata during FunToken creation. The bank metadata for a new FunToken mapping ties a connection between the Bank Coin's `DenomUnit` and the ERC20 contract metadata like the name, decimals, and symbol. This change brings parity between EVM wallets, such as MetaMask, and Interchain wallets like Keplr and Leap.
- [#2068](https://github.com/NibiruChain/nibiru/pull/2068) - feat: enable wasm light clients on IBC (08-wasm)
- [#2074](https://github.com/NibiruChain/nibiru/pull/2074) - fix(evm-keeper): better utilize ERC20 metadata during FunToken creation. The bank metadata for a new FunToken mapping ties a connection between the Bank Coin's `DenomUnit` and the ERC20 contract metadata like the name, decimals, and symbol. This change brings parity between EVM wallets, such as MetaMask, and Interchain wallets like Keplr and Leap.
- [#2076](https://github.com/NibiruChain/nibiru/pull/2076) - fix(evm-gas-fees):
Use effective gas price in RefundGas and make sure that units are properly
reflected on all occurences of "base fee" in the codebase. This fixes [#2059](https://github.com/NibiruChain/nibiru/issues/2059)
and the [related comments from @Unique-Divine and @berndartmueller](https://github.com/NibiruChain/nibiru/issues/2059#issuecomment-2408625724).
Use effective gas price in RefundGas and make sure that units are properly
reflected on all occurences of "base fee" in the codebase. This fixes [#2059](https://github.com/NibiruChain/nibiru/issues/2059)
and the [related comments from @Unique-Divine and @berndartmueller](https://github.com/NibiruChain/nibiru/issues/2059#issuecomment-2408625724).
- [#2084](https://github.com/NibiruChain/nibiru/pull/2084) - feat(evm-forge): foundry support and template for Nibiru EVM develoment
- [#2086](https://github.com/NibiruChain/nibiru/pull/2086) - fix(evm-precomples):
Fix state consistency in precompile execution by ensuring proper journaling of
Expand All @@ -68,8 +69,13 @@ consistent setup and dynamic gas calculations, addressing the following tickets.
- <https://github.com/code-423n4/2024-10-nibiru-zenith/issues/47>
- [#2088](https://github.com/NibiruChain/nibiru/pull/2088) - refactor(evm): remove outdated comment and improper error message text
- [#2089](https://github.com/NibiruChain/nibiru/pull/2089) - better handling of gas consumption within erc20 contract execution
- [#2090](https://github.com/NibiruChain/nibiru/pull/2090) - fix(evm): Account
for (1) ERC20 transfers with tokens that return false success values instead of
throwing an error and (2) ERC20 transfers with other operations that don't bring
about the expected resulting balance for the transfer recipient.
- [#2091](https://github.com/NibiruChain/nibiru/pull/2091) - feat(evm): add fun token creation fee validation
- [#2093](https://github.com/NibiruChain/nibiru/pull/2093) - feat(evm): gas usage in precompiles: limits, local gas meters
- [#2092](https://github.com/NibiruChain/nibiru/pull/2092) - feat(evm): add validation for wasm multi message execution
- [#2094](https://github.com/NibiruChain/nibiru/pull/2094) - fix(evm): Following
from the changs in #2086, this pull request implements a new `JournalChange`
struct that saves a deep copy of the state multi store before each
Expand All @@ -79,13 +85,19 @@ non-EVM and EVM state will be in sync even if there are complex, multi-step
Ethereum transactions, such as in the case of an EthereumTx that influences the
`StateDB`, then calls a precompile that also changes non-EVM state, and then EVM
reverts inside of a try-catch.
- [#2098](https://github.com/NibiruChain/nibiru/pull/2098) - test(evm): statedb tests for race conditions within funtoken precompile
- [#2090](https://github.com/NibiruChain/nibiru/pull/2090) - fix(evm): Account
for (1) ERC20 transfers with tokens that return false success values instead of
throwing an error and (2) ERC20 transfers with other operations that don't bring
about the expected resulting balance for the transfer recipient.
- [#2092](https://github.com/NibiruChain/nibiru/pull/2092) - feat(evm): add validation for wasm multi message execution
- [#2068](https://github.com/NibiruChain/nibiru/pull/2068) - feat: enable wasm light clients on IBC (08-wasm)
- [#2095](https://github.com/NibiruChain/nibiru/pull/2095) - fix(evm): This
change records NIBI (ether) transfers on the `StateDB` during precompiled
contract calls using the `NibiruBankKeeper`, which is struct extension of
the `bankkeeper.BaseKeeper` that is used throughout Nibiru.
The `NibiruBankKeeper` holds a reference to the current EVM `StateDB` and records
balance changes in wei as journal changes automatically. This guarantees that
commits and reversions of the `StateDB` do not misalign with the state of the
Bank module. This code change uses the `NibiruBankKeeper` on all modules that
depend on x/bank, such as the EVM and Wasm modules.
- [#2097](https://github.com/NibiruChain/nibiru/pull/2097) - feat(evm): Add new query to get dated price from the oracle precompile
- [#2098](https://github.com/NibiruChain/nibiru/pull/2098) - test(evm): statedb
tests for race conditions within funtoken precompile
- [#2100](https://github.com/NibiruChain/nibiru/pull/2100) - refactor: cleanup statedb and precompile sections
- [#2101](https://github.com/NibiruChain/nibiru/pull/2101) - fix(evm): tx receipt proper marshalling

#### Nibiru EVM | Before Audit 1 - 2024-10-18
Expand Down Expand Up @@ -166,7 +178,6 @@ about the expected resulting balance for the transfer recipient.
- [#2060](https://github.com/NibiruChain/nibiru/pull/2060) - fix(evm-precompiles): add assertNumArgs validation
- [#2056](https://github.com/NibiruChain/nibiru/pull/2056) - feat(evm): add oracle precompile
- [#2065](https://github.com/NibiruChain/nibiru/pull/2065) - refactor(evm)!: Refactor out dead code from the evm.Params
- [#2100](https://github.com/NibiruChain/nibiru/pull/2100) - refactor: cleanup statedb and precompile sections

### State Machine Breaking (Other)

Expand Down
2 changes: 1 addition & 1 deletion app/ante/gas_wanted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *AnteTestSuite) TestGasWantedDecorator() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
stateDB := deps.NewStateDB()
anteDec := ante.AnteDecoratorGasWanted{}

tx := tc.txSetup(&deps)
Expand Down
2 changes: 1 addition & 1 deletion app/ante/handler_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type AnteHandlerOptions struct {
IBCKeeper *ibckeeper.Keeper
DevGasKeeper *devgaskeeper.Keeper
DevGasBankKeeper devgasante.BankKeeper
EvmKeeper evmkeeper.Keeper
EvmKeeper *evmkeeper.Keeper
AccountKeeper authkeeper.AccountKeeper

TxCounterStoreKey types.StoreKey
Expand Down
3 changes: 1 addition & 2 deletions app/evmante/evmante_can_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ func (ctd CanTransferDecorator) AnteHandle(
BaseFeeWei: baseFeeWeiPerGas,
}

stateDB := statedb.New(
stateDB := ctd.NewStateDB(
ctx,
ctd.EVMKeeper,
statedb.NewEmptyTxConfig(gethcommon.BytesToHash(ctx.HeaderHash().Bytes())),
)
evmInstance := ctd.EVMKeeper.NewEVM(ctx, coreMsg, cfg, evm.NewNoOpTracer(), stateDB)
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_can_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (s *TestSuite) TestCanTransferDecorator() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
anteDec := evmante.CanTransferDecorator{&deps.App.AppKeepers.EvmKeeper}
stateDB := deps.NewStateDB()
anteDec := evmante.CanTransferDecorator{deps.App.AppKeepers.EvmKeeper}
tx := tc.txSetup(&deps)

if tc.ctxSetup != nil {
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_emit_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (s *TestSuite) TestEthEmitEventDecorator() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
anteDec := evmante.NewEthEmitEventDecorator(&deps.App.AppKeepers.EvmKeeper)
stateDB := deps.NewStateDB()
anteDec := evmante.NewEthEmitEventDecorator(deps.App.AppKeepers.EvmKeeper)

tx := tc.txSetup(&deps)
s.Require().NoError(stateDB.Commit())
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_gas_consume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func (s *TestSuite) TestAnteDecEthGasConsume() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
stateDB := deps.NewStateDB()
anteDec := evmante.NewAnteDecEthGasConsume(
&deps.App.AppKeepers.EvmKeeper, tc.maxGasWanted,
deps.App.AppKeepers.EvmKeeper, tc.maxGasWanted,
)

tc.beforeTxSetup(&deps, stateDB)
Expand Down
18 changes: 9 additions & 9 deletions app/evmante/evmante_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ func NewAnteHandlerEVM(
) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
// outermost AnteDecorator. SetUpContext must be called first
NewEthSetUpContextDecorator(&options.EvmKeeper),
NewMempoolGasPriceDecorator(&options.EvmKeeper),
NewEthValidateBasicDecorator(&options.EvmKeeper),
NewEthSigVerificationDecorator(&options.EvmKeeper),
NewAnteDecVerifyEthAcc(&options.EvmKeeper, options.AccountKeeper),
CanTransferDecorator{&options.EvmKeeper},
NewAnteDecEthGasConsume(&options.EvmKeeper, options.MaxTxGasWanted),
NewAnteDecEthIncrementSenderSequence(&options.EvmKeeper, options.AccountKeeper),
NewEthSetUpContextDecorator(options.EvmKeeper),
NewMempoolGasPriceDecorator(options.EvmKeeper),
NewEthValidateBasicDecorator(options.EvmKeeper),
NewEthSigVerificationDecorator(options.EvmKeeper),
NewAnteDecVerifyEthAcc(options.EvmKeeper, options.AccountKeeper),
CanTransferDecorator{options.EvmKeeper},
NewAnteDecEthGasConsume(options.EvmKeeper, options.MaxTxGasWanted),
NewAnteDecEthIncrementSenderSequence(options.EvmKeeper, options.AccountKeeper),
ante.AnteDecoratorGasWanted{},
// emit eth tx hash and index at the very last ante handler.
NewEthEmitEventDecorator(&options.EvmKeeper),
NewEthEmitEventDecorator(options.EvmKeeper),
)
}
2 changes: 1 addition & 1 deletion app/evmante/evmante_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *TestSuite) TestAnteHandlerEVM() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
stateDB := deps.NewStateDB()

anteHandlerEVM := evmante.NewAnteHandlerEVM(
ante.AnteHandlerOptions{
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_increment_sender_seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (s *TestSuite) TestAnteDecEthIncrementSenderSequence() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
anteDec := evmante.NewAnteDecEthIncrementSenderSequence(&deps.App.EvmKeeper, deps.App.AccountKeeper)
stateDB := deps.NewStateDB()
anteDec := evmante.NewAnteDecEthIncrementSenderSequence(deps.App.EvmKeeper, deps.App.AccountKeeper)

if tc.beforeTxSetup != nil {
tc.beforeTxSetup(&deps, stateDB)
Expand Down
2 changes: 1 addition & 1 deletion app/evmante/evmante_mempool_fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s *TestSuite) TestMempoolGasFeeDecorator() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
anteDec := evmante.NewMempoolGasPriceDecorator(&deps.App.AppKeepers.EvmKeeper)
anteDec := evmante.NewMempoolGasPriceDecorator(deps.App.AppKeepers.EvmKeeper)

tx := tc.txSetup(&deps)

Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_setup_ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

func (s *TestSuite) TestEthSetupContextDecorator() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
anteDec := evmante.NewEthSetUpContextDecorator(&deps.App.EvmKeeper)
stateDB := deps.NewStateDB()
anteDec := evmante.NewEthSetUpContextDecorator(deps.App.EvmKeeper)

s.Require().NoError(stateDB.Commit())
tx := evmtest.HappyCreateContractTx(&deps)
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_sigverify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (s *TestSuite) TestEthSigVerificationDecorator() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
anteDec := evmante.NewEthSigVerificationDecorator(&deps.App.AppKeepers.EvmKeeper)
stateDB := deps.NewStateDB()
anteDec := evmante.NewEthSigVerificationDecorator(deps.App.AppKeepers.EvmKeeper)

tx := tc.txSetup(&deps)
s.Require().NoError(stateDB.Commit())
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_validate_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func (s *TestSuite) TestEthValidateBasicDecorator() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
anteDec := evmante.NewEthValidateBasicDecorator(&deps.App.AppKeepers.EvmKeeper)
stateDB := deps.NewStateDB()
anteDec := evmante.NewEthValidateBasicDecorator(deps.App.AppKeepers.EvmKeeper)

tx := tc.txSetup(&deps)
s.Require().NoError(stateDB.Commit())
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_verify_eth_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (s *TestSuite) TestAnteDecoratorVerifyEthAcc_CheckTx() {
for _, tc := range testCases {
s.Run(tc.name, func() {
deps := evmtest.NewTestDeps()
stateDB := deps.StateDB()
anteDec := evmante.NewAnteDecVerifyEthAcc(&deps.App.AppKeepers.EvmKeeper, &deps.App.AppKeepers.AccountKeeper)
stateDB := deps.NewStateDB()
anteDec := evmante.NewAnteDecVerifyEthAcc(deps.App.AppKeepers.EvmKeeper, &deps.App.AppKeepers.AccountKeeper)

tc.beforeTxSetup(&deps, stateDB)
tx := tc.txSetup(&deps)
Expand Down
29 changes: 16 additions & 13 deletions app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ type AppKeepers struct {
}

type privateKeepers struct {
bankBaseKeeper bankkeeper.BaseKeeper
capabilityKeeper *capabilitykeeper.Keeper
slashingKeeper slashingkeeper.Keeper
crisisKeeper crisiskeeper.Keeper
Expand Down Expand Up @@ -271,14 +270,17 @@ func (app *NibiruApp) InitKeepers(
govModuleAddr,
)

app.bankBaseKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
BlockedAddresses(),
govModuleAddr,
)
app.BankKeeper = app.bankBaseKeeper
nibiruBankKeeper := &evmkeeper.NibiruBankKeeper{
BaseKeeper: bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
BlockedAddresses(),
govModuleAddr,
),
StateDB: nil,
}
app.BankKeeper = nibiruBankKeeper
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec,
keys[stakingtypes.StoreKey],
Expand Down Expand Up @@ -374,16 +376,17 @@ func (app *NibiruApp) InitKeepers(
),
)

app.EvmKeeper = evmkeeper.NewKeeper(
evmKeeper := evmkeeper.NewKeeper(
appCodec,
keys[evm.StoreKey],
tkeys[evm.TransientKey],
authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
nibiruBankKeeper,
app.StakingKeeper,
cast.ToString(appOpts.Get("evm.tracer")),
)
app.EvmKeeper = &evmKeeper

// ---------------------------------- IBC keepers

Expand Down Expand Up @@ -631,7 +634,7 @@ func (app *NibiruApp) initAppModules(
),
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.bankBaseKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
capability.NewAppModule(appCodec, *app.capabilityKeeper, false),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
Expand All @@ -657,7 +660,7 @@ func (app *NibiruApp) initAppModules(
ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper),
ibcwasm.NewAppModule(app.WasmClientKeeper),

evmmodule.NewAppModule(&app.EvmKeeper, app.AccountKeeper),
evmmodule.NewAppModule(app.EvmKeeper, app.AccountKeeper),

// wasm
wasm.NewAppModule(
Expand Down
2 changes: 1 addition & 1 deletion app/keepers/all_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type PublicKeepers struct {
SudoKeeper keeper.Keeper
DevGasKeeper devgaskeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper
EvmKeeper evmkeeper.Keeper
EvmKeeper *evmkeeper.Keeper

// WASM keepers
WasmKeeper wasmkeeper.Keeper
Expand Down
1 change: 1 addition & 0 deletions app/wasmext/stargate_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func WasmAcceptedStargateQueries() wasmkeeper.AcceptedStargateQueries {

// nibiru oracle
"/nibiru.oracle.v1.Query/ExchangeRate": new(oracle.QueryExchangeRateResponse),
"/nibiru.oracle.v1.Query/DatedExchangeRate": new(oracle.QueryDatedExchangeRateResponse),
"/nibiru.oracle.v1.Query/ExchangeRateTwap": new(oracle.QueryExchangeRateResponse),
"/nibiru.oracle.v1.Query/ExchangeRates": new(oracle.QueryExchangeRatesResponse),
"/nibiru.oracle.v1.Query/Actives": new(oracle.QueryActivesResponse),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ replace (
cosmossdk.io/api => cosmossdk.io/api v0.3.1

github.com/CosmWasm/wasmd => github.com/NibiruChain/wasmd v0.44.0-nibiru
github.com/cosmos/cosmos-sdk => github.com/NibiruChain/cosmos-sdk v0.47.11-nibiru
github.com/cosmos/cosmos-sdk => github.com/NibiruChain/cosmos-sdk v0.47.11-nibiru.2

github.com/cosmos/iavl => github.com/cosmos/iavl v0.20.0

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/NibiruChain/collections v0.5.0 h1:33pXpVTe1PK/tfdZlAJF1JF7AdzGNARG+iL9G/z3X7k=
github.com/NibiruChain/collections v0.5.0/go.mod h1:43L6yjuF0BMre/mw4gqn/kUOZz1c2Y3huZ/RQfBFrOQ=
github.com/NibiruChain/cosmos-sdk v0.47.11-nibiru h1:PgFpxDe+7+OzWHs4zXlml5j2i9sGq2Zpd3ndYQG29/0=
github.com/NibiruChain/cosmos-sdk v0.47.11-nibiru/go.mod h1:ADjORYzUQqQv/FxDi0H0K5gW/rAk1CiDR3ZKsExfJV0=
github.com/NibiruChain/cosmos-sdk v0.47.11-nibiru.2 h1:HtLNrkp0HhgxtbpdNwsasOod4uUNFpuwYpyceFtbj3E=
github.com/NibiruChain/cosmos-sdk v0.47.11-nibiru.2/go.mod h1:ADjORYzUQqQv/FxDi0H0K5gW/rAk1CiDR3ZKsExfJV0=
github.com/NibiruChain/go-ethereum v1.10.27-nibiru h1:o6lRFt57izoYwzN5cG8tnnBtJcaO3X7MjjN7PGGNCFg=
github.com/NibiruChain/go-ethereum v1.10.27-nibiru/go.mod h1:kvvL3nDceUcB+1qGUBAsVf5dW23RBR77fqxgx2PGNrQ=
github.com/NibiruChain/wasmd v0.44.0-nibiru h1:b+stNdbMFsl0+o4KedXyF83qRnEpB/jCiTGZZgv2h2U=
Expand Down
26 changes: 25 additions & 1 deletion proto/nibiru/oracle/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ service Query {
option (google.api.http).get = "/nibiru/oracle/v1beta1/exchange_rate_twap";
}

// DatedExchangeRate returns latest price of a pair
rpc DatedExchangeRate(QueryExchangeRateRequest)
returns (QueryDatedExchangeRateResponse) {
option (google.api.http).get = "/nibiru/oracle/v1beta1/dated_exchange_rate";
}

// ExchangeRates returns exchange rates of all pairs
rpc ExchangeRates(QueryExchangeRatesRequest)
returns (QueryExchangeRatesResponse) {
Expand Down Expand Up @@ -112,7 +118,25 @@ message QueryExchangeRateResponse {

// QueryExchangeRatesRequest is the request type for the Query/ExchangeRates RPC
// method.
message QueryExchangeRatesRequest {}
message QueryExchangeRatesRequest {
}

// QueryDatedExchangeRateResponse is the request type for the
// Query/DatedExchangeRate RPC method.
message QueryDatedExchangeRateResponse {
string price = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Block timestamp for the block where the oracle came to consensus for this
// price. This timestamp is a conventional Unix millisecond time, i.e. the
// number of milliseconds elapsed since January 1, 1970 UTC.
int64 block_timestamp_ms = 2;

// Block height when the oracle came to consensus for this price.
uint64 block_height = 3;
}

// QueryExchangeRatesResponse is response type for the
// Query/ExchangeRates RPC method.
Expand Down
16 changes: 13 additions & 3 deletions x/evm/embeds/artifacts/contracts/IOracle.sol/IOracle.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@
"name": "queryExchangeRate",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
"internalType": "uint256",
"name": "price",
"type": "uint256"
},
{
"internalType": "uint64",
"name": "blockTimeMs",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "blockHeight",
"type": "uint64"
}
],
"stateMutability": "view",
Expand Down
Loading

0 comments on commit 50c8247

Please sign in to comment.