Skip to content

Commit

Permalink
deploy statekeys
Browse files Browse the repository at this point in the history
  • Loading branch information
samliok committed Oct 8, 2024
1 parent c5da65f commit 66ea4e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/updated-vm-with-contracts/actions/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ func (*Deploy) ComputeUnits(chain.Rules) uint64 {
return consts.DeployUnits
}

// Why is StateKeysMaxChunks part of the action interface?
func (d *Deploy) StateKeysMaxChunks() []uint16 {
return []uint16{uint16(len(d.ContractBytes) / 64), uint16(1)}
byteChunks := storage.MaxContractSize / consts.ChunkSize
accountKeyChunks := uint16(1)
return []uint16{uint16(byteChunks), accountKeyChunks}
}

// Specify all statekeys Execute can touch
Expand Down
3 changes: 3 additions & 0 deletions examples/updated-vm-with-contracts/consts/units.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package consts
const (
ChunkSize = 64

DeployUnits = 1
CallUnits = 2

)
2 changes: 2 additions & 0 deletions examples/updated-vm-with-contracts/storage/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/hypersdk/codec"
"github.com/ava-labs/hypersdk/keys"
"github.com/ava-labs/hypersdk/state"
Expand All @@ -21,6 +22,7 @@ var (
const (
AccountTypeID = 0
MaxKeySize = 36
MaxContractSize = units.MiB * 4
)

var _ runtime.StateManager = (*ContractStateManager)(nil)
Expand Down

0 comments on commit 66ea4e9

Please sign in to comment.