Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zjg555543 committed Jul 26, 2023
1 parent 70ba6b4 commit 0429d90
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ func NewOKExChainApp(
}
app.InitUpgrade(ctx)
app.WasmKeeper.UpdateGasRegister(ctx)
app.WasmKeeper.UpdateCurBlockNum(ctx)
}

app.ScopedIBCKeeper = scopedIBCKeeper
Expand All @@ -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))
}
Expand Down
8 changes: 8 additions & 0 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions x/wasm/keeper/wasmtesting/mock_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
1 change: 1 addition & 0 deletions x/wasm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions x/wasm/types/wasmer_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0429d90

Please sign in to comment.