Skip to content

Commit 90e59b7

Browse files
committed
e2e: allow PoA admin override with ENV variable
1 parent f67be75 commit 90e59b7

File tree

2 files changed

+112
-20
lines changed

2 files changed

+112
-20
lines changed

app/app.go

+29-20
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,15 @@ import (
139139
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
140140
)
141141

142-
// !IMPORTANT: testnet only (reece's addr)
143-
const POAAdmin = "manifest10r39fueph9fq7a6lgswu4zdsg8t3gxlqdwwncm"
142+
func GetPoAAdmin() string {
143+
// used only in e2e testing with interchaintest
144+
if address := os.Getenv("OVERRIDE_POA_ADMIN_ADDRESS"); address != "" {
145+
return address
146+
}
147+
148+
// !IMPORTANT: testnet only (reece's addr). Change this to a mainnet address
149+
return "manifest10r39fueph9fq7a6lgswu4zdsg8t3gxlqdwwncm"
150+
}
144151

145152
// We pull these out so we can set them with LDFLAGS in the Makefile
146153
var (
@@ -344,7 +351,7 @@ func NewApp(
344351
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(
345352
appCodec,
346353
runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]),
347-
POAAdmin,
354+
GetPoAAdmin(),
348355
runtime.EventService{},
349356
)
350357
bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore)
@@ -371,14 +378,14 @@ func NewApp(
371378
maccPerms,
372379
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()),
373380
sdk.GetConfig().GetBech32AccountAddrPrefix(),
374-
POAAdmin,
381+
GetPoAAdmin(),
375382
)
376383
app.BankKeeper = bankkeeper.NewBaseKeeper(
377384
appCodec,
378385
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
379386
app.AccountKeeper,
380387
BlockedAddresses(),
381-
POAAdmin,
388+
GetPoAAdmin(),
382389
logger,
383390
)
384391

@@ -387,7 +394,7 @@ func NewApp(
387394
runtime.NewKVStoreService(keys[stakingtypes.StoreKey]),
388395
app.AccountKeeper,
389396
app.BankKeeper,
390-
POAAdmin,
397+
GetPoAAdmin(),
391398
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
392399
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
393400
)
@@ -398,7 +405,7 @@ func NewApp(
398405
app.AccountKeeper,
399406
app.BankKeeper,
400407
authtypes.FeeCollectorName,
401-
POAAdmin,
408+
GetPoAAdmin(),
402409
)
403410

