Skip to content

Commit

Permalink
feat: add 64 bit opcodes and uint64 registers (#146)
Browse files Browse the repository at this point in the history
* feat: add 64 bit opcodes and uint64 registers

* fix: host func casting
  • Loading branch information
danielvladco authored Nov 28, 2024
1 parent d791611 commit acdd66f
Show file tree
Hide file tree
Showing 19 changed files with 2,343 additions and 453 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ go 1.22.5
require (
github.com/cockroachdb/pebble v1.1.0
github.com/ebitengine/purego v0.8.1
github.com/stretchr/testify v1.9.0
github.com/golang/mock v1.6.0
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.27.0
)

Expand Down
15 changes: 13 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxI
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
Expand Down Expand Up @@ -59,10 +61,11 @@ github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3c
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
Expand All @@ -72,20 +75,27 @@ golang.org/x/exp v0.0.0-20240110193028-0dcbfd608b1e h1:723BNChdd0c2Wk6WOE320qGBi
golang.org/x/exp v0.0.0-20240110193028-0dcbfd608b1e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
Expand All @@ -94,6 +104,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
71 changes: 49 additions & 22 deletions internal/polkavm/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ func (m *Memory) Write(address uint32, data []byte) error {
return nil
}

type Registers [13]uint32
type Registers [13]uint64

type Gas int64

// HostCall the generic Ω function definition Ωx(n, ϱ, ω, μ, x) defined in section A.6
type HostCall[X any] func(hostCall uint32, gasCounter Gas, regs Registers, mem Memory, x X) (Gas, Registers, Memory, X, error)

//go:generate go run github.com/golang/mock/mockgen --destination mutator_mock.go --package polkavm . Mutator
type Mutator interface {
Trap() error
Fallthrough()
Expand All @@ -108,67 +109,93 @@ type Mutator interface {
BranchGreaterSignedImm(s1 Reg, s2 uint32, target uint32)
SetLessThanUnsignedImm(d Reg, s1 Reg, s2 uint32)
SetLessThanSignedImm(d Reg, s1 Reg, s2 uint32)
ShiftLogicalLeftImm(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRightImm(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRightImmAlt(d Reg, s1 Reg, s2 uint32)
NegateAndAddImm(d Reg, s1 Reg, s2 uint32)
ShiftLogicalLeftImm32(d Reg, s1 Reg, s2 uint32)
ShiftLogicalLeftImm64(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRightImm32(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRightImm64(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRightImmAlt32(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRightImmAlt64(d Reg, s1 Reg, s2 uint32)
NegateAndAddImm32(d Reg, s1 Reg, s2 uint32)
NegateAndAddImm64(d Reg, s1 Reg, s2 uint32)
SetGreaterThanUnsignedImm(d Reg, s1 Reg, s2 uint32)
SetGreaterThanSignedImm(d Reg, s1 Reg, s2 uint32)
ShiftLogicalRightImmAlt(d Reg, s1 Reg, s2 uint32)
ShiftLogicalLeftImmAlt(d Reg, s1 Reg, s2 uint32)
Add(d Reg, s1, s2 Reg)
AddImm(d Reg, s1 Reg, s2 uint32)
Sub(d Reg, s1, s2 Reg)
ShiftLogicalRightImmAlt32(d Reg, s1 Reg, s2 uint32)
ShiftLogicalRightImmAlt64(d Reg, s1 Reg, s2 uint32)
ShiftLogicalLeftImmAlt32(d Reg, s1 Reg, s2 uint32)
ShiftLogicalLeftImmAlt64(d Reg, s1 Reg, s2 uint32)
Add32(d Reg, s1, s2 Reg)
Add64(d Reg, s1, s2 Reg)
AddImm32(d Reg, s1 Reg, s2 uint32)
AddImm64(d Reg, s1 Reg, s2 uint32)
Sub32(d Reg, s1, s2 Reg)
Sub64(d Reg, s1, s2 Reg)
And(d Reg, s1, s2 Reg)
AndImm(d Reg, s1 Reg, s2 uint32)
Xor(d Reg, s1, s2 Reg)
XorImm(d Reg, s1 Reg, s2 uint32)
Or(d Reg, s1, s2 Reg)
OrImm(d Reg, s1 Reg, s2 uint32)
Mul(d Reg, s1, s2 Reg)
MulImm(d Reg, s1 Reg, s2 uint32)
Mul32(d Reg, s1, s2 Reg)
Mul64(d Reg, s1, s2 Reg)
MulImm32(d Reg, s1 Reg, s2 uint32)
MulImm64(d Reg, s1 Reg, s2 uint32)
MulUpperSignedSigned(d Reg, s1, s2 Reg)
MulUpperSignedSignedImm(d Reg, s1 Reg, s2 uint32)
MulUpperUnsignedUnsigned(d Reg, s1, s2 Reg)
MulUpperUnsignedUnsignedImm(d Reg, s1 Reg, s2 uint32)
MulUpperSignedUnsigned(d Reg, s1, s2 Reg)
SetLessThanUnsigned(d Reg, s1, s2 Reg)
SetLessThanSigned(d Reg, s1, s2 Reg)
ShiftLogicalLeft(d Reg, s1, s2 Reg)
ShiftLogicalRight(d Reg, s1, s2 Reg)
ShiftLogicalRightImm(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRight(d Reg, s1, s2 Reg)
DivUnsigned(d Reg, s1, s2 Reg)
DivSigned(d Reg, s1, s2 Reg)
RemUnsigned(d Reg, s1, s2 Reg)
RemSigned(d Reg, s1, s2 Reg)
ShiftLogicalLeft32(d Reg, s1, s2 Reg)
ShiftLogicalLeft64(d Reg, s1, s2 Reg)
ShiftLogicalRight32(d Reg, s1, s2 Reg)
ShiftLogicalRight64(d Reg, s1, s2 Reg)
ShiftLogicalRightImm32(d Reg, s1 Reg, s2 uint32)
ShiftLogicalRightImm64(d Reg, s1 Reg, s2 uint32)
ShiftArithmeticRight32(d Reg, s1, s2 Reg)
ShiftArithmeticRight64(d Reg, s1, s2 Reg)
DivUnsigned32(d Reg, s1, s2 Reg)
DivUnsigned64(d Reg, s1, s2 Reg)
DivSigned32(d Reg, s1, s2 Reg)
DivSigned64(d Reg, s1, s2 Reg)
RemUnsigned32(d Reg, s1, s2 Reg)
RemUnsigned64(d Reg, s1, s2 Reg)
RemSigned32(d Reg, s1, s2 Reg)
RemSigned64(d Reg, s1, s2 Reg)
CmovIfZero(d Reg, s, c Reg)
CmovIfZeroImm(d Reg, c Reg, s uint32)
CmovIfNotZero(d Reg, s, c Reg)
CmovIfNotZeroImm(d Reg, c Reg, s uint32)
StoreU8(src Reg, offset uint32) error
StoreU16(src Reg, offset uint32) error
StoreU32(src Reg, offset uint32) error
StoreU64(src Reg, offset uint32) error
StoreImmU8(offset uint32, value uint32) error
StoreImmU16(offset uint32, value uint32) error
StoreImmU32(offset uint32, value uint32) error
StoreImmU64(offset uint32, value uint32) error
StoreImmIndirectU8(base Reg, offset uint32, value uint32) error
StoreImmIndirectU16(base Reg, offset uint32, value uint32) error
StoreImmIndirectU32(base Reg, offset uint32, value uint32) error
StoreImmIndirectU64(base Reg, offset uint32, value uint32) error
StoreIndirectU8(src Reg, base Reg, offset uint32) error
StoreIndirectU16(src Reg, base Reg, offset uint32) error
StoreIndirectU32(src Reg, base Reg, offset uint32) error
StoreIndirectU64(src Reg, base Reg, offset uint32) error
LoadU8(dst Reg, offset uint32) error
LoadI8(dst Reg, offset uint32) error
LoadU16(dst Reg, offset uint32) error
LoadI16(dst Reg, offset uint32) error
LoadU32(dst Reg, offset uint32) error
LoadI32(dst Reg, offset uint32) error
LoadU64(dst Reg, offset uint32) error
LoadIndirectU8(dst Reg, base Reg, offset uint32) error
LoadIndirectI8(dst Reg, base Reg, offset uint32) error
LoadIndirectU16(dst Reg, base Reg, offset uint32) error
LoadIndirectI16(dst Reg, base Reg, offset uint32) error
LoadIndirectU32(dst Reg, base Reg, offset uint32) error
LoadIndirectI32(dst Reg, base Reg, offset uint32) error
LoadIndirectU64(dst Reg, base Reg, offset uint32) error
LoadImm(dst Reg, imm uint32)
LoadImm64(dst Reg, imm uint64)
LoadImmAndJump(ra Reg, value uint32, target uint32)
LoadImmAndJumpIndirect(ra Reg, base Reg, value, offset uint32) error
Jump(target uint32)
Expand Down
28 changes: 14 additions & 14 deletions internal/polkavm/host_call/accumulate_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ func Bless(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (
// let [m, a, v, o, n] = ω7...12
managerServiceId, assignServiceId, designateServiceId, addr, servicesNr := regs[A0], regs[A1], regs[A2], regs[A3], regs[A4]
// let g = {(s ↦ g) where E4(s) ⌢ E8(g) = μ_o+12i⋅⋅⋅+12 | i ∈ Nn} if Zo⋅⋅⋅+12n ⊂ Vμ otherwise ∇
for i := range servicesNr {
serviceId, err := readNumber[block.ServiceId](mem, addr+(12*i), 4)
for i := range uint32(servicesNr) {
serviceId, err := readNumber[block.ServiceId](mem, uint32(addr)+(12*i), 4)
if err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, err
}
serviceGas, err := readNumber[uint64](mem, addr+(12*i)+4, 8)
serviceGas, err := readNumber[uint64](mem, uint32(addr)+(12*i)+4, 8)
if err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, err
}
Expand All @@ -54,12 +54,12 @@ func Assign(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair)
// let o = ω8
addr := regs[A1]
core := regs[A0]
if core >= uint32(common.TotalNumberOfCores) {
if core >= uint64(common.TotalNumberOfCores) {
return gas, withCode(regs, CORE), mem, ctxPair, nil
}
for i := 0; i < state.PendingAuthorizersQueueSize; i++ {
bytes := make([]byte, 32)
if err := mem.Read(addr+uint32(32*i), bytes); err != nil {
if err := mem.Read(uint32(addr)+uint32(32*i), bytes); err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, nil
}
ctxPair.RegularCtx.AccumulationState.WorkReportsQueue[core][i] = crypto.Hash(bytes)
Expand All @@ -84,7 +84,7 @@ func Designate(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPai
addr := regs[A0]
for i := 0; i < common.NumberOfValidators; i++ {
bytes := make([]byte, 336)
if err := mem.Read(addr+uint32(336*i), bytes); err != nil {
if err := mem.Read(uint32(addr)+uint32(336*i), bytes); err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, nil
}

Expand All @@ -109,7 +109,7 @@ func Checkpoint(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPa
ctxPair.ExceptionalCtx = ctxPair.RegularCtx

// Set the new ϱ' value into ω′7
regs[A0] = uint32(gas & ((1 << 32) - 1))
regs[A0] = uint64(gas & ((1 << 32) - 1))

return gas, regs, mem, ctxPair, nil
}
Expand All @@ -126,7 +126,7 @@ func New(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (Ga

// c = μo⋅⋅⋅+32 if No⋅⋅⋅+32 ⊂ Vμ otherwise ∇
codeHashBytes := make([]byte, 32)
if err := mem.Read(addr, codeHashBytes); err != nil {
if err := mem.Read(uint32(addr), codeHashBytes); err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, nil
}

Expand All @@ -149,7 +149,7 @@ func New(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (Ga

// if a ≠ ∇ ∧ b ≥ (xs)t
if b >= ctxPair.RegularCtx.ServiceAccount().ThresholdBalance() {
regs[A0] = uint32(ctxPair.RegularCtx.ServiceId)
regs[A0] = uint64(ctxPair.RegularCtx.ServiceId)
currentAccount := ctxPair.RegularCtx.ServiceAccount()
currentAccount.Balance = b
ctxPair.RegularCtx.ServiceState[ctxPair.RegularCtx.ServiceId] = currentAccount
Expand All @@ -176,7 +176,7 @@ func Upgrade(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair)

// c = μo⋅⋅⋅+32 if No⋅⋅⋅+32 ⊂ Vμ otherwise ∇
codeHash := make([]byte, 32)
if err := mem.Read(addr, codeHash); err != nil {
if err := mem.Read(uint32(addr), codeHash); err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, nil
}

Expand All @@ -202,7 +202,7 @@ func Transfer(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair

// m = μo⋅⋅⋅+M if No⋅⋅⋅+M ⊂ Vμ otherwise ∇
m := make([]byte, service.TransferMemoSizeBytes)
if err := mem.Read(o, m); err != nil {
if err := mem.Read(uint32(o), m); err != nil {
return gas, withCode(regs, OK), mem, ctxPair, nil
}

Expand Down Expand Up @@ -263,7 +263,7 @@ func Quit(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair) (G

// m = E−1(μo⋅⋅⋅+M)
memo := make([]byte, service.TransferMemoSizeBytes)
if err := mem.Read(addr, memo); err != nil {
if err := mem.Read(uint32(addr), memo); err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, nil
}

Expand Down Expand Up @@ -309,7 +309,7 @@ func Solicit(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair,
addr, preimageLength := regs[A0], regs[A1]
// let h = μo⋅⋅⋅+32 if Zo⋅⋅⋅+32 ⊂ Vμ otherwise ∇
preimageHashBytes := make([]byte, 32)
if err := mem.Read(addr, preimageHashBytes); err != nil {
if err := mem.Read(uint32(addr), preimageHashBytes); err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, nil
}

Expand Down Expand Up @@ -350,7 +350,7 @@ func Forget(gas Gas, regs Registers, mem Memory, ctxPair AccumulateContextPair,

// let h = μo⋅⋅⋅+32 if Zo⋅⋅⋅+32 ⊂ Vμ otherwise ∇
preimageHashBytes := make([]byte, 32)
if err := mem.Read(addr, preimageHashBytes); err != nil {
if err := mem.Read(uint32(addr), preimageHashBytes); err != nil {
return gas, withCode(regs, OOB), mem, ctxPair, nil
}

Expand Down
Loading

0 comments on commit acdd66f

Please sign in to comment.