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

Implement CAP-58 (constructor support) #1447

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ wasmparser = "=0.116.1"
# NB: When updating, also update the version in rs-soroban-env dev-dependencies
[workspace.dependencies.stellar-xdr]
version = "=21.2.0"
# git = "https://github.com/stellar/rs-stellar-xdr"
# rev = "d0138770652a615e3cd99447f2f2727658c17450"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "953ad1c6103146121871a3e2fa5aaca3d6256891"
default-features = false

[workspace.dependencies.wasmi]
Expand All @@ -47,7 +47,8 @@ rev = "122a74a7c491929e5ac9de876099154ef7c06d06"
features = ["no-hash-maps"]

# [patch."https://github.com/stellar/rs-stellar-xdr"]
# stellar-xdr = { path = "../rs-stellar-xdr/" }
# [patch.crates-io]
# stellar-xdr = { path = "../rs-stellar-xdr" }
# [patch."https://github.com/stellar/wasmi"]
# soroban-wasmi = { path = "../wasmi/crates/wasmi/" }
# soroban-wasmi_core = { path = "../wasmi/crates/core/" }
Expand Down
25 changes: 25 additions & 0 deletions soroban-env-common/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,31 @@
"return": "Void",
"docs": "If the TTL for the provided contract's code (if applicable) is below `threshold` ledgers, extend `live_until_ledger_seq` such that TTL == `extend_to`, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + `max_entry_ttl` - 1), the new `live_until_ledger_seq` will be clamped to the max.",
"min_supported_protocol": 21
},
{
"export": "e",
"name": "create_contract_with_constructor",
"args": [
{
"name": "deployer",
"type": "AddressObject"
},
{
"name": "wasm_hash",
"type": "BytesObject"
},
{
"name": "salt",
"type": "BytesObject"
},
{
"name": "constructor_args",
"type": "VecObject"
}
],
"return": "AddressObject",
"docs": "Creates the contract instance on behalf of `deployer`. Created contract must be created from a Wasm that has a constructor. `deployer` must authorize this call via Soroban auth framework, i.e. this calls `deployer.require_auth` with respective arguments. `wasm_hash` must be a hash of the contract code that has already been uploaded on this network. `salt` is used to create a unique contract id. `constructor_args` are forwarded into created contract's constructor (`__constructor`) function. Returns the address of the created contract.",
"min_supported_protocol": 22
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions soroban-env-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ p256 = {version = "0.13.2", default-features = false, features = ["alloc"]}

[dev-dependencies.stellar-xdr]
version = "=21.2.0"
# git = "https://github.com/stellar/rs-stellar-xdr"
# rev = "d0138770652a615e3cd99447f2f2727658c17450"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "953ad1c6103146121871a3e2fa5aaca3d6256891"
default-features = false
features = ["arbitrary"]

[features]
testutils = ["soroban-env-common/testutils", "recording_mode", "dep:backtrace"]
next = ["soroban-env-common/next"]
next = ["soroban-env-common/next", "stellar-xdr/next"]
tracy = ["dep:tracy-client", "soroban-env-common/tracy"]
recording_mode = []
bench = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,48 @@
" 5 call bytes_new_from_slice(32)": "cpu:361649, mem:417742, objs:-/3@bb4c5905",
" 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:362618, mem:417854, objs:-/4@eb793bfe",
" 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "",
" 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:364261, mem:418032, objs:-/5@2b1f9da6, auth:1@416f1e2c/-",
" 9 ret obj_cmp -> Ok(0)": "cpu:364553",
" 10 call get_ledger_network_id()": "cpu:364603, auth:1@416f1e2c/1@35d84348",
" 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:365633, mem:418144, objs:-/6@650deec0",
" 12 ret create_contract -> Ok(Address(obj#13))": "cpu:383766, mem:421218, objs:-/7@d84cbde8, store:-/2@72ebdcaa, foot:2@e329408f, auth:-/1@75c66300",
" 13 call call(Address(obj#13), Symbol(test), Vec(obj#15))": "cpu:384727, mem:421298, objs:-/8@26b03860, auth:-/-",
" 14 push VM:193a354b:test()": "cpu:557144, mem:585183, objs:-/9@f2fe6f5, vm:65536@6644521a/2@2f94d90d, stk:1@9220068b, auth:1@d7dc1364/-",
" 15 call bytes_new_from_linear_memory(U32(0), U32(100))": "cpu:559814, mem:585214, vm:-/-",
" 16 ret bytes_new_from_linear_memory -> Ok(Bytes(obj#19))": "cpu:561076, mem:585394, objs:-/10@21e7a208",
" 17 pop VM:193a354b:test -> Ok(Bytes(obj#19))": "cpu:561572, mem:585418, objs:1@7f18fa80/10@21e7a208, vm:65536@6644521a/2@2f94d90d, stk:1@a78fd13f",
" 18 ret call -> Ok(Bytes(obj#19))": "cpu:562255, mem:585434, objs:-/10@21e7a208, vm:-/-, stk:-, auth:-/-",
" 19 call bytes_len(Bytes(obj#19))": "",
" 20 ret bytes_len -> Ok(U32(100))": "cpu:562377",
" 21 call bytes_new_from_slice(16000142)": "cpu:47, mem:0",
" 22 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:4001042, mem:16000222, objs:-/11@e14cd6",
" 23 call upload_wasm(Bytes(obj#21))": "",
" 24 ret upload_wasm -> Ok(Bytes(obj#23))": "cpu:15347760028, mem:1499150493, objs:-/12@858c0f3f, store:-/3@fc19e716, foot:3@a89fc125",
" 25 call bytes_new_from_slice(32)": "cpu:15347760468, mem:1499150557, objs:-/13@84639590",
" 26 ret bytes_new_from_slice -> Ok(Bytes(obj#27))": "cpu:15347761437, mem:1499150669, objs:-/14@20ce99e",
" 27 call create_contract(Address(obj#25), Bytes(obj#23), Bytes(obj#27))": "",
" 28 call obj_cmp(Address(obj#29), Address(obj#25))": "cpu:15347763080, mem:1499150847, objs:-/15@2bd3f355, auth:1@b1a941ab/-",
" 29 ret obj_cmp -> Ok(0)": "cpu:15347763372",
" 30 call get_ledger_network_id()": "cpu:15347763422, auth:1@b1a941ab/1@b1c4a5c3",
" 31 ret get_ledger_network_id -> Ok(Bytes(obj#31))": "cpu:15347764452, mem:1499150959, objs:-/16@11fcf875",
" 32 ret create_contract -> Ok(Address(obj#33))": "cpu:15347783867, mem:1499154405, objs:-/17@b40a3272, store:-/4@1c0d07e4, foot:4@e3998a1a, auth:-/1@546ea3b6",
" 33 call call(Address(obj#33), Symbol(test), Vec(obj#35))": "cpu:961, mem:80, objs:-/18@400dadf4, auth:-/-",
" 34 ret call -> Err(Error(Budget, ExceededLimit))": "cpu:7661413, mem:47972261",
" 35 end": "cpu:7661413, mem:47972261, prngs:-/9b4a753, objs:-/18@400dadf4, vm:-/-, evt:-, store:-/4@1c0d07e4, foot:4@e3998a1a, stk:-, auth:-/-"
" 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:365229, mem:418094, objs:-/5@2b1f9da6, auth:1@ab3b6b7c/-",
" 9 ret obj_cmp -> Ok(0)": "cpu:365521",
" 10 call get_ledger_network_id()": "cpu:365571, auth:1@ab3b6b7c/1@b4ff25ea",
" 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:366601, mem:418206, objs:-/6@650deec0",
" 12 call symbol_new_from_slice(13)": "cpu:552059, mem:584261, store:-/2@72ebdcaa, foot:2@e329408f",
" 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:553067, mem:584354, objs:-/7@c727927d",
" 14 push VM:193a354b:sym#13()": "cpu:724675, mem:748231, objs:-/8@98c1645b, vm:65536@6644521a/2@2f94d90d, stk:1@b4e140d8, auth:2@bc088ab/1@e3f2228e",
" 15 call symbol_len(Symbol(obj#13))": "cpu:727345, mem:748262",
" 16 ret symbol_len -> Ok(U32(13))": "cpu:727467",
" 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "",
" 18 ret symbol_copy_to_slice -> Ok(())": "cpu:727571",
" 19 pop VM:193a354b:sym#13 -> Ok(Void)": "",
" 20 ret create_contract -> Ok(Address(obj#17))": "cpu:728694, mem:748342, objs:-/9@e44b6a96, vm:-/-, stk:-, auth:-/-",
" 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:729655, mem:748422, objs:-/10@4a435079",
" 22 push VM:193a354b:test()": "cpu:903040, mem:912443, objs:-/11@aad83c35, vm:65536@6644521a/2@2f94d90d, stk:1@9220068b, auth:1@b1b428e/-",
" 23 call bytes_new_from_linear_memory(U32(0), U32(100))": "cpu:905710, mem:912474, vm:-/-",
" 24 ret bytes_new_from_linear_memory -> Ok(Bytes(obj#23))": "cpu:906972, mem:912654, objs:-/12@e2637e1c",
" 25 pop VM:193a354b:test -> Ok(Bytes(obj#23))": "cpu:907468, mem:912678, objs:1@b5962073/12@e2637e1c, vm:65536@6644521a/2@2f94d90d, stk:1@8397b962",
" 26 ret call -> Ok(Bytes(obj#23))": "cpu:908151, mem:912694, objs:-/12@e2637e1c, vm:-/-, stk:-, auth:-/-",
" 27 call bytes_len(Bytes(obj#23))": "",
" 28 ret bytes_len -> Ok(U32(100))": "cpu:908273",
" 29 call bytes_new_from_slice(16000142)": "cpu:47, mem:0",
" 30 ret bytes_new_from_slice -> Ok(Bytes(obj#25))": "cpu:4001042, mem:16000222, objs:-/13@7d77ab53",
" 31 call upload_wasm(Bytes(obj#25))": "",
" 32 ret upload_wasm -> Ok(Bytes(obj#27))": "cpu:15347760028, mem:1499150493, objs:-/14@47033fc9, store:-/3@fc19e716, foot:3@a89fc125",
" 33 call bytes_new_from_slice(32)": "cpu:15347760468, mem:1499150557, objs:-/15@cace3dff",
" 34 ret bytes_new_from_slice -> Ok(Bytes(obj#31))": "cpu:15347761437, mem:1499150669, objs:-/16@fef7e32d",
" 35 call create_contract(Address(obj#29), Bytes(obj#27), Bytes(obj#31))": "",
" 36 call obj_cmp(Address(obj#33), Address(obj#29))": "cpu:15347764048, mem:1499150909, objs:-/17@b40fad6a, auth:1@3bb1667b/-",
" 37 ret obj_cmp -> Ok(0)": "cpu:15347764340",
" 38 call get_ledger_network_id()": "cpu:15347764390, auth:1@3bb1667b/1@592dbad0",
" 39 ret get_ledger_network_id -> Ok(Bytes(obj#35))": "cpu:15347765420, mem:1499151021, objs:-/18@82c11bd6",
" 40 call symbol_new_from_slice(13)": "cpu:15357451459, mem:1563182944, store:-/4@1c0d07e4, foot:4@e3998a1a",
" 41 ret symbol_new_from_slice -> Ok(Symbol(obj#37))": "cpu:15357452467, mem:1563183037, objs:-/19@2beaf5af",
" 42 push VM:27d624d8:sym#37()": "cpu:15367123408, mem:1627212546, objs:-/20@54f2039d, vm:16056320@6ae17543/2@2f94d90d, stk:1@644de402, auth:2@49db469/1@e93018dd",
" 43 call symbol_len(Symbol(obj#37))": "cpu:15367126078, mem:1627212577",
" 44 ret symbol_len -> Ok(U32(13))": "cpu:15367126200",
" 45 call symbol_copy_to_slice(Symbol(obj#37), U32(0), 13)": "",
" 46 ret symbol_copy_to_slice -> Ok(())": "cpu:15367126304",
" 47 pop VM:27d624d8:sym#37 -> Ok(Void)": "",
" 48 ret create_contract -> Ok(Address(obj#41))": "cpu:15367127444, mem:1627212657, objs:-/21@66e11dce, vm:-/-, stk:-, auth:-/-",
" 49 call call(Address(obj#41), Symbol(test), Vec(obj#43))": "cpu:961, mem:80, objs:-/22@8ffbf0da",
" 50 ret call -> Err(Error(Budget, ExceededLimit))": "cpu:7662546, mem:47972397",
" 51 end": "cpu:7662546, mem:47972397, prngs:-/9b4a753, objs:-/22@8ffbf0da, vm:-/-, evt:-, store:-/4@1c0d07e4, foot:4@e3998a1a, stk:-, auth:-/-"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@
" 5 call bytes_new_from_slice(32)": "cpu:2271955, mem:1638704, objs:-/3@a780f4a1",
" 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:2272924, mem:1638816, objs:-/4@5441559c",
" 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "",
" 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:2274567, mem:1638994, objs:-/5@6cbc65d6, auth:1@6a5ef2c9/-",
" 9 ret obj_cmp -> Ok(0)": "cpu:2274859",
" 10 call get_ledger_network_id()": "cpu:2274909, auth:1@6a5ef2c9/1@18e127e2",
" 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:2275939, mem:1639106, objs:-/6@f5a2751f",
" 12 ret create_contract -> Ok(Address(obj#13))": "cpu:2294072, mem:1642180, objs:-/7@e8892517, store:-/2@619f32b5, foot:2@73444153, auth:-/1@233e284a",
" 13 call call(Address(obj#13), Symbol(bin_word), Vec(obj#15))": "cpu:2295035, mem:1642268, objs:-/8@4c0b0eb3, auth:-/-",
" 14 push VM:75130317:bin_word(U32(2864434397))": "cpu:2739781, mem:2870989, objs:-/9@181ddb96, vm:1114112@67b8985c/12@d32baa7b, stk:1@be273e0f, auth:1@b86eb558/-",
" 15 call bytes_new_from_linear_memory(U32(1048572), U32(4))": "cpu:2742455, mem:2871036, vm:-/-",
" 16 ret bytes_new_from_linear_memory -> Ok(Bytes(obj#19))": "cpu:2743781, mem:2871120, objs:-/10@8f3713f0",
" 17 pop VM:75130317:bin_word -> Ok(Bytes(obj#19))": "cpu:2744277, mem:2871144, objs:1@7f18fa80/10@8f3713f0, vm:1114112@a2a6f9c8/12@d32baa7b, stk:1@b4a13456",
" 18 ret call -> Ok(Bytes(obj#19))": "cpu:2744960, mem:2871160, objs:-/10@8f3713f0, vm:-/-, stk:-, auth:-/-",
" 19 call obj_cmp(Bytes(obj#19), Bytes(obj#21))": "cpu:2745921, mem:2871244, objs:-/11@3023d359",
" 20 ret obj_cmp -> Ok(0)": "cpu:2746209",
" 21 call vec_new()": "cpu:2747170, mem:2871328, objs:-/12@82e455c7",
" 22 ret vec_new -> Ok(Vec(obj#25))": "cpu:2747671, mem:2871392, objs:-/13@40e25a5c",
" 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:2275535, mem:1639056, objs:-/5@6cbc65d6, auth:1@69d177b3/-",
" 9 ret obj_cmp -> Ok(0)": "cpu:2275827",
" 10 call get_ledger_network_id()": "cpu:2275877, auth:1@69d177b3/1@93d99e6b",
" 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:2276907, mem:1639168, objs:-/6@f5a2751f",
" 12 ret create_contract -> Ok(Address(obj#13))": "cpu:2735191, mem:2870107, objs:-/7@e8892517, store:-/2@619f32b5, foot:2@73444153, auth:-/1@243164e3",
" 13 call call(Address(obj#13), Symbol(bin_word), Vec(obj#15))": "cpu:2736154, mem:2870195, objs:-/8@4c0b0eb3, auth:-/-",
" 14 push VM:75130317:bin_word(U32(2864434397))": "cpu:3180900, mem:4098916, objs:-/9@181ddb96, vm:1114112@67b8985c/12@d32baa7b, stk:1@be273e0f, auth:1@b86eb558/-",
" 15 call bytes_new_from_linear_memory(U32(1048572), U32(4))": "cpu:3183574, mem:4098963, vm:-/-",
" 16 ret bytes_new_from_linear_memory -> Ok(Bytes(obj#19))": "cpu:3184900, mem:4099047, objs:-/10@8f3713f0",
" 17 pop VM:75130317:bin_word -> Ok(Bytes(obj#19))": "cpu:3185396, mem:4099071, objs:1@7f18fa80/10@8f3713f0, vm:1114112@a2a6f9c8/12@d32baa7b, stk:1@b4a13456",
" 18 ret call -> Ok(Bytes(obj#19))": "cpu:3186079, mem:4099087, objs:-/10@8f3713f0, vm:-/-, stk:-, auth:-/-",
" 19 call obj_cmp(Bytes(obj#19), Bytes(obj#21))": "cpu:3187040, mem:4099171, objs:-/11@3023d359",
" 20 ret obj_cmp -> Ok(0)": "cpu:3187328",
" 21 call vec_new()": "cpu:3188289, mem:4099255, objs:-/12@82e455c7",
" 22 ret vec_new -> Ok(Vec(obj#25))": "cpu:3188790, mem:4099319, objs:-/13@40e25a5c",
" 23 call vec_push_back(Vec(obj#25), Bytes(obj#23))": "",
" 24 ret vec_push_back -> Ok(Vec(obj#27))": "cpu:2748878, mem:2871480, objs:-/14@b6924a77",
" 24 ret vec_push_back -> Ok(Vec(obj#27))": "cpu:3189997, mem:4099407, objs:-/14@b6924a77",
" 25 call call(Address(obj#13), Symbol(bin_inc), Vec(obj#27))": "",
" 26 push VM:75130317:bin_inc(Bytes(obj#23))": "cpu:3194592, mem:4100337, objs:-/15@c506ccd2, vm:1114112@67b8985c/12@d32baa7b, stk:1@47d8fa40, auth:1@251a9ba2/-",
" 27 call bytes_len(Bytes(obj#23))": "cpu:3197701, mem:4100408, objs:1@b5962073/15@c506ccd2, vm:-/-, stk:1@1e1dc600",
" 28 ret bytes_len -> Ok(U32(4))": "cpu:3198233",
" 26 push VM:75130317:bin_inc(Bytes(obj#23))": "cpu:3635711, mem:5328264, objs:-/15@c506ccd2, vm:1114112@67b8985c/12@d32baa7b, stk:1@47d8fa40, auth:1@251a9ba2/-",
" 27 call bytes_len(Bytes(obj#23))": "cpu:3638820, mem:5328335, objs:1@b5962073/15@c506ccd2, vm:-/-, stk:1@1e1dc600",
" 28 ret bytes_len -> Ok(U32(4))": "cpu:3639352",
" 29 call bytes_copy_to_linear_memory(Bytes(obj#23), U32(0), U32(1048572), U32(4))": "",
" 30 ret bytes_copy_to_linear_memory -> Ok(Void)": "cpu:3198707",
" 30 ret bytes_copy_to_linear_memory -> Ok(Void)": "cpu:3639826",
" 31 call bytes_new_from_linear_memory(U32(1048572), U32(4))": "",
" 32 ret bytes_new_from_linear_memory -> Ok(Bytes(obj#31))": "cpu:3200181, mem:4100492, objs:1@b5962073/16@4c245c5f",
" 33 pop VM:75130317:bin_inc -> Ok(Bytes(obj#31))": "cpu:3200677, mem:4100516, objs:2@a8b6a51c/16@4c245c5f, vm:1114112@2206e62e/12@d32baa7b, stk:1@aa3c8413",
" 34 ret call -> Ok(Bytes(obj#31))": "cpu:3201360, mem:4100532, objs:-/16@4c245c5f, vm:-/-, stk:-, auth:-/-",
" 35 call obj_cmp(Bytes(obj#31), Bytes(obj#33))": "cpu:3202321, mem:4100616, objs:-/17@397f6f02",
" 36 ret obj_cmp -> Ok(0)": "cpu:3202609",
" 37 end": "cpu:3202609, mem:4100616, prngs:-/9b4a753, objs:-/17@397f6f02, vm:-/-, evt:-, store:-/2@619f32b5, foot:2@73444153, stk:-, auth:-/-"
" 32 ret bytes_new_from_linear_memory -> Ok(Bytes(obj#31))": "cpu:3641300, mem:5328419, objs:1@b5962073/16@4c245c5f",
" 33 pop VM:75130317:bin_inc -> Ok(Bytes(obj#31))": "cpu:3641796, mem:5328443, objs:2@a8b6a51c/16@4c245c5f, vm:1114112@2206e62e/12@d32baa7b, stk:1@aa3c8413",
" 34 ret call -> Ok(Bytes(obj#31))": "cpu:3642479, mem:5328459, objs:-/16@4c245c5f, vm:-/-, stk:-, auth:-/-",
" 35 call obj_cmp(Bytes(obj#31), Bytes(obj#33))": "cpu:3643440, mem:5328543, objs:-/17@397f6f02",
" 36 ret obj_cmp -> Ok(0)": "cpu:3643728",
" 37 end": "cpu:3643728, mem:5328543, prngs:-/9b4a753, objs:-/17@397f6f02, vm:-/-, evt:-, store:-/2@619f32b5, foot:2@73444153, stk:-, auth:-/-"
}
Loading
Loading