Comments (6)
https://github.com/WebAssembly/spec/blob/master/document/core/exec/instructions.rst
Looking at SELECT
as a template.
So right now we have:
useGas
Subtracts an amount to the gas counter
Parameters
- amount
i64
the amount to subtract to the gas counter
Returns
nothing
But we might think to have (I'm taking liberty with making my own notation for the system contract math notation at the end):
useGas
- Assert: due to validation, that the top element of the stack is a value of type
i64
. - Pop the value
i64.const g
from the top of the stack. - Load the value
i64.const G
fromEEI.gasAvailable
. - If
g <= G
, then:
i. SetEEI.gasAvailable
toG - g
. - Else:
ii. SetEEI.trapReason
toout of gas
and Trap.
~\\[-1ex]
\begin{array}{l}
\begin{array}{lcl@{\qquad}l}
EEI; (\I32.\CONST g) (useGas) &\stepto& EEI'
\end{array}
\\ \qquad
(\iff EEI.gasAvailable = G \\
\wedge G >= g \\
\wedge EEI' = EEI \with gasAvailable = G - g \\
)
\end{array}
\begin{array}{l}
\begin{array}{lcl@{\qquad}l}
EEI; (\I32.\CONST g) (useGas) &\stepto& EEI'; trap
\end{array}
\\ \qquad
(\iff EEI.gasAvailable = G \\
\wedge G < g \\
\wedge EEI' = EEI \with trapReason = "out of gas" \\
)
\end{array}
This would give us a nice way to formalize/disambiguate issues like: #72
from design.
Can you give a short example of what format you'd like it to have? (There are so many versions of the "WAMS spec", I'm not entirely sure which one do you mean.)
from design.
- Assert: due to validation, that the top element of the stack is a value of type i64.
- Pop the value i64.const g from the top of the stack.
I am not sure we actually have access to the stack.
External functions donβt receive access to the stack of the caller, just arguments, which were popped already off the stack.
from design.
Would the following make more sense?
Note that I've switched (i32.const g) (useGas)
to call EEI.useGas i64.const g
to reflect that this is a function call.
call EEI.useGas i64.const g
- Load the value
i64.const G
fromEEI.gasAvailable
. - If
g <= G
, then:
i. SetEEI.gasAvailable
toG - g
. - Else:
ii. SetEEI.trapReason
toout of gas
and Trap.
~\\[-1ex]
\begin{array}{l}
\begin{array}{lcl@{\qquad}l}
EEI; (call EEI.useGas i64.const g) &\stepto& EEI'
\end{array}
\\ \qquad
(\iff EEI.gasAvailable = G \\
\wedge G >= g \\
\wedge EEI' = EEI \with gasAvailable = G - g \\
)
\end{array}
\begin{array}{l}
\begin{array}{lcl@{\qquad}l}
EEI; (call EEI.useGas i64.const g) &\stepto& EEI'; trap
\end{array}
\\ \qquad
(\iff EEI.gasAvailable = G \\
\wedge G < g \\
\wedge EEI' = EEI \with trapReason = "out of gas" \\
)
\end{array}
from design.
From the perspective of a lowly implementer, this would help a lot and would probably preempt a lot of the dumb questions I've asked e.g. https://gitter.im/ewasm/internal?at=5aac31dbc3c5f8b90d7e5e15.
from design.
https://docs.google.com/document/d/1z_u-hmQ6kF50rXbBEmT_tLOnyBGaBplpoOIe0FPEZ3s/edit?usp=sharing
from design.
Related Issues (20)
- Enviroment abstraction for eWASM code execution
- Generic buffer API
- Inlined metering HOT 6
- Update to Constantinople/Petersburg HOT 1
- Equivalence, invertable transformation, and size optimization of Wasm binaries HOT 4
- Serenity async proposal (discussion) HOT 4
- Async vs sync interface HOT 2
- Linear storage design HOT 4
- System/standard library for bignumbers HOT 19
- Eth 2.0 Phase 2 with "precompiles" proposal HOT 1
- wasm256 - Wasm with native i256 HOT 1
- how to test the gas costs
- opcode gas
- Shared memory between instances HOT 1
- "Stack too deep" in EWASM
- Provide kecccak256 host function HOT 3
- JVM pros/cons clarification
- Update EEI for London hardfork
- IP OGS HOT 1
- ewasm status HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from design.