Skip to content

Commit 508c03a

Browse files
authored
Merge pull request #1710 from scrtlabs/cron-module
draft: cron module
2 parents 9a9edc8 + b730cf0 commit 508c03a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+8736
-46
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ jobs:
201201
echo "not_a_key" > ias_keys/develop/api_key.txt
202202
LOG_LEVEL=ERROR go test -v -tags "test" ./x/compute/client/...
203203
LOG_LEVEL=ERROR SKIP_LIGHT_CLIENT_VALIDATION=TRUE go test -p 1 -timeout 90m -v -tags "test" ./x/compute/internal/...
204-
204+
- name: Test x/cron
205+
run: |
206+
source "$HOME/.sgxsdk/sgxsdk/environment"
207+
export SGX_MODE=SW
208+
LOG_LEVEL=ERROR go test -v -tags "test" ./x/cron/...
205209
Clippy:
206210
runs-on: ubuntu-22.04
207211
steps:

app/app.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import (
8484
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
8585
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
8686
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
87+
crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types"
8788

8889
"cosmossdk.io/log"
8990
upgradetypes "cosmossdk.io/x/upgrade/types"
@@ -326,6 +327,7 @@ func NewSecretNetworkApp(
326327
panic(err)
327328
}
328329
app.txConfig = txConfig
330+
app.AppKeepers.CronKeeper.SetTxConfig(txConfig)
329331

330332
app.AppKeepers.InitCustomKeepers(appCodec, legacyAmino, bApp, bootstrap, homePath, computeConfig)
331333
app.setupUpgradeStoreLoaders()
@@ -595,6 +597,7 @@ func SetOrderBeginBlockers(app *SecretNetworkApp) {
595597
compute.ModuleName,
596598
reg.ModuleName,
597599
ibcswitchtypes.ModuleName,
600+
crontypes.ModuleName,
598601
circuittypes.ModuleName,
599602
)
600603
}
@@ -628,6 +631,7 @@ func SetOrderInitGenesis(app *SecretNetworkApp) {
628631

629632
ibcfeetypes.ModuleName,
630633
feegrant.ModuleName,
634+
crontypes.ModuleName,
631635
circuittypes.ModuleName,
632636
)
633637
}
@@ -657,6 +661,7 @@ func SetOrderEndBlockers(app *SecretNetworkApp) {
657661
compute.ModuleName,
658662
reg.ModuleName,
659663
ibcswitchtypes.ModuleName,
664+
crontypes.ModuleName,
660665
circuittypes.ModuleName,
661666
)
662667
}

app/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
3434
ibc "github.com/cosmos/ibc-go/v8/modules/core"
3535
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
36+
"github.com/scrtlabs/SecretNetwork/x/cron"
3637
ibcswitch "github.com/scrtlabs/SecretNetwork/x/emergencybutton"
3738

3839
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -78,6 +79,7 @@ var mbasics = module.NewBasicManager(
7879
ica.AppModuleBasic{},
7980
packetforwardrouter.AppModuleBasic{},
8081
ibcfee.AppModuleBasic{},
82+
cron.AppModuleBasic{},
8183
},
8284
// our stuff
8385
customModuleBasics()...,

app/keepers/keepers.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ import (
5555
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
5656
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
5757
"github.com/scrtlabs/SecretNetwork/x/compute"
58+
cronkeeper "github.com/scrtlabs/SecretNetwork/x/cron/keeper"
59+
crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types"
60+
5861
reg "github.com/scrtlabs/SecretNetwork/x/registration"
5962

6063
ibcpacketforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/keeper"
@@ -81,6 +84,7 @@ type SecretAppKeepers struct {
8184
AuthzKeeper *authzkeeper.Keeper
8285
BankKeeper *bankkeeper.BaseKeeper
8386
CapabilityKeeper *capabilitykeeper.Keeper
87+
CronKeeper *cronkeeper.Keeper
8488
StakingKeeper *stakingkeeper.Keeper
8589
SlashingKeeper *slashingkeeper.Keeper
8690
MintKeeper *mintkeeper.Keeper
@@ -237,6 +241,15 @@ func (ak *SecretAppKeepers) InitSdkKeepers(
237241
)
238242
ak.CircuitKeeper = &circuitKeeper
239243

244+
cronKeeper := cronkeeper.NewKeeper(
245+
appCodec,
246+
ak.keys[crontypes.StoreKey],
247+
ak.memKeys[crontypes.StoreKey],
248+
ak.AccountKeeper,
249+
authtypes.NewModuleAddress(crontypes.ModuleName).String(),
250+
)
251+
ak.CronKeeper = cronKeeper
252+
240253
feegrantKeeper := feegrantkeeper.NewKeeper(
241254
appCodec,
242255
runtime.NewKVStoreService(ak.keys[feegrant.StoreKey]),
@@ -370,6 +383,7 @@ func (ak *SecretAppKeepers) InitCustomKeepers(
370383
bootstrap,
371384
)
372385
ak.RegKeeper = &regKeeper
386+
ak.CronKeeper.SetRegKeeper(regKeeper)
373387

374388
// Assaf:
375389
// Rules:
@@ -515,6 +529,7 @@ func (ak *SecretAppKeepers) InitCustomKeepers(
515529
runtime.NewKVStoreService(ak.keys[compute.StoreKey]),
516530
*ak.AccountKeeper,
517531
ak.BankKeeper,
532+
*ak.CronKeeper,
518533
*ak.GovKeeper,
519534
*ak.DistrKeeper,
520535
*ak.MintKeeper,
@@ -589,6 +604,7 @@ func (ak *SecretAppKeepers) InitKeys() {
589604
ibcswitch.StoreKey,
590605
ibchookstypes.StoreKey,
591606
circuittypes.StoreKey,
607+
crontypes.StoreKey,
592608
)
593609

594610
ak.tKeys = storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
@@ -612,6 +628,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
612628
paramsKeeper.Subspace(compute.ModuleName)
613629
paramsKeeper.Subspace(reg.ModuleName)
614630
paramsKeeper.Subspace(ibcswitch.ModuleName).WithKeyTable(ibcswitchtypes.ParamKeyTable())
631+
paramsKeeper.Subspace(crontypes.ModuleName)
615632

616633
return paramsKeeper
617634
}

app/modules.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import (
3939
ibc "github.com/cosmos/ibc-go/v8/modules/core"
4040
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
4141
"github.com/scrtlabs/SecretNetwork/x/compute"
42+
"github.com/scrtlabs/SecretNetwork/x/cron"
43+
crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types"
4244
ibcswitch "github.com/scrtlabs/SecretNetwork/x/emergencybutton"
4345
reg "github.com/scrtlabs/SecretNetwork/x/registration"
4446
)
@@ -55,6 +57,7 @@ var ModuleAccountPermissions = map[string][]string{
5557
ibcfeetypes.ModuleName: nil,
5658
ibcswitch.ModuleName: nil,
5759
compute.ModuleName: {authtypes.Burner},
60+
crontypes.ModuleName: nil,
5861
}
5962

6063
func Modules(
@@ -88,5 +91,6 @@ func Modules(
8891
packetforward.NewAppModule(app.AppKeepers.PacketForwardKeeper, app.AppKeepers.GetSubspace(packetforwardtypes.ModuleName)),
8992
ibcfee.NewAppModule(app.AppKeepers.IbcFeeKeeper),
9093
ibcswitch.NewAppModule(app.AppKeepers.IbcSwitchKeeper, app.AppKeepers.GetSubspace(ibcswitch.ModuleName)),
94+
cron.NewAppModule(app.appCodec, *app.AppKeepers.CronKeeper),
9195
}
9296
}

cosmwasm/enclaves/Cargo.lock

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmwasm/enclaves/execute/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ block-verifier = { path = "../shared/block-verifier", optional = true }
9191
time = "=0.3.17"
9292
ed25519-dalek = { version = "1.0", default-features = false }
9393
sha2 = "0.10"
94-
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] }
95-
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false }
96-
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] }
94+
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] }
95+
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false }
96+
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] }
9797

9898
[dependencies.webpki]
9999
git = "https://github.com/mesalock-linux/webpki"

cosmwasm/enclaves/execute/Enclave.edl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ enclave {
199199
[in, count=in_encrypted_random_len] const uint8_t* in_encrypted_random,
200200
uintptr_t in_encrypted_random_len,
201201
[out, count=32] uint8_t* decrypted,
202-
[out, count=32] uint8_t* next_validator_set_evidence
202+
[out, count=32] uint8_t* next_validator_set_evidence,
203+
[in, count=in_cron_msgs_len] const uint8_t* in_cron_msgs,
204+
uintptr_t in_cron_msgs_len
203205
);
204206
};
205207

cosmwasm/enclaves/execute/src/ecalls.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub unsafe extern "C" fn ecall_submit_block_signatures(
1717
in_encrypted_random_len: u32,
1818
decrypted_random: &mut [u8; 32],
1919
next_validator_set_evidence: &mut [u8; 32],
20+
in_cron_msgs: *const u8,
21+
in_cron_msgs_len: u32,
2022
) -> sgx_status_t {
2123
#[cfg(feature = "light-client-validation")]
2224
{
@@ -31,6 +33,8 @@ pub unsafe extern "C" fn ecall_submit_block_signatures(
3133
in_encrypted_random_len,
3234
decrypted_random,
3335
next_validator_set_evidence,
36+
in_cron_msgs,
37+
in_cron_msgs_len,
3438
)
3539
}
3640

cosmwasm/enclaves/shared/block-verifier/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ sgx_trts = {rev = "d2d339cbb005f676bb700059bd51dc689c025f6b", git = "https://git
1818
sgx_types = { rev = "d2d339cbb005f676bb700059bd51dc689c025f6b", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
1919

2020
[dependencies]
21-
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] }
22-
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false }
23-
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] }
21+
sha2 = "0.10"
22+
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] }
23+
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false }
24+
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] }
2425
lazy_static = "1.4.0"
2526
log = "0.4.17"
2627

0 commit comments

Comments
 (0)