diff --git a/gno.land/pkg/sdk/vm/keeper.go b/gno.land/pkg/sdk/vm/keeper.go index f16c051167d..15408d8351e 100644 --- a/gno.land/pkg/sdk/vm/keeper.go +++ b/gno.land/pkg/sdk/vm/keeper.go @@ -207,9 +207,9 @@ var gnoStoreContextKey gnoStoreContextKeyType func (vm *VMKeeper) newGnoTransactionStore(ctx sdk.Context) gno.TransactionStore { base := ctx.Store(vm.baseKey) iavl := ctx.Store(vm.iavlKey) - vm.gnoStore.SetGasMeter(ctx.GasMeter()) + gasMeter := ctx.GasMeter() - return vm.gnoStore.BeginTransaction(base, iavl) + return vm.gnoStore.BeginTransaction(base, iavl, gasMeter) } func (vm *VMKeeper) MakeGnoTransactionStore(ctx sdk.Context) sdk.Context { diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index 78b11a4ebc5..49de5a6f18d 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -3115,7 +3115,7 @@ func evalStaticType(store Store, last BlockNode, x Expr) Type { // See comment in evalStaticTypeOfRaw. if store != nil && pn.PkgPath != uversePkgPath { pv := pn.NewPackage() // temporary - store = store.BeginTransaction(nil, nil) + store = store.BeginTransaction(nil, nil, nil) store.SetCachePackage(pv) } m := NewMachine(pn.PkgPath, store) @@ -3183,7 +3183,7 @@ func evalStaticTypeOfRaw(store Store, last BlockNode, x Expr) (t Type) { // yet predefined this time around. if store != nil && pn.PkgPath != uversePkgPath { pv := pn.NewPackage() // temporary - store = store.BeginTransaction(nil, nil) + store = store.BeginTransaction(nil, nil, nil) store.SetCachePackage(pv) } m := NewMachine(pn.PkgPath, store) diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index d6c839f05f0..18c9b6146d3 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -34,7 +34,7 @@ type NativeResolver func(pkgName string, name Name) func(m *Machine) // blockchain, or the file system. type Store interface { // STABLE - BeginTransaction(baseStore, iavlStore store.Store) TransactionStore + BeginTransaction(baseStore, iavlStore store.Store, gasMeter store.GasMeter) TransactionStore SetPackageGetter(PackageGetter) GetPackage(pkgPath string, isImport bool) *PackageValue SetCachePackage(*PackageValue) @@ -51,7 +51,7 @@ type Store interface { GetBlockNode(Location) BlockNode // to get a PackageNode, use PackageNodeLocation(). GetBlockNodeSafe(Location) BlockNode SetBlockNode(BlockNode) - SetGasMeter(store.GasMeter) + // UNSTABLE Go2GnoType(rt reflect.Type) Type GetAllocator() *Allocator @@ -171,7 +171,7 @@ func NewStore(alloc *Allocator, baseStore, iavlStore store.Store) *defaultStore } // If nil baseStore and iavlStore, the baseStores are re-used. -func (ds *defaultStore) BeginTransaction(baseStore, iavlStore store.Store) TransactionStore { +func (ds *defaultStore) BeginTransaction(baseStore, iavlStore store.Store, gasMeter store.GasMeter) TransactionStore { if baseStore == nil { baseStore = ds.baseStore } @@ -195,7 +195,7 @@ func (ds *defaultStore) BeginTransaction(baseStore, iavlStore store.Store) Trans nativeResolver: ds.nativeResolver, // gas meter - gasMeter: ds.gasMeter, + gasMeter: gasMeter, gasConfig: ds.gasConfig, // transient @@ -744,10 +744,6 @@ func (ds *defaultStore) IterMemPackage() <-chan *gnovm.MemPackage { } } -func (ds *defaultStore) SetGasMeter(gm store.GasMeter) { - ds.gasMeter = gm -} - func (ds *defaultStore) consumeGas(gas int64, descriptor string) { // In the tests, the defaultStore may not set the gas meter. if ds.gasMeter != nil { diff --git a/gnovm/pkg/gnolang/store_test.go b/gnovm/pkg/gnolang/store_test.go index e280032e3d9..c4fc52a9c7c 100644 --- a/gnovm/pkg/gnolang/store_test.go +++ b/gnovm/pkg/gnolang/store_test.go @@ -17,7 +17,7 @@ func TestTransactionStore(t *testing.T) { st := NewStore(nil, tm2Store, tm2Store) wrappedTm2Store := tm2Store.CacheWrap() - txSt := st.BeginTransaction(wrappedTm2Store, wrappedTm2Store) + txSt := st.BeginTransaction(wrappedTm2Store, wrappedTm2Store, nil) m := NewMachineWithOptions(MachineOptions{ PkgPath: "hello", Store: txSt, @@ -86,7 +86,7 @@ func TestCopyFromCachedStore(t *testing.T) { d1s := dbadapter.StoreConstructor(d1, storetypes.StoreOptions{}) d2s := dbadapter.StoreConstructor(d2, storetypes.StoreOptions{}) destStore := NewStore(nil, d1s, d2s) - destStoreTx := destStore.BeginTransaction(nil, nil) // CopyFromCachedStore requires a tx store. + destStoreTx := destStore.BeginTransaction(nil, nil, nil) // CopyFromCachedStore requires a tx store. CopyFromCachedStore(destStoreTx, cachedStore, c1s, c2s) destStoreTx.Write()