From 0429d90c77d8170e9cb5205e555bdbf277d4410d Mon Sep 17 00:00:00 2001 From: jianguo Date: Wed, 26 Jul 2023 21:53:41 +0800 Subject: [PATCH] update --- app/app.go | 4 ++++ x/wasm/keeper/keeper.go | 8 ++++++++ x/wasm/keeper/wasmtesting/mock_engine.go | 10 ++++++++++ x/wasm/module.go | 1 + x/wasm/types/wasmer_engine.go | 4 ++++ 5 files changed, 27 insertions(+) diff --git a/app/app.go b/app/app.go index 12b75d29d4..f39968507e 100644 --- a/app/app.go +++ b/app/app.go @@ -781,6 +781,7 @@ func NewOKExChainApp( } app.InitUpgrade(ctx) app.WasmKeeper.UpdateGasRegister(ctx) + app.WasmKeeper.UpdateCurBlockNum(ctx) } app.ScopedIBCKeeper = scopedIBCKeeper @@ -802,6 +803,9 @@ func (app *OKExChainApp) InitUpgrade(ctx sdk.Context) { tmtypes.InitMilestoneVenus6Height(int64(info.EffectiveHeight)) }) + // TODO + // app.WasmKeeper.UpdateMilestone(ctx, "wasm_v1", info.EffectiveHeight) + if err := app.ParamsKeeper.ApplyEffectiveUpgrade(ctx); err != nil { tmos.Exit(fmt.Sprintf("failed apply effective upgrade height info: %s", err)) } diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 6c9fffb549..e7703d3dd3 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -323,6 +323,14 @@ func (k *Keeper) UpdateGasRegister(ctx sdk.Context) { return } +func (k *Keeper) UpdateCurBlockNum(ctx sdk.Context) { + k.wasmVM.UpdateCurBlockNum(uint64(ctx.BlockHeight())) +} + +func (k *Keeper) UpdateMilestone(_ sdk.Context, milestone string, blockNum uint64) { + k.wasmVM.UpdateMilestone(milestone, blockNum) +} + func (k *Keeper) modifyGasFactor(ctx sdk.Context, extra string) error { result, err := types.NewActionModifyGasFactor(extra) if err != nil { diff --git a/x/wasm/keeper/wasmtesting/mock_engine.go b/x/wasm/keeper/wasmtesting/mock_engine.go index f2935c29e1..9f784ac32b 100644 --- a/x/wasm/keeper/wasmtesting/mock_engine.go +++ b/x/wasm/keeper/wasmtesting/mock_engine.go @@ -94,6 +94,16 @@ func (m *MockWasmer) AnalyzeCode(codeID wasmvm.Checksum) (*wasmvmtypes.AnalysisR return m.AnalyzeCodeFn(codeID) } +func (m *MockWasmer) UpdateCurBlockNum(_ uint64) error { + panic("UpdateCurBlockNum error ") + return nil +} + +func (m *MockWasmer) UpdateMilestone(_ string, _ uint64) error { + panic("UpdateMilestone error ") + return nil +} + func (m *MockWasmer) Instantiate(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { if m.InstantiateFn == nil { panic("not supposed to be called!") diff --git a/x/wasm/module.go b/x/wasm/module.go index b6f10c8779..098ea8ca33 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -186,6 +186,7 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { keeper.GetWasmParamsCache().SetNeedBlockedUpdate() } am.keeper.UpdateGasRegister(ctx) + am.keeper.UpdateCurBlockNum(ctx) } // EndBlock returns the end blocker for the wasm module. It returns no validator diff --git a/x/wasm/types/wasmer_engine.go b/x/wasm/types/wasmer_engine.go index 9b3cf71aac..b4e15452aa 100644 --- a/x/wasm/types/wasmer_engine.go +++ b/x/wasm/types/wasmer_engine.go @@ -24,6 +24,10 @@ type WasmerEngine interface { // Currently just reports if it exposes all IBC entry points. AnalyzeCode(checksum wasmvm.Checksum) (*wasmvmtypes.AnalysisReport, error) + UpdateCurBlockNum(_ uint64) error + + UpdateMilestone(milestone string, blockNum uint64) error + // Instantiate will create a new contract based on the given codeID. // We can set the initMsg (contract "genesis") here, and it then receives // an account and address and can be invoked (Execute) many times.