Skip to content

Commit 98495c7

Browse files
authored
refactor: register names and signed extension function renamed (#540)
1 parent 8cb94f4 commit 98495c7

16 files changed

+290
-290
lines changed

internal/authorization/authorization.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (a *Authorization) InvokePVM(
6767
gasCounter, regs, mem, err = host_call.Fetch(gasCounter, regs, mem, &workPackage, nil, nil, nil, nil, nil, nil)
6868
default:
6969
// (▸, ϱ−10, [φ0,…,φ6, WHAT, φ8,…], µ)
70-
regs[pvm.A0] = uint64(host_call.WHAT)
70+
regs[pvm.R7] = uint64(host_call.WHAT)
7171
gasCounter -= isAuthorizedCost
7272
}
7373

internal/pvm/host_call/accumulate_functions.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func Bless(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (
2121
gas -= BlessCost
2222

2323
// let [m, a, v, r, o, n] = φ7...13
24-
managerServiceId, assignServiceAddr, designateServiceId, createProtectedServiceId, addr, servicesNr := regs[A0], regs[A1], regs[A2], regs[A3], regs[A4], regs[A5]
24+
managerServiceId, assignServiceAddr, designateServiceId, createProtectedServiceId, addr, servicesNr := regs[R7], regs[R8], regs[R9], regs[R10], regs[R11], regs[R12]
2525

2626
// let g = {(s ↦ g) where E4(s) ⌢ E8(g) = μ_o+12i⋅⋅⋅+12 | i ∈ Nn} if No⋅⋅⋅+12n ⊂ Vμ otherwise ∇
2727
gasPerServiceId := make(map[block.ServiceId]uint64)
@@ -91,7 +91,7 @@ func Assign(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair)
9191
gas -= AssignCost
9292

9393
// let [c, o, a] = φ7···+3
94-
core, addr, newAssigner := regs[A0], regs[A1], regs[A2]
94+
core, addr, newAssigner := regs[R7], regs[R8], regs[R9]
9595

9696
// Read the queue from memory first (can panic on invalid memory access)
9797
// q = [μo+32i···+32 | i ← NQ] if No···+32Q ⊆ Vμ otherwise ∇
@@ -152,7 +152,7 @@ func Designate(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPai
152152
)
153153

154154
// let o = φ7
155-
addr := regs[A0]
155+
addr := regs[R7]
156156
for i := 0; i < constants.NumberOfValidators; i++ {
157157
bytes := make([]byte, 336)
158158
valAddr, ok := safemath.Add(addr, 336*uint64(i))
@@ -191,7 +191,7 @@ func Checkpoint(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPa
191191
ctxPair.ExceptionalCtx = ctxPair.RegularCtx.Clone()
192192

193193
// Set the new ϱ' value into φ′7
194-
regs[A0] = uint64(gas)
194+
regs[R7] = uint64(gas)
195195

196196
return gas, regs, mem, ctxPair, nil
197197
}
@@ -220,12 +220,12 @@ func New(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair, tim
220220
gas -= NewCost
221221

222222
// let [o, l, g, m, f, i] = φ7..+6
223-
addr := regs[A0]
224-
preimageLength := regs[A1]
225-
gasLimitAccumulator := regs[A2]
226-
gasLimitTransfer := regs[A3]
227-
gratisStorageOffset := regs[A4]
228-
desiredId := regs[A5]
223+
addr := regs[R7]
224+
preimageLength := regs[R8]
225+
gasLimitAccumulator := regs[R9]
226+
gasLimitTransfer := regs[R10]
227+
gratisStorageOffset := regs[R11]
228+
desiredId := regs[R12]
229229

230230
// (▸, HUH, x_i, (x_e)_d) otherwise if f ≠ 0 ∧ x_s ≠ (x_e)_m
231231
xsId := ctxPair.RegularCtx.ServiceId
@@ -330,15 +330,15 @@ func New(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair, tim
330330
return gas, withCode(regs, FULL), mem, ctxPair, nil
331331
}
332332

333-
regs[A0] = uint64(actualServiceId)
333+
regs[R7] = uint64(actualServiceId)
334334
ctxPair.RegularCtx.AccumulationState.ServiceState[actualServiceId] = account
335335
ctxPair.RegularCtx.AccumulationState.ServiceState[xsId] = s
336336
return gas, regs, mem, ctxPair, nil
337337
}
338338

339339
// Regular path
340340
// (▸, x_i, i*, (x_e)_d ∪ d) otherwise
341-
regs[A0] = uint64(actualServiceId)
341+
regs[R7] = uint64(actualServiceId)
342342
nextId := service.BumpIndex(ctxPair.RegularCtx.NewServiceId, ctxPair.RegularCtx.AccumulationState.ServiceState)
343343
ctxPair.RegularCtx.NewServiceId = nextId
344344
ctxPair.RegularCtx.AccumulationState.ServiceState[actualServiceId] = account
@@ -351,7 +351,7 @@ func New(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair, tim
351351
func Upgrade(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (Gas, Registers, Memory, AccumulateContextPair, error) {
352352
gas -= UpgradeCost
353353
// let [o, g, m] = φ7...10
354-
addr, gasLimitAccumulator, gasLimitTransfer := regs[A0], regs[A1], regs[A2]
354+
addr, gasLimitAccumulator, gasLimitTransfer := regs[R7], regs[R8], regs[R9]
355355

356356
// c = μo⋅⋅⋅+32 if No⋅⋅⋅+32 ⊂ Vμ otherwise ∇
357357
codeHash := make([]byte, 32)
@@ -374,7 +374,7 @@ func Upgrade(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair)
374374
// Transfer ΩT(ϱ, φ, μ, (x, y))
375375
func Transfer(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (Gas, Registers, Memory, AccumulateContextPair, error) {
376376
// let (d, a, l, o) = φ7..11
377-
receiverId, amount, gasLimit, o := regs[A0], regs[A1], regs[A2], regs[A3]
377+
receiverId, amount, gasLimit, o := regs[R7], regs[R8], regs[R9], regs[R10]
378378

379379
gas -= TransferBaseCost
380380

@@ -434,7 +434,7 @@ func Transfer(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair
434434
func Eject(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair, timeslot jamtime.Timeslot) (Gas, Registers, Memory, AccumulateContextPair, error) {
435435
gas -= EjectCost
436436

437-
d, o := regs[A0], regs[A1]
437+
d, o := regs[R7], regs[R8]
438438

439439
// let h = μo..o+32 if Zo..o+32 ⊂ Vμ
440440
h := make([]byte, 32)
@@ -506,7 +506,7 @@ func Eject(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair, t
506506
func Query(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (Gas, Registers, Memory, AccumulateContextPair, error) {
507507
gas -= QueryCost
508508

509-
addr, preimageMetaKeyLength := regs[A0], regs[A1]
509+
addr, preimageMetaKeyLength := regs[R7], regs[R8]
510510

511511
// let h = μo..o+32 if Zo..o+32 ⊂ Vμ
512512
h := make([]byte, 32)
@@ -529,23 +529,23 @@ func Query(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (
529529
a, exists := serviceAccount.GetPreimageMeta(k)
530530
if !exists {
531531
// a = ∇ => (NONE, 0)
532-
regs[A1] = 0
532+
regs[R8] = 0
533533
return gas, withCode(regs, NONE), mem, ctxPair, nil
534534
}
535535

536536
switch len(a) {
537537
case 0:
538538
// a = [] => (0, 0)
539-
regs[A0], regs[A1] = 0, 0
539+
regs[R7], regs[R8] = 0, 0
540540
case 1:
541541
// a = [x] => (1 + 2^32 * x, 0)
542-
regs[A0], regs[A1] = 1+(uint64(a[0])<<32), 0
542+
regs[R7], regs[R8] = 1+(uint64(a[0])<<32), 0
543543
case 2:
544544
// a = [x, y] => (2 + 2^32 * x, y)
545-
regs[A0], regs[A1] = 2+(uint64(a[0])<<32), uint64(a[1])
545+
regs[R7], regs[R8] = 2+(uint64(a[0])<<32), uint64(a[1])
546546
case 3:
547547
// a = [x, y, z] => (3 + 2^32 * x, y + 2^32 * z)
548-
regs[A0], regs[A1] = 3+(uint64(a[0])<<32), uint64(a[1])+(uint64(a[2])<<32)
548+
regs[R7], regs[R8] = 3+(uint64(a[0])<<32), uint64(a[1])+(uint64(a[2])<<32)
549549
}
550550

551551
return gas, regs, mem, ctxPair, nil
@@ -556,7 +556,7 @@ func Solicit(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair,
556556
gas -= SolicitCost
557557

558558
// let [o, z] = φ7,8
559-
addr, preimageLength := regs[A0], regs[A1]
559+
addr, preimageLength := regs[R7], regs[R8]
560560
// let h = μo⋅⋅⋅+32 if Zo⋅⋅⋅+32 ⊂ Vμ otherwise ∇
561561
preimageHashBytes := make([]byte, 32)
562562
if addr > math.MaxUint32 {
@@ -615,7 +615,7 @@ func Forget(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair,
615615
gas -= ForgetCost
616616

617617
// let [o, z] = φ0,1
618-
addr, preimageLength := regs[A0], regs[A1]
618+
addr, preimageLength := regs[R7], regs[R8]
619619

620620
// let h = μo⋅⋅⋅+32 if Zo⋅⋅⋅+32 ⊂ Vμ otherwise ∇
621621
preimageHashBytes := make([]byte, 32)
@@ -705,7 +705,7 @@ func Forget(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair,
705705
func Yield(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (Gas, Registers, Memory, AccumulateContextPair, error) {
706706
gas -= YieldCost
707707

708-
addr := regs[A0]
708+
addr := regs[R7]
709709

710710
// let h = μo..o+32 if Zo..o+32 ⊂ Vμ otherwise ∇
711711
hBytes := make([]byte, 32)
@@ -729,8 +729,8 @@ func Provide(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair,
729729
gas -= ProvideCost
730730

731731
// let [o, z] = φ8,9
732-
o, z := regs[A1], regs[A2]
733-
omega7 := regs[A0]
732+
o, z := regs[R8], regs[R9]
733+
omega7 := regs[R7]
734734

735735
// let d = xd ∪ (xu)d
736736
allServices := ctxPair.RegularCtx.AccumulationState.ServiceState

0 commit comments

Comments
 (0)