404411
app.DistrKeeper = distrkeeper.NewKeeper(
@@ -408,15 +415,15 @@ func NewApp(
408415
app.BankKeeper,
409416
app.StakingKeeper,
410417
authtypes.FeeCollectorName,
411-
POAAdmin,
418+
GetPoAAdmin(),
412419
)
413420

414421
app.SlashingKeeper = slashingkeeper.NewKeeper(
415422
appCodec,
416423
legacyAmino,
417424
runtime.NewKVStoreService(keys[slashingtypes.StoreKey]),
418425
app.StakingKeeper,
419-
POAAdmin,
426+
GetPoAAdmin(),
420427
)
421428

422429
app.POAKeeper = poakeeper.NewKeeper(
@@ -436,7 +443,7 @@ func NewApp(
436443
invCheckPeriod,
437444
app.BankKeeper,
438445
authtypes.FeeCollectorName,
439-
POAAdmin,
446+
GetPoAAdmin(),
440447
app.AccountKeeper.AddressCodec(),
441448
)
442449

@@ -451,7 +458,7 @@ func NewApp(
451458
app.CircuitKeeper = circuitkeeper.NewKeeper(
452459
appCodec,
453460
runtime.NewKVStoreService(keys[circuittypes.StoreKey]),
454-
POAAdmin,
461+
GetPoAAdmin(),
455462
app.AccountKeeper.AddressCodec(),
456463
)
457464
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)
@@ -487,7 +494,7 @@ func NewApp(
487494
appCodec,
488495
homePath,
489496
app.BaseApp,
490-
POAAdmin,
497+
GetPoAAdmin(),
491498
)
492499

493500
app.IBCKeeper = ibckeeper.NewKeeper(
@@ -497,7 +504,7 @@ func NewApp(
497504
app.StakingKeeper,
498505
app.UpgradeKeeper,
499506
scopedIBCKeeper,
500-
POAAdmin,
507+
GetPoAAdmin(),
501508
)
502509

503510
// Register the proposal types
@@ -523,7 +530,7 @@ func NewApp(
523530
app.DistrKeeper,
524531
app.MsgServiceRouter(),
525532
govConfig,
526-
POAAdmin,
533+
GetPoAAdmin(),
527534
)
528535

529536
app.GovKeeper = *govKeeper.SetHooks(
@@ -558,7 +565,7 @@ func NewApp(
558565
app.MintKeeper,
559566
app.BankKeeper,
560567
logger,
561-
POAAdmin,
568+
GetPoAAdmin(),
562569
)
563570

564571
// Create the TokenFactory Keeper
@@ -570,7 +577,7 @@ func NewApp(
570577
app.DistrKeeper,
571578
tokenFactoryCapabilities,
572579
app.POAKeeper.IsAdmin,
573-
POAAdmin,
580+
GetPoAAdmin(),
574581
)
575582

576583
// IBC Fee Module keeper
@@ -592,7 +599,7 @@ func NewApp(
592599
app.AccountKeeper,
593600
app.BankKeeper,
594601
scopedTransferKeeper,
595-
POAAdmin,
602+
GetPoAAdmin(),
596603
)
597604

598605
app.ICAHostKeeper = icahostkeeper.NewKeeper(
@@ -605,7 +612,7 @@ func NewApp(
605612
app.AccountKeeper,
606613
scopedICAHostKeeper,
607614
app.MsgServiceRouter(),
608-
POAAdmin,
615+
GetPoAAdmin(),
609616
)
610617
app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
611618
appCodec,
@@ -616,7 +623,7 @@ func NewApp(
616623
app.IBCKeeper.PortKeeper,
617624
scopedICAControllerKeeper,
618625
app.MsgServiceRouter(),
619-
POAAdmin,
626+
GetPoAAdmin(),
620627
)
621628

622629
// Set legacy router for backwards compatibility with gov v1beta1
@@ -841,6 +848,8 @@ func NewApp(
841848
app.ScopedICAHostKeeper = scopedICAHostKeeper
842849
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
843850

851+
app.setAnteHandler(txConfig)
852+
844853
// In v0.46, the SDK introduces _postHandlers_. PostHandlers are like
845854
// antehandlers, but are run _after_ the `runMsgs` execution. They are also
846855
// defined as a chain, and have the same signature as antehandlers.
@@ -1123,7 +1132,7 @@ func BlockedAddresses() map[string]bool {
11231132
}
11241133

11251134
// allow the following addresses to receive funds
1126-
delete(modAccAddrs, POAAdmin)
1135+
delete(modAccAddrs, govtypes.ModuleName)
11271136

11281137
return modAccAddrs
11291138
}

interchaintest/mainfest_test.go

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package interchaintest
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"testing"
7+
8+
"github.com/strangelove-ventures/interchaintest/v8"
9+
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
10+
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
11+
"github.com/stretchr/testify/require"
12+
"go.uber.org/zap/zapcore"
13+
"go.uber.org/zap/zaptest"
14+
)
15+
16+
func TestManifest(t *testing.T) {
17+
t.Parallel()
18+
19+
ctx := context.Background()
20+
cfgA := LocalChainConfig
21+
cfgA.Env = []string{
22+
fmt.Sprintf("OVERRIDE_POA_ADMIN_ADDRESS=%s", accAddr),
23+
}
24+
25+
fmt.Printf("cfgA: %+v\n", cfgA)
26+
27+
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t, zaptest.Level(zapcore.DebugLevel)), []*interchaintest.ChainSpec{
28+
{
29+
Name: "manifest",
30+
Version: "local",
31+
ChainName: cfgA.ChainID,
32+
NumValidators: &vals,
33+
NumFullNodes: &fullNodes,
34+
ChainConfig: cfgA,
35+
},
36+
//
37+
})
38+
39+
chains, err := cf.Chains(t.Name())
40+
require.NoError(t, err)
41+
manifestA := chains[0].(*cosmos.CosmosChain)
42+
43+
// Relayer Factory
44+
client, network := interchaintest.DockerSetup(t)
45+
46+
ic := interchaintest.NewInterchain().
47+
AddChain(manifestA)
48+
49+
rep := testreporter.NewNopReporter()
50+
eRep := rep.RelayerExecReporter(t)
51+
52+
// Build interchain
53+
require.NoError(t, ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{
54+
TestName: t.Name(),
55+
Client: client,
56+
NetworkID: network,
57+
SkipPathCreation: false,
58+
}))
59+
60+
// Chains
61+
appChain := chains[0].(*cosmos.CosmosChain)
62+
63+
// load in the PoA admin to sudo mint via the TokenFactory
64+
poaAdmin, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, "acc0", accMnemonic, DefaultGenesisAmt, appChain)
65+
if err != nil {
66+
t.Fatal(err)
67+
}
68+
poaAdminAddr := poaAdmin.FormattedAddress()
69+
t.Logf("poaAdminAddr: %s\n", poaAdminAddr)
70+
71+
// users := interchaintest.GetAndFundTestUsers(t, ctx, "default", DefaultGenesisAmt, appChain, appChain)
72+
// user := users[0]
73+
// uaddr := user.FormattedAddress()
74+
75+
// user2 := users[1]
76+
// uaddr2 := user2.FormattedAddress()
77+
78+
// node := appChain.GetNode()
79+
80+
t.Cleanup(func() {
81+
_ = ic.Close()
82+
})
83+
}

0 commit comments

Comments
 (0)