Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Devon Bear committed Oct 9, 2023
2 parents 73ec31c + cc9e8f7 commit 32bc0d5
Show file tree
Hide file tree
Showing 48 changed files with 426 additions and 4,222 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cosmos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

replace (
// We replace `go-ethereum` with `polaris-geth` in order include our required changes.
github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20231005195105-e21d980905b4
github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20231008031417-f6e231f3bf10

// Required at the moment until a bug in the comsos-sdk is fixed.
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
Expand Down
4 changes: 2 additions & 2 deletions cosmos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/berachain/polaris-geth v0.0.0-20231005195105-e21d980905b4 h1:t8fKaxVPovG95BUX62QX1DaJld0Uk5Hi9DtDQphIWR0=
github.com/berachain/polaris-geth v0.0.0-20231005195105-e21d980905b4/go.mod h1:xHQKzwkHSl0gnSjZK1mWa06XEdm9685AHqhRknOzqGQ=
github.com/berachain/polaris-geth v0.0.0-20231008031417-f6e231f3bf10 h1:LY4GputrzZf7U2yoDLgt7oQdJc5URRTzQooDnb6igjM=
github.com/berachain/polaris-geth v0.0.0-20231008031417-f6e231f3bf10/go.mod h1:gkQ5Ygi64ZBh9M/4iXY1R8WqoNCx1Ey0CkYn2BD4/fw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s=
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
Expand Down
11 changes: 6 additions & 5 deletions cosmos/precompile/bank/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"math/big"
"testing"

"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
Expand All @@ -36,8 +37,8 @@ import (

"pkg.berachain.dev/polaris/cosmos/precompile"
"pkg.berachain.dev/polaris/cosmos/precompile/bank"
testutils "pkg.berachain.dev/polaris/cosmos/testing/utils"
"pkg.berachain.dev/polaris/cosmos/x/evm/plugins/precompile/log"
testutils "pkg.berachain.dev/polaris/cosmos/testutil"
pclog "pkg.berachain.dev/polaris/cosmos/x/evm/plugins/precompile/log"
evmtypes "pkg.berachain.dev/polaris/cosmos/x/evm/types"
"pkg.berachain.dev/polaris/eth/common"
ethprecompile "pkg.berachain.dev/polaris/eth/core/precompile"
Expand All @@ -57,22 +58,22 @@ var _ = Describe("Bank Precompile Test", func() {
var (
contract *bank.Contract
addr sdk.AccAddress
factory *log.Factory
factory *pclog.Factory
ak authkeeper.AccountKeeperI
bk bankkeeper.BaseKeeper
ctx context.Context
)

BeforeEach(func() {
ctx, ak, bk, _ = testutils.SetupMinimalKeepers()
ctx, ak, bk, _ = testutils.SetupMinimalKeepers(log.NewTestLogger(GinkgoT()))

contract = utils.MustGetAs[*bank.Contract](bank.NewPrecompileContract(
ak, bankkeeper.NewMsgServerImpl(bk), bk),
)
addr = sdk.AccAddress([]byte("bank"))

// Register the events.
factory = log.NewFactory([]ethprecompile.Registrable{contract})
factory = pclog.NewFactory([]ethprecompile.Registrable{contract})
})

It("should register the send event", func() {
Expand Down
15 changes: 9 additions & 6 deletions cosmos/precompile/distribution/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"math/big"
"testing"

"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"

Expand All @@ -44,8 +45,8 @@ import (

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

testutil "pkg.berachain.dev/polaris/cosmos/testing/utils"
"pkg.berachain.dev/polaris/cosmos/x/evm/plugins/precompile/log"
testutil "pkg.berachain.dev/polaris/cosmos/testutil"
pclog "pkg.berachain.dev/polaris/cosmos/x/evm/plugins/precompile/log"
ethprecompile "pkg.berachain.dev/polaris/eth/core/precompile"
"pkg.berachain.dev/polaris/eth/core/vm"
"pkg.berachain.dev/polaris/lib/utils"
Expand Down Expand Up @@ -77,15 +78,17 @@ func setup() (
*stakingkeeper.Keeper,
*bankkeeper.BaseKeeper,
) {
ctx, ak, bk, sk := testutil.SetupMinimalKeepers()
distrKey := storetypes.NewKVStoreKey(distributiontypes.StoreKey)
ctx, ak, bk, sk := testutil.SetupMinimalKeepers(log.NewTestLogger(GinkgoT()),
[]storetypes.StoreKey{distrKey}...)

encCfg := cosmostestutil.MakeTestEncodingConfig(
distribution.AppModuleBasic{},
)

dk := distrkeeper.NewKeeper(
encCfg.Codec,
runtime.NewKVStoreService(storetypes.NewKVStoreKey(distributiontypes.StoreKey)),
runtime.NewKVStoreService(distrKey),
ak,
bk,
sk,
Expand All @@ -107,7 +110,7 @@ var _ = Describe("Distribution Precompile Test", func() {
var (
contract *Contract
valAddr sdk.ValAddress
f *log.Factory
f *pclog.Factory
amt sdk.Coin

ctx sdk.Context
Expand All @@ -131,7 +134,7 @@ var _ = Describe("Distribution Precompile Test", func() {
))

// Register the events.
f = log.NewFactory([]ethprecompile.Registrable{contract})
f = pclog.NewFactory([]ethprecompile.Registrable{contract})

// Set up the stateful factory.
sf = ethprecompile.NewStatefulFactory()
Expand Down
2 changes: 1 addition & 1 deletion cosmos/precompile/governance/governance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (

cbindings "pkg.berachain.dev/polaris/contracts/bindings/cosmos/lib"
generated "pkg.berachain.dev/polaris/contracts/bindings/cosmos/precompile/governance"
testutils "pkg.berachain.dev/polaris/cosmos/testing/utils"
testutils "pkg.berachain.dev/polaris/cosmos/testutil"
"pkg.berachain.dev/polaris/cosmos/types"
"pkg.berachain.dev/polaris/eth/common"
ethprecompile "pkg.berachain.dev/polaris/eth/core/precompile"
Expand Down
10 changes: 7 additions & 3 deletions cosmos/precompile/governance/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/golang/mock/gomock"

"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -43,7 +44,7 @@ import (
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

testutils "pkg.berachain.dev/polaris/cosmos/testing/utils"
testutils "pkg.berachain.dev/polaris/cosmos/testutil"
"pkg.berachain.dev/polaris/eth/common"

//nolint:stylecheck,revive // Ginkgo is the testing framework.
Expand All @@ -67,7 +68,10 @@ func setupGovTest(ctrl *gomock.Controller, caller sdk.AccAddress) (
sdk.Context, authkeeper.AccountKeeperI, bankkeeper.Keeper, *governancekeeper.Keeper,
) {
// Setup the keepers and context.
ctx, ak, bk, sk := testutils.SetupMinimalKeepers()
govKey := storetypes.NewKVStoreKey(governancetypes.StoreKey)
ctx, ak, bk, sk := testutils.SetupMinimalKeepers(
log.NewTestLogger(GinkgoT()), []storetypes.StoreKey{govKey}...,
)
dk := govtestutil.NewMockDistributionKeeper(ctrl)

// Create the codec.
Expand All @@ -94,7 +98,7 @@ func setupGovTest(ctrl *gomock.Controller, caller sdk.AccAddress) (
}
gk := governancekeeper.NewKeeper(
encCfg.Codec,
runtime.NewKVStoreService(storetypes.NewKVStoreKey(governancetypes.StoreKey)),
runtime.NewKVStoreService(govKey),
ak,
bk,
sk,
Expand Down
5 changes: 3 additions & 2 deletions cosmos/precompile/staking/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"math/big"
"testing"

"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand All @@ -38,7 +39,7 @@ import (
cbindings "pkg.berachain.dev/polaris/contracts/bindings/cosmos/lib"
generated "pkg.berachain.dev/polaris/contracts/bindings/cosmos/precompile/staking"
cosmlib "pkg.berachain.dev/polaris/cosmos/lib"
testutil "pkg.berachain.dev/polaris/cosmos/testing/utils"
testutil "pkg.berachain.dev/polaris/cosmos/testutil"
"pkg.berachain.dev/polaris/eth/accounts/abi"
"pkg.berachain.dev/polaris/eth/common"
ethprecompile "pkg.berachain.dev/polaris/eth/core/precompile"
Expand Down Expand Up @@ -88,7 +89,7 @@ var _ = Describe("Staking", func() {
)

BeforeEach(func() {
sdkCtx, ak, bk, sk = testutil.SetupMinimalKeepers()
sdkCtx, ak, bk, sk = testutil.SetupMinimalKeepers(log.NewTestLogger(GinkgoT()))
contract = libutils.MustGetAs[*Contract](NewPrecompileContract(ak, &sk))
sf = ethprecompile.NewStatefulFactory()
})
Expand Down
6 changes: 3 additions & 3 deletions cosmos/store/cachekv/readonly_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import (
"pkg.berachain.dev/polaris/eth/core/vm"
)

var _ storetypes.CacheKVStore = (*ReadOnlyStore)(nil)
var _ storetypes.KVStore = (*ReadOnlyStore)(nil)

// ReadOnlyStore is a wrapper around cachekv.Store that panics on any write operation.
type ReadOnlyStore struct {
storetypes.CacheKVStore
storetypes.KVStore
}

func NewReadOnlyStoreFor(cacheKVStore storetypes.CacheKVStore) *ReadOnlyStore {
func NewReadOnlyStoreFor(cacheKVStore storetypes.KVStore) *ReadOnlyStore {
return &ReadOnlyStore{cacheKVStore}
}

Expand Down
13 changes: 6 additions & 7 deletions cosmos/store/cachekv/readonly_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ package cachekv_test
import (
"testing"

sdkcachekv "cosmossdk.io/store/cachekv"
storetypes "cosmossdk.io/store/types"
cdb "github.com/cosmos/cosmos-db"

"cosmossdk.io/store/dbadapter"

"pkg.berachain.dev/polaris/cosmos/store/cachekv"
"pkg.berachain.dev/polaris/cosmos/testing/types/mock"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -42,10 +42,9 @@ var _ = Describe("ReadOnly Store", func() {
var readOnlyStore *cachekv.ReadOnlyStore

BeforeEach(func() {
ms := mock.NewMultiStore()
kv := ms.GetKVStore(storetypes.NewKVStoreKey("test"))
kv.Set([]byte("key"), []byte("value"))
readOnlyStore = cachekv.NewReadOnlyStoreFor(sdkcachekv.NewStore(kv))
kvStore := dbadapter.Store{DB: cdb.NewMemDB()}
kvStore.Set([]byte("key"), []byte("value"))
readOnlyStore = cachekv.NewReadOnlyStoreFor(kvStore)
})

It("should panic only on writes", func() {
Expand Down
Loading

0 comments on commit 32bc0d5

Please sign in to comment.