Skip to content

Commit

Permalink
Increase defaults on gnovm to allow init large avl.Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed May 30, 2023
1 parent 89ce7f8 commit f1c2501
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
35 changes: 35 additions & 0 deletions examples/gno.land/r/demo/art/haiku/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
haiku is a implementation of a smart contract for creating and transfering text-based NFTs that conform to haiku poetry standards.

The contract integrates a 240 kB wordlist into the contract that is used to check syllable counts and whether words are valid English, so that only valid Haikus can be added. Haikus are given a "rarity" score that can be used as a indicator of artificial scarcity.

Add this realm to gno.land:

gnokey maketx addpkg --pkgpath "gno.land/r/demo/art/haiku" --pkgdir "examples/gno.land/r/demo/art/haiku" --deposit 100000000ugnot --gas-fee 2000000000ugnot --gas-wanted 10000000000 --broadcast --chainid dev --remote localhost:26657 <YOURKEY>

Note: because of the word-list (240 kb) this realm takes a much higher gas than other realms. The gnovm actually had to be edited to be able to do this kind of transaction because it also takes some time and will timeout with the current defaults. Specifically, I had to increase the following parameters:

- `MaxTxBytes`, `MaxDataBytes` increased 10x (consensus parameters)
- `MaxGas` increased 1000x (consensus parameters)
- `TimeoutBroadcastTxCommit` increased 12x (RPC config)
- `maxAllocTx` increased 50x (keeper limits)
- `MaxCycles` increased 100 times (`AddPackage` config)


Mint a haiku:

gnokey maketx call --pkgpath "gno.land/r/demo/art/haiku" --func "Mint" --args "Knock over a plant,\ncat's innocent eyes proclaim,\n'Nature needed that!'" --gas-fee "1000000ugnot" --gas-wanted "8000000" --broadcast --chainid dev --remote localhost:26657 <YOURKEY>

Transfer a haiku:

gnokey maketx call --pkgpath "gno.land/r/demo/art/haiku" --func "Transfer" --args "g1k673c6704gzv9qyadjxv045etrysmk60ukug59" --args "be95708bce28ee9eea54a3ab6a719e24b9408aa753c3583ad8a2336b87ec3ca9" --gas-fee "1000000ugnot" --gas-wanted "8000000" --broadcast --chainid dev --remote localhost:26657 <OWNERKEY>

In this case the `g1k673c6704gzv9qyadjxv045etrysmk60ukug59` is the recipient address and the `be95708bce28ee9eea54a3ab6a719e24b9408aa753c3583ad8a2336b87ec3ca9` is the token ID of the haiku to transfer (available from gno.land). Only owners can transfer.

Register a user:

gnokey maketx call --pkgpath "gno.land/r/demo/users" --func "Register" --args "" --args "schollz" --args "https://schollz.com" --gas-fee "1000000ugnot" --gas-wanted "2000000" --broadcast --chainid dev --remote localhost:26657 --send "200000000ugnot" <YOURKEY>

If you register a user, then your username will show up on the haiku pages instead of the address, using the `users` realm.



8 changes: 4 additions & 4 deletions gno.land/cmd/gnoland/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ func makeGenesisDoc(
gen.ConsensusParams = abci.ConsensusParams{
Block: &abci.BlockParams{
// TODO: update limits.
MaxTxBytes: 1000000, // 1MB,
MaxDataBytes: 2000000, // 2MB,
MaxGas: 10000000, // 10M gas
TimeIotaMS: 100, // 100ms
MaxTxBytes: 10000000, // 10MB,
MaxDataBytes: 20000000, // 20MB,
MaxGas: 100000000000, // 100000M gas
TimeIotaMS: 100, // 100ms
},
}
gen.Validators = []bft.GenesisValidator{
Expand Down
2 changes: 1 addition & 1 deletion tm2/pkg/bft/rpc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func DefaultRPCConfig() *RPCConfig {
Unsafe: false,
MaxOpenConnections: 900,

TimeoutBroadcastTxCommit: 10 * time.Second,
TimeoutBroadcastTxCommit: 120 * time.Second,

MaxBodyBytes: int64(1000000), // 1MB
MaxHeaderBytes: 1 << 20, // same as the net/http default
Expand Down
4 changes: 2 additions & 2 deletions tm2/pkg/sdk/vm/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
maxAllocTx = 500 * 1000 * 1000
maxAllocTx = 25000 * 1000 * 1000
maxAllocQuery = 1500 * 1000 * 1000 // higher limit for queries
)

Expand Down Expand Up @@ -174,7 +174,7 @@ func (vm *VMKeeper) AddPackage(ctx sdk.Context, msg MsgAddPackage) error {
Store: store,
Alloc: store.GetAllocator(),
Context: msgCtx,
MaxCycles: 10 * 1000 * 1000, // 10M cycles // XXX
MaxCycles: 1000 * 1000 * 1000, // 1000M cycles // XXX
})
defer m2.Release()
m2.RunMemPackage(memPkg, true)
Expand Down

0 comments on commit f1c2501

Please sign in to comment.