Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with atree inlining and data deduplication #2882

Merged
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dbbb777
Integrate with atree inlining and deduplication
fxamacker Oct 19, 2023
ca1a9ea
Fix lint warnings
fxamacker Oct 19, 2023
bc7b622
Use UnreachableError in panic
fxamacker Oct 19, 2023
bfd43ca
Simplify TypeInfo.Identifier()
fxamacker Oct 19, 2023
713c6c3
Reformat with extra lines for readability
fxamacker Oct 19, 2023
e9ae0d2
meter allocations of array static types
turbolent Oct 19, 2023
cba775c
disable atree validation for memory metering tests, adjust expected v…
turbolent Oct 19, 2023
5e51834
pass proper location range
turbolent Oct 20, 2023
a93c048
simplify dictionary iterator to just support key iteration, which all…
turbolent Oct 20, 2023
da81afe
use type ID constructor function
turbolent Oct 20, 2023
936c6e4
SomeStorable.Encode should not ever be called. use proper encode func…
turbolent Oct 20, 2023
13950f9
address TODOs: Identifier functions can use StaticType.ID, Copy can r…
turbolent Oct 20, 2023
f52f42a
Update to use latest Atree inlining
fxamacker Oct 22, 2023
aa087cf
Refactor SomeStorable encoding
fxamacker Oct 24, 2023
1b673ea
Update to use latest Atree inlining
fxamacker Oct 24, 2023
f01949a
lower size of generated containers
turbolent Oct 24, 2023
e268003
add tests for "moving" struct and composite between arrays, and mutat…
turbolent Oct 24, 2023
2f3642f
Cleanup and add more comments
fxamacker Oct 25, 2023
5c2ee46
Add another test for SomeValue encoding
fxamacker Oct 25, 2023
79f3ab3
Add smoke test flag smokeTestSeed
fxamacker Oct 25, 2023
593cead
Add reproducer for false alarm (unreachable slab)
fxamacker Oct 31, 2023
15343c1
add atRoot parameter to Value.DeepRemove. only validate atree value i…
turbolent Oct 31, 2023
a81c720
always perform atree value validation, only perform atree storage val…
turbolent Oct 31, 2023
211ded1
Merge pull request #2920 from onflow/bastian/deep-remove-atroot-flag
turbolent Nov 1, 2023
b98a84e
Add reproducer for false alarm (unreachable slab)
fxamacker Nov 9, 2023
1ecf35c
Add `atRoot` parameter to Value.Transfer()
fxamacker Nov 9, 2023
d35b7d6
Use Atree non-readonly iterators in Transfer()
fxamacker Nov 21, 2023
7ddc21d
Rename atRoot param for Transfer() and DeepRemove()
fxamacker Nov 21, 2023
d08a2a8
Use hasNoParentContainer for inner value DeepRemove()
fxamacker Nov 21, 2023
a6df504
Update StorageMapKey funcs needed by atree iterators
fxamacker Jan 18, 2024
ea8fd35
Merge branch 'feature/atree-register-inlining' into fxamacker/integra…
turbolent Jan 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/kr/pretty v0.3.1
github.com/leanovate/gopter v0.2.9
github.com/logrusorgru/aurora/v4 v4.0.0
github.com/onflow/atree v0.6.1-0.20230706233410-78f997992600
github.com/onflow/atree v0.6.1-0.20231024210403-cb829958cc5f
github.com/rivo/uniseg v0.4.4
github.com/schollz/progressbar/v3 v3.13.1
github.com/stretchr/testify v1.8.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ github.com/mattn/go-tty v0.0.4/go.mod h1:u5GGXBtZU6RQoKV8gY5W6UhMudbR5vXnUe7j3px
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/onflow/atree v0.6.1-0.20230706233410-78f997992600 h1:OOnC8buJso6dSZ6W+RGQDnJW9UTh7HfEGyS/ivXJ7NI=
github.com/onflow/atree v0.6.1-0.20230706233410-78f997992600/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A=
github.com/onflow/atree v0.6.1-0.20231024210403-cb829958cc5f h1:mmc7WjCGwiEkt1GlANRRoxxJRz469gBG0ik755gJJpg=
github.com/onflow/atree v0.6.1-0.20231024210403-cb829958cc5f/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/term v1.2.0-beta.2 h1:L3y/h2jkuBVFdWiJvNfYfKmzcCnILw7mJWm2JQuMppw=
github.com/pkg/term v1.2.0-beta.2/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
Expand Down
16 changes: 13 additions & 3 deletions runtime/cmd/decode-state-values/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/schollz/progressbar/v3"

"github.com/onflow/cadence/runtime/common"
runtimeErr "github.com/onflow/cadence/runtime/errors"
"github.com/onflow/cadence/runtime/interpreter"
)

Expand Down Expand Up @@ -91,8 +92,12 @@ func storageKeyToSlabID(address atree.Address, key string) atree.SlabID {
return atree.NewSlabID(address, index)
}

func decodeStorable(decoder *cbor.StreamDecoder, storableSlabStorageID atree.SlabID) (atree.Storable, error) {
return interpreter.DecodeStorable(decoder, storableSlabStorageID, nil)
func decodeStorable(
decoder *cbor.StreamDecoder,
storableSlabStorageID atree.SlabID,
inlinedExtraData []atree.ExtraData,
) (atree.Storable, error) {
return interpreter.DecodeStorable(decoder, storableSlabStorageID, inlinedExtraData, nil)
}

func decodeTypeInfo(decoder *cbor.StreamDecoder) (atree.TypeInfo, error) {
Expand Down Expand Up @@ -136,6 +141,11 @@ type slabStorage struct{}

var _ atree.SlabStorage = &slabStorage{}

func (s *slabStorage) RetrieveIfLoaded(atree.SlabID) atree.Slab {
// RetrieveIfLoaded() is used for loaded resource tracking. So it isn't needed here.
panic(runtimeErr.NewUnreachableError())
ramtinms marked this conversation as resolved.
Show resolved Hide resolved
}

func (s *slabStorage) Retrieve(id atree.SlabID) (atree.Slab, bool, error) {
data, ok := storage[slabIDToStorageKey(id)]
if !ok {
Expand Down Expand Up @@ -350,7 +360,7 @@ func loadStorageKey(

reader := bytes.NewReader(data)
decoder := interpreter.CBORDecMode.NewStreamDecoder(reader)
storable, err := interpreter.DecodeStorable(decoder, atree.SlabIDUndefined, nil)
storable, err := interpreter.DecodeStorable(decoder, atree.SlabIDUndefined, nil, nil)
if err != nil {
log.Printf(
"Failed to decode storable @ 0x%x %s: %s (data: %x)\n",
Expand Down
66 changes: 35 additions & 31 deletions runtime/convertValues.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,40 +562,44 @@ func exportDictionaryValue(
var err error
pairs := make([]cadence.KeyValuePair, 0, v.Count())

v.Iterate(inter, func(key, value interpreter.Value) (resume bool) {

var convertedKey cadence.Value
convertedKey, err = exportValueWithInterpreter(
key,
inter,
locationRange,
seenReferences,
)
if err != nil {
return false
}
v.Iterate(
inter,
locationRange,
func(key, value interpreter.Value) (resume bool) {

var convertedKey cadence.Value
convertedKey, err = exportValueWithInterpreter(
key,
inter,
locationRange,
seenReferences,
)
if err != nil {
return false
}

var convertedValue cadence.Value
convertedValue, err = exportValueWithInterpreter(
value,
inter,
locationRange,
seenReferences,
)
if err != nil {
return false
}
var convertedValue cadence.Value
convertedValue, err = exportValueWithInterpreter(
value,
inter,
locationRange,
seenReferences,
)
if err != nil {
return false
}

pairs = append(
pairs,
cadence.KeyValuePair{
Key: convertedKey,
Value: convertedValue,
},
)
pairs = append(
pairs,
cadence.KeyValuePair{
Key: convertedKey,
Value: convertedValue,
},
)

return true
})
return true
},
)

if err != nil {
return nil, err
Expand Down
Loading
Loading