Skip to content

Commit 5afcffc

Browse files
authored
Merge pull request #920 from multiversx/imp-vm-ops
Imp vm ops
2 parents 56769a1 + 6442806 commit 5afcffc

File tree

12 files changed

+385
-5
lines changed

12 files changed

+385
-5
lines changed

config/config.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@
192192
MBufferFinish = 10
193193
MBufferSetRandom = 10
194194

195+
[ManagedMapAPICost]
196+
ManagedMapNew = 10
197+
ManagedMapPut = 10
198+
ManagedMapGet = 10
199+
ManagedMapRemove = 10
200+
ManagedMapContains = 10
201+
195202
[WASMOpcodeCost]
196203
AtomicFence = 1
197204
AtomicNotify = 1

config/gasSchedule.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ func CreateGasConfig(gasMap GasScheduleMap) (*GasCost, error) {
114114
dynamicStorageLoadParams.Quadratic, dynamicStorageLoadParams.Linear, dynamicStorageLoadParams.Constant)
115115
}
116116

117+
managedMapOps := &ManagedMapAPICost{}
118+
err = mapstructure.Decode(gasMap["ManagedMapAPICost"], managedMapOps)
119+
if err != nil {
120+
return nil, err
121+
}
122+
117123
gasCost := &GasCost{
118124
BaseOperationCost: *baseOps,
119125
BigIntAPICost: *bigIntOps,
@@ -123,6 +129,7 @@ func CreateGasConfig(gasMap GasScheduleMap) (*GasCost, error) {
123129
ManagedBufferAPICost: *MBufferOps,
124130
WASMOpcodeCost: wasmOps,
125131
DynamicStorageLoad: *dynamicStorageLoadParams,
132+
ManagedMapAPICost: *managedMapOps,
126133
}
127134

128135
return gasCost, nil

integrationTests/json/scenariosFeatures_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ func TestRustBigFloatFeatures(t *testing.T) {
6262
CheckNoError()
6363
}
6464

65+
func TestRustManagedMapBenchmark(t *testing.T) {
66+
if testing.Short() {
67+
t.Skip("not a short test")
68+
}
69+
70+
ScenariosTest(t).
71+
Folder("features/managed-map-benchmark/scenarios").
72+
Run().
73+
CheckNoError()
74+
}
75+
6576
func TestRustManagedMapFeatures(t *testing.T) {
6677
if testing.Short() {
6778
t.Skip("not a short test")

scenario/gasSchedules/gasScheduleEmbedGenerated.go

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scenario/gasSchedules/gasScheduleV3.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@
255255
MBufferFinish = 1000
256256
MBufferSetRandom = 6000
257257

258+
[ManagedMapAPICost]
259+
ManagedMapNew = 10000
260+
ManagedMapPut = 10000
261+
ManagedMapGet = 10000
262+
ManagedMapRemove = 10000
263+
ManagedMapContains = 10000
264+
258265
[WASMOpcodeCost]
259266
AtomicFence = 10
260267
AtomicNotify = 10

scenario/gasSchedules/gasScheduleV4.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@
257257
MBufferFinish = 1000
258258
MBufferSetRandom = 6000
259259

260+
[ManagedMapAPICost]
261+
ManagedMapNew = 10000
262+
ManagedMapPut = 10000
263+
ManagedMapGet = 10000
264+
ManagedMapRemove = 10000
265+
ManagedMapContains = 10000
266+
260267
[WASMOpcodeCost]
261268
AtomicFence = 10
262269
AtomicNotify = 10

test/features/big-float-features/scenarios/big_float_operator_checks.scen.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"expect": {
3333
"out": [],
3434
"status": "10",
35-
"message": "str:this big Float operation is not permitted while doing float.Add"
35+
"message": "*"
3636
}
3737
},
3838
{
@@ -72,7 +72,7 @@
7272
"expect": {
7373
"out": [],
7474
"status": "10",
75-
"message": "str:this big Float operation is not permitted while doing float.Sub"
75+
"message": "*"
7676
}
7777
}
7878
]
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"buildInfo": {
3+
"rustc": {
4+
"version": "1.85.0",
5+
"commitHash": "4d91de4e48198da2e33413efdcd9cd2cc0c46688",
6+
"commitDate": "2025-02-17",
7+
"channel": "Stable",
8+
"short": "rustc 1.85.0 (4d91de4e4 2025-02-17)"
9+
},
10+
"contractCrate": {
11+
"name": "managed-map-benchmark",
12+
"version": "0.0.0"
13+
},
14+
"framework": {
15+
"name": "multiversx-sc",
16+
"version": "0.57.1"
17+
}
18+
},
19+
"abi": {
20+
"name": "ManagedMapBenchmark",
21+
"constructor": {
22+
"inputs": [],
23+
"outputs": []
24+
},
25+
"endpoints": [
26+
{
27+
"name": "mm_get",
28+
"mutability": "readonly",
29+
"inputs": [
30+
{
31+
"name": "key",
32+
"type": "bytes"
33+
},
34+
{
35+
"name": "repeats",
36+
"type": "u32"
37+
}
38+
],
39+
"outputs": [
40+
{
41+
"type": "bytes"
42+
}
43+
]
44+
},
45+
{
46+
"name": "mm_contains",
47+
"mutability": "readonly",
48+
"inputs": [
49+
{
50+
"name": "key",
51+
"type": "bytes"
52+
},
53+
{
54+
"name": "repeats",
55+
"type": "u32"
56+
}
57+
],
58+
"outputs": [
59+
{
60+
"type": "bool"
61+
}
62+
]
63+
},
64+
{
65+
"name": "mm_remove",
66+
"mutability": "mutable",
67+
"inputs": [
68+
{
69+
"name": "remove_key",
70+
"type": "bytes"
71+
},
72+
{
73+
"name": "repeats",
74+
"type": "u32"
75+
}
76+
],
77+
"outputs": []
78+
}
79+
],
80+
"esdtAttributes": [],
81+
"hasCallback": false,
82+
"types": {}
83+
},
84+
"code": "0061736d0100000001340a60027f7f017f6000017f60000060037f7f7f017f60017f017f60017f0060027f7f0060017f017e60047f7f7f7f017f60017e0002ba031303656e76126d427566666572417070656e644279746573000303656e76126d616e616765645369676e616c4572726f72000503656e76126d427566666572476574417267756d656e74000003656e761b736d616c6c496e74476574556e7369676e6564417267756d656e74000703656e760f6765744e756d417267756d656e7473000103656e760b7369676e616c4572726f72000603656e760d6d616e616765644d6170476574000303656e76126d616e616765644d6170436f6e7461696e73000003656e760f6d4275666665725365744279746573000303656e76126d42756666657253746f726167654c6f6164000003656e760d6d427566666572417070656e64000003656e760d6d616e616765644d61704e6577000103656e76106d4275666665724765744c656e677468000403656e76136d42756666657247657442797465536c696365000803656e760d6d616e616765644d6170507574000303656e760e636865636b4e6f5061796d656e74000203656e760d6d42756666657246696e697368000403656e7614736d616c6c496e7446696e6973685369676e6564000903656e76106d616e616765644d617052656d6f7665000303100f00010101050000040601020202020205030100030616037f01418080080b7f0041fc80080b7f00418081080b075a08066d656d6f7279020004696e6974001d066d6d5f676574001e0b6d6d5f636f6e7461696e73001f096d6d5f72656d6f766500200863616c6c4261636b00210a5f5f646174615f656e6403010b5f5f686561705f6261736503020ae0050f1101017f101522022000200110081a20020b0f01017f41001015220010021a20000b1901017f41f8800841f8800828020041016b220036020020000b4702017f017e4101100322014280808080105a04404180800841171013220041dc8008410710001a200041978008410310001a200041b38008410e10001a20001001000b2001a70b1400100420004604400f0b419a800841191005000b0f00200020011015220010061a20000b0b0020002001100741004a0b0d0020001015220010091a20000b4601017f230041106b220224002002200141187420014180fe03714108747220014108764180fe03712001411876727236020c20002002410c6a410410001a200241106a24000ba60202017e067f230041106b22012400100b210641e68008410b1013210320014200370308024002402003101a2205100c220241094f0d00200541002002200120026b41106a100d1a2001290308220042388620004280fe0383422886842000428080fc0783421886200042808080f80f834208868484200042088842808080f80f832000421888428080fc07838420004228884280fe0383200042388884848422004280808080105a0d002000a72103034020032004460d0241e380084103101322022004101b2002101a210241f180084105101322052004101b200620022005101a100e1a200441016a21040c000b000b41c18008411b101322012003100a1a200141978008410310001a200141b38008410e10001a20011001000b200141106a240020060b0800100f410010170b3701037f100f410210171014210110162100101c21020340200004402002200110181a200041016b21000c010b0b20022001101810101a0b3701037f100f410210171014210110162100101c21020340200004402002200110191a200041016b21000c010b0b200220011019ad10110b3001037f100f410210171014210110162100101c210203402000044020022001101510121a200041016b21000c010b0b0b02000b0b89010200418080080b76617267756d656e74206465636f6465206572726f722028293a2077726f6e67206e756d626572206f6620617267756d656e7473696e70757420746f6f206c6f6e6773746f72616765206465636f6465206572726f7220286b65793a20726570656174736b65796e756d5f656e747269657376616c75650041f880080b0438ffffff",
85+
"report": {
86+
"imports": [
87+
"checkNoPayment",
88+
"getNumArguments",
89+
"mBufferAppend",
90+
"mBufferAppendBytes",
91+
"mBufferFinish",
92+
"mBufferGetArgument",
93+
"mBufferGetByteSlice",
94+
"mBufferGetLength",
95+
"mBufferSetBytes",
96+
"mBufferStorageLoad",
97+
"managedMapContains",
98+
"managedMapGet",
99+
"managedMapNew",
100+
"managedMapPut",
101+
"managedMapRemove",
102+
"managedSignalError",
103+
"signalError",
104+
"smallIntFinishSigned",
105+
"smallIntGetUnsignedArgument"
106+
],
107+
"isMemGrow": false,
108+
"eiCheck": {
109+
"eiVersion": "1.3",
110+
"ok": true
111+
},
112+
"codeReport": {
113+
"path": "../output/managed-map-benchmark.wasm",
114+
"size": 1525,
115+
"hasAllocator": false,
116+
"hasPanic": "None"
117+
}
118+
}
119+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"steps": [
3+
{
4+
"step": "setState",
5+
"accounts": {
6+
"sc:mmap-features": {
7+
"nonce": "0",
8+
"balance": "0",
9+
"storage": {
10+
"str:num_entries": "3",
11+
"str:key|u32:0": "str:key0",
12+
"str:value|u32:0": "str:value0",
13+
"str:key|u32:1": "str:key1",
14+
"str:value|u32:1": "",
15+
"str:key|u32:2": "",
16+
"str:value|u32:2": "str:value2"
17+
},
18+
"code": "mxsc:../output/managed-map-benchmark.mxsc.json"
19+
},
20+
"address:an-account": {
21+
"nonce": "0"
22+
}
23+
}
24+
},
25+
{
26+
"step": "scCall",
27+
"id": "get 1",
28+
"tx": {
29+
"from": "address:an-account",
30+
"to": "sc:mmap-features",
31+
"function": "mm_contains",
32+
"arguments": [
33+
"str:key0",
34+
"1"
35+
],
36+
"gasLimit": "50,000,000",
37+
"gasPrice": "0"
38+
},
39+
"expect": {
40+
"gas": "48635289",
41+
"out": [
42+
"true"
43+
]
44+
}
45+
},
46+
{
47+
"step": "scCall",
48+
"id": "get 1000",
49+
"tx": {
50+
"from": "address:an-account",
51+
"to": "sc:mmap-features",
52+
"function": "mm_contains",
53+
"arguments": [
54+
"str:key0",
55+
"1000"
56+
],
57+
"gasLimit": "50,000,000",
58+
"gasPrice": "0"
59+
},
60+
"expect": {
61+
"gas": "38560374",
62+
"out": [
63+
"true"
64+
]
65+
}
66+
}
67+
]
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"steps": [
3+
{
4+
"step": "setState",
5+
"accounts": {
6+
"sc:mmap-features": {
7+
"nonce": "0",
8+
"balance": "0",
9+
"storage": {
10+
"str:num_entries": "3",
11+
"str:key|u32:0": "str:key0",
12+
"str:value|u32:0": "str:value0",
13+
"str:key|u32:1": "str:key1",
14+
"str:value|u32:1": "",
15+
"str:key|u32:2": "",
16+
"str:value|u32:2": "str:value2"
17+
},
18+
"code": "mxsc:../output/managed-map-benchmark.mxsc.json"
19+
},
20+
"address:an-account": {
21+
"nonce": "0"
22+
}
23+
}
24+
},
25+
{
26+
"step": "scCall",
27+
"id": "get 1",
28+
"tx": {
29+
"from": "address:an-account",
30+
"to": "sc:mmap-features",
31+
"function": "mm_get",
32+
"arguments": [
33+
"str:key0",
34+
"1"
35+
],
36+
"gasLimit": "50,000,000",
37+
"gasPrice": "0"
38+
},
39+
"expect": {
40+
"gas": "48627983",
41+
"out": [
42+
"str:value0"
43+
]
44+
}
45+
},
46+
{
47+
"step": "scCall",
48+
"id": "get 1000",
49+
"tx": {
50+
"from": "address:an-account",
51+
"to": "sc:mmap-features",
52+
"function": "mm_get",
53+
"arguments": [
54+
"str:key0",
55+
"1000"
56+
],
57+
"gasLimit": "50,000,000",
58+
"gasPrice": "0"
59+
},
60+
"expect": {
61+
"gas": "37898723",
62+
"out": [
63+
"str:value0"
64+
]
65+
}
66+
}
67+
]
68+
}

0 commit comments

Comments
 (0)