Skip to content

Commit aae46b5

Browse files
committed
fix the execution order of scheduled messages within the enclave
1 parent 63fc721 commit aae46b5

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

app/keepers/keepers.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,6 @@ func (ak *SecretAppKeepers) InitCustomKeepers(
552552
ak.ComputeKeeper = &computeKeeper
553553
wasmHooks.ContractKeeper = ak.ComputeKeeper
554554

555-
// wasmMsgServer := compute.NewMsgServerImpl(*ak.ComputeKeeper)
556-
// fmt.Printf("wasmMsgServer: %+v\n", wasmMsgServer)
557-
// ak.CronKeeper.WasmMsgServer = compute.NewCronWasmMsgServerAdapter(wasmMsgServer)
558-
// ak.ComputeKeeper.SetCronKeeper(*ak.CronKeeper)
559-
// fmt.Printf("ak.CronKeeper.WasmMsgServer: %+v\n", ak.CronKeeper.WasmMsgServer)
560-
561555
// Compute receive: Switch -> Fee -> Packet Forward -> WASM Hooks
562556
var computeStack porttypes.IBCModule
563557
computeStack = compute.NewIBCHandler(ak.ComputeKeeper, ak.IbcKeeper.ChannelKeeper, ak.IbcFeeKeeper)

cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,6 @@ pub unsafe fn submit_block_signatures_impl(
122122
message_verifier.clear();
123123
}
124124

125-
for tx in txs.iter() {
126-
// doing this a different way makes the code unreadable or requires creating a copy of
127-
128-
let parsed_tx = unwrap_or_return!(tx_from_bytes(tx.as_slice()).map_err(|_| {
129-
error!("Unable to parse tx bytes from proto");
130-
sgx_status_t::SGX_ERROR_INVALID_PARAMETER
131-
}));
132-
133-
message_verifier.append_msg_from_tx(parsed_tx);
134-
}
135-
136125
let mut hasher = Sha256::new();
137126
hasher.update(cron_msgs_slice);
138127
let hash_result = hasher.finalize();
@@ -152,12 +141,21 @@ pub unsafe fn submit_block_signatures_impl(
152141
sgx_status_t::SGX_ERROR_INVALID_PARAMETER
153142
}));
154143

155-
dbg!(&parsed_cron_msg);
156-
157144
message_verifier.append_msg_from_tx(parsed_cron_msg);
158145
}
159146
}
160147

148+
for tx in txs.iter() {
149+
// doing this a different way makes the code unreadable or requires creating a copy of
150+
151+
let parsed_tx = unwrap_or_return!(tx_from_bytes(tx.as_slice()).map_err(|_| {
152+
error!("Unable to parse tx bytes from proto");
153+
sgx_status_t::SGX_ERROR_INVALID_PARAMETER
154+
}));
155+
156+
message_verifier.append_msg_from_tx(parsed_tx);
157+
}
158+
161159
message_verifier.set_block_info(
162160
header.header.height.value(),
163161
header.header.time.unix_timestamp_nanos(),

x/compute/module.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ func (am AppModule) BeginBlock(c context.Context) error {
158158
ctx.Logger().Error("Failed to get scheduled cron msgs")
159159
return err
160160
}
161-
// hash := sha256.Sum256([]byte("random"))
162-
// block_header.ImplicitHash = hash[:]
163-
// block_header.AppHash = hash[:]
164161

165162
cron_msgs := tm_type.Data{Txs: bytesCronMsgs}
166163
cron_data, err := cron_msgs.Marshal()
@@ -198,17 +195,13 @@ func (am AppModule) BeginBlock(c context.Context) error {
198195
}
199196

200197
for idx, msg := range execCronMsgs {
201-
fmt.Printf("idx, msg: %+v %+v\n", idx, msg)
202198
ctx = ctx.WithTxBytes(bytesCronMsgs[idx])
203199
_, err := am.keeper.Execute(ctx, msg.Contract, msg.Sender, msg.Msg, msg.SentFunds, msg.CallbackSig, wasmtypes.HandleTypeExecute)
204200
if err != nil {
205201
ctx.Logger().Error("Failed to execute cron message", "error", err)
206-
// return err
207202
}
208203
}
209204

210-
fmt.Printf("setRandomSeed\n")
211-
212205
am.keeper.SetRandomSeed(ctx, random, validator_set_evidence)
213206
} else {
214207
ctx.Logger().Debug("Non-encrypted block", "Block_hash", block_header.LastBlockId.Hash, "Height", ctx.BlockHeight(), "Txs", len(x2_data))

0 commit comments

Comments
 (0)