Comments (3)
IMO it would be better to focus on features that make the languages/libraries more powerful/ergonomic rather than enshrining another new first-class citizen in the language.
There's a transient storage library I wrote that I am using for work: https://github.com/Philogy/transient-goodies that is already relatively ergonomic to use, behaving like normal storage in many ways:
- being assigned unique slots in the contract's storage slot
- being composable into mappings and structs out-of-the-box
it allows the following usage which besides the .get
, .inc
overhead is pretty close to native storage IMO:
import {tuint256} from "transient-goodies/src/TransientPrimitives.sol";
contract MyContract {
mapping(bytes32 => tuint256) internal txValidatedHashes;
function validate(bytes32[] calldata hashes) external {
for (uint256 i = 0; i < hashes.length; i++) {
bytes32 hash = hashes[i];
require(txValidatedHashes[hash].get() == 0, "Already validated");
txValidatedHashes[hash].inc(1);
}
}
}
I wonder if implementing features that would allow library devs like me to make such libraries even more ergonomic or useful wouldn't be more powerful and achieve more than focusing on the specific case of transient storage itself.
Things like:
- allowing you to customize the behaviour of assignment of custom types/structs
- allowing you to define implicit type casting for custom types/structs
- allowing you to define the behavior of other operations
-=
,+=
,*=
, etc. for custom types / structs - generics (type parameters & type classes aka interfaces)
from solidity.
Hey @Philogy!
Thank you for detailing this out so well. As mentioned in my response to your quote-tweet here, we agree that implementing features like these into a standard library for library devs to use would be quite useful. And this is indeed what we are aiming to do with Experimental Solidity (you can watch our talk from Solidity Summit 2024 here). However, building a language with proper generics that's logically accurate and tested thoroughly is a non-trivial and time-consuming process and we're afraid that the community would not want to hold off on support for these features at the EVM-level.
That being said, we agree that your proposal is still proves to be the better approach in the longer term and so we did not start working on transient storage support until the community pushed for it.
In conclusion, even though the broader goal with Experimental Solidity is exactly what you proposed, we cannot ignore the immediate community demand and will have to focus on high-level language support for transient storage for the time-being. Would love to hear your further thoughts. :)
from solidity.
@mehtavishwa30 I've seen your point and appreciate the note. The reason I brought it up again here is because I wanted to be more specific on what features exactly I think could be implemented short-term without a larger rework like full generics (such as being able to override assignment behavior, defining -=
, +=
, etc. for custom types, type casting).
Now I have no knowledge of the Solidity compiler's internals so I can't judge the complexity of implementing these over transient storage itself but from the description of solc devs that I've read saying that high-level transient storage support is non-trivial, requiring several deep changes it seems like this features might be equally if not less complex while providing more short-term benefit.
Yes, the community has requested high-level transient storage support and it's great to see how the team is incorporating this feedback but I think there are different ways to achieve this.
from solidity.
Related Issues (20)
- Calling solc with `--standard-json` with `"language":"yul"` with tstore in the YUL leads to no generated code HOT 1
- Nested memory arrays not implemented in ABICoder V1
- Switch all MacOS scripts to use GNU utils
- codegen error: Copying of type struct memory[] memory to storage not yet supported. HOT 1
- IR-based Codegen error: too deep inside the stack.
- SMTChecker: Error trying to invoke SMT solver
- SMTChecker: struct variable push() cause false positive HOT 1
- ABICoderv1 and AST import cause storage difference due to function-type variable assignment
- mstore(add(mload(0x80), 0x20), xx) cause IR-based codegen execution revert.
- IR-base codegen, abicoder v1, Ast import lack of memory protection mechanism
- write to uint[2][2] calldata fail in IR-based Codegen HOT 1
- IR-based codegen: Modifying the length of a dynamic array to a large number in assembly, followed by a push() operation, will cause a revert.
- Unnamed return variable is displayed incorrectly in counter example
- When accessing an out-of-bounds index in a fixed-size array, the contract execution reverts
- Unreachable code warning for internal function called by an abstract contract HOT 1
- Compiler error on attempting to use hexadecimal literals of length 39-41 as integers HOT 1
- Unable to check existence of precompiled contract by its address or get its code in VM or Sepolia testnet HOT 1
- Yul interpreter subset for side-effect-free evaluation
- do-while results in redundant branching instructions when compiling via IR HOT 1
- Call external pure function from another pure function of the same contract using "this" causes an error
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 solidity.