diff --git a/examples/updated-vm-with-contracts/actions/deploy.go b/examples/updated-vm-with-contracts/actions/deploy.go index bd82b1fd08..791f24a1f3 100644 --- a/examples/updated-vm-with-contracts/actions/deploy.go +++ b/examples/updated-vm-with-contracts/actions/deploy.go @@ -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 diff --git a/examples/updated-vm-with-contracts/consts/units.go b/examples/updated-vm-with-contracts/consts/units.go index b19ed53298..48beec9c46 100644 --- a/examples/updated-vm-with-contracts/consts/units.go +++ b/examples/updated-vm-with-contracts/consts/units.go @@ -1,5 +1,8 @@ package consts const ( + ChunkSize = 64 + DeployUnits = 1 CallUnits = 2 + ) \ No newline at end of file diff --git a/examples/updated-vm-with-contracts/storage/contract.go b/examples/updated-vm-with-contracts/storage/contract.go index 3d1665f1e3..805800c6f0 100644 --- a/examples/updated-vm-with-contracts/storage/contract.go +++ b/examples/updated-vm-with-contracts/storage/contract.go @@ -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" @@ -21,6 +22,7 @@ var ( const ( AccountTypeID = 0 MaxKeySize = 36 + MaxContractSize = units.MiB * 4 ) var _ runtime.StateManager = (*ContractStateManager)(nil)