Close Menu
    Trending
    • Here’s How High The XRP Price Will Be If It Repeats The 2017 Surge
    • Solana Yield Protocol Carrot Shuts Down After $8M Exploit
    • Zcash (ZEC) Jumps 8% Daily, Bitcoin (BTC) Calms at $78K: Weekend Watch
    • XRP Price May Rebound 50% After ETFs Add $84M in April
    • Shiba Inu (SHIB) Breakout Blockers—Is A Crash To $0 On The Table?
    • Exodus (EXOD) Announces Official UFC Deal And Exodus Pay
    • Ripple’s XRP Turned the Tide in April After Record Losing Streak Ends
    • Crypto Tops X’s Most-Muted List, and AI Slop May Be Why
    CryptoGate
    • Home
    • Bitcoin News
    • Cryptocurrency
    • Crypto Market Trends
    • Altcoins
    • Ethereum
    • Blockchain
    • en
      • en
      • fr
      • de
      • it
      • ja
    CryptoGate
    Home»Ethereum»Serpent upgrades: More Fun Stuff
    Ethereum

    Serpent upgrades: More Fun Stuff

    CryptoGateBy CryptoGateFebruary 16, 2026No Comments7 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Over the previous two weeks our main focus has been getting all the shoppers up to date to PoC5 compatibility, and it undoubtedly has been an extended highway. Among the many adjustments to the VM embody:

    • The brand new init/code mechanism: mainly, while you create a contract, the code offered will execute instantly, after which the return worth of that code can be what turns into the contract’s code. This permits us to have contract initialization code, however nonetheless maintain to the identical format of [nonce, price, gas, to, value, data] for each transactions and contract creation, additionally making it simpler to create new contracts through forwarding contracts
    • Reordering transaction and contract information: the order is now [nonce, price, gas, to, value, data] in transactions and [gas, to, value, datain, datainsz, dataout, dataoutsz] in messages. Word that Serpent retains the ship(to, worth, fuel), o = msg(to, worth, fuel, datain, datainsz) and o = msg(to, worth, fuel, datain, datainsz, dataoutsz) parameters.
    • Payment changes: transaction creation now has a charge of 500 fuel, and several other different charges have been up to date.
    • The CODECOPY and CALLDATACOPY opcodes: CODECOPY takes code_index, mem_index, len as arguments, and copies the code from code_index … code_index+len-1 to reminiscence mem_index … mem_index+len-1. These are very helpful when mixed with init/code. There may be additionally now CODESIZE.

    The most important adjustments, nevertheless, have been to the structure surrounding the protocol. On the GUI aspect, the C++ and Go shoppers are evolving quickly, and we’ll see extra updates from that aspect coming very shortly. When you have been following Ethereum carefully, you have got seemingly seen Denny’s Lotto, a full implementation of a lottery, plus GUI, written and executed contained in the C++ shopper. From right here on, the C++ shopper will shift towards being a extra developer-oriented instrument, whereas the Go shopper will begin to give attention to being a user-facing utility (or fairly, meta-application). On the compiler aspect, Serpent has undergone quite a few substantial enhancements.

    First, the code. You possibly can peek into the Serpent compiler beneath the hood and it is possible for you to to see all of the functionsobtainable, along with their exact translations into EVM code. For instance, we’ve:

    72:     [‘access’, 2, 1,
    73:         [”, ”, 32, ‘MUL’, ‘ADD’, ‘MLOAD’]],

    Which means what entry(x,y) is definitely doing beneath the hood is it’s recursively compiling no matter x and y really are, after which loading the reminiscence at index x + y * 32; therefore, x is the pointer to the beginning of the array and y is the index. This code construction has been round since PoC4, however now I’ve upgraded the meta-language used to explain translations even additional, in order to incorporate even when, whereas and init/code on this building (earlier than they have been particular instances); now, solely set and seq stay as particular instances, and if I needed to I might even take away seq by reimplementing it as a rewrite rule.

    The most important adjustments to date have been for PoC5 compatibility. For instance, should you run serpent compile_to_assembly ‘return(msg.information[0]*2)’, you will notice:

    [“begincode0.endcode0“,“DUP“,“MSIZE“,“SWAP“,“MSIZE“,“begincode_0.endcode_0″, “DUP”, “MSIZE”, “SWAP”, “MSIZE”, “begincode0​.endcode0​“,“DUP“,“MSIZE“,“SWAP“,“MSIZE“,“begincode_0″, “CALLDATACOPY”, “RETURN”, “~begincode_0”, “#CODE_BEGIN”, 2, 0, “CALLDATALOAD”, “MUL”, “MSIZE”, “SWAP”, “MSIZE”, “MSTORE”, 32, “SWAP”, “RETURN”, “#CODE_END”, “~endcode_0”]

    The precise code there may be simply:

    [2, 0, “CALLDATALOAD”, “MUL”, “MSIZE”, “SWAP”, “MSIZE”, “MSTORE”, 32, “SWAP”, “RETURN”]

    If you wish to see what’s occurring right here, suppose {that a} message is coming in with its first datum being 5. We thus have:

    2 -> Stack: [2]
    0 -> Stack: [2, 0]
    CALLDATALOAD -> Stack: [2,5]
    MUL -> Stack: [10]
    MSIZE -> Stack: [10, 0]
    SWAP -> Stack: [0, 10]
    MSIZE -> Stack: [0, 10, 0]
    MSTORE -> Stack: [0], Reminiscence: [0, 0, 0 … 10]
    32 -> Stack: [0, 32], Reminiscence: [0, 0, 0 … 10]
    SWAP -> Stack: [32, 0], Reminiscence: [0, 0, 0 … 10]
    RETURN

    The final RETURN returns the 32 reminiscence bytes ranging from 0, or [0, 0, 0 … 10], or the quantity 10.

    Now, let’s analyze the wrapper code.

    [“begincode0.endcode0“,“DUP“,“MSIZE“,“SWAP“,“MSIZE“,“begincode_0.endcode_0″, “DUP”, “MSIZE”, “SWAP”, “MSIZE”, “begincode0​.endcode0​“,“DUP“,“MSIZE“,“SWAP“,“MSIZE“,“begincode_0″, “CALLDATACOPY”, “RETURN”, “~begincode_0”, “#CODE_BEGIN”, ….. , “#CODE_END”, “~endcode_0”]

    I elided the interior code defined above to make issues clearer. The very first thing we see are two labels, begincode_0 andendcode_0, and the #CODE_BEGIN and #CODE_END guards. The labels mark the start and finish of the interior code, and the guards are there for the later phases of the compiler, which understands that all the things between the guards ought to be compiled as if it’s a separate program. Now, let’s take a look at the primary components of the code. On this case, we’ve ~begincode_0 at place 10 and ~endcode_0 at place 24 within the ultimate code. begincode0andbegincode_0 and begincode0​andendcode_0 are used to refer to those positions, and $begincode_0.endcode_0 refers back to the size of the interval between them, 14. Now, keep in mind that throughout contract initialization the decision information is the code that you just’re feeding in. Thus, we’ve:

    14 -> Stack: [14]
    DUP -> Stack: [14, 14]
    MSIZE -> Stack: [14, 14, 0]
    SWAP -> Stack: [14, 0, 14]
    MSIZE -> Stack: [14, 0, 14, 0]
    10 -> Stack: [14, 0, 14, 0, 10]
    CALLDATACOPY -> Stack: [14, 0] Reminiscence: [ … ]
    RETURN

    Discover how the primary half of the code cleverly arrange the stack in order that it might push the interior code into reminiscence indices 0…13, after which instantly return that chunk of reminiscence. Within the ultimate compiled code,600e515b525b600a37f26002600035025b525b54602052f2, the interior code sits properly to the correct of the initializer code that merely returns it. In additional advanced contracts, initializers can even serve features like setting sure storage slots to values, and even calling or creating different contracts.

    Now, allow us to introduce the most recent and most enjoyable characteristic of Serpent: imports. One widespread use case in contract land is that you just need to give a contract the flexibility to spawn off new contracts. Drawback is, the best way to you set the code for the spawned contracts into the spawner contracts? Earlier than, the one answer was the uncomfortable strategy of compiling the newer contracts first, after which placing the compiled code into an array. Now, we’ve a greater answer: import.

    Put the next into returnten.se:

    x = create(tx.fuel – 100, 0, import(mul2.se))
    return(msg(x,0,tx.gas-100,[5],1))

    Now, put the next into mul2.se:

    return(msg.information[0]*2)

    Now, should you serpent compile returnten.se and run the contract, you discover that, voila, it returns ten. The explanation why is apparent. The returnten.se contract creates an occasion of the mul2.se contract, after which calls it with the worth 5. mul2.se, because the title suggests, is a doubler, and so it returns 5*2 = 10. Word that import just isn’t a operate in the usual sense; x = import(‘123.se’) will fail, and import solely works within the very particular context of create.

    Now, suppose you might be making a 1000-line monster contract and need to cut up it up into information. To try this, we use inset. Intoouter.se, put:

    if msg.information[0] == 1:
    inset(interior.se)

    And into interior.se, put:

    return(3)

    Operating serpent compile outer.se offers you a pleasant piece of compiled code that returns 3 if the msg.information[0] argument is the same as one. And that’s all there may be to it.

    Upcoming updates to Serpent embody:

    • An enchancment of this mechanism so it doesn’t load the interior code twice should you attempt to use import twice with the identical filename
    • String literals
    • Area and code-efficiency enhancements for array literals
    • A debugging decorator (ie. a compiling operate which tells you what traces of Serpent correspond to what bytes of compiled code)

    Within the brief time period, although, my very own effort will give attention to bugfixes, a cross-client take a look at suite, and continued work on ethereumjs-lib.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    CryptoGate
    • Website
    • Pinterest

    Related Posts

    Crypto Market Still In Fear After Historical Lows, But Can Bitcoin And Ethereum Recover?

    May 1, 2026

    Are Ethereum Whales Dumping And Crashing The Price? Here’s What We Know

    May 1, 2026

    Announcing Cohort 7 of the Ethereum Protocol Fellowship

    April 30, 2026

    Ethereum Traders Shift: Spot Market Weakness Drives Rise In Derivatives Trading

    April 29, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Strategy’s Michael Saylor Pitches Bitcoin To The Middle East

    December 9, 2025

    REX-Osprey Dogecoin and XRP ETFs likely to debut this week

    September 16, 2025

    The 1.x Files: EIP 1559 and the Ethereum Improvement Horizon

    November 27, 2025

    US Bitcoin and Ethereum ETFs face $1 billion outflow amid market dip

    August 20, 2025

    ETH ETF Outflows Top $242M Despite Ether Holding $2K

    February 14, 2026
    Categories
    • Altcoins
    • Bitcoin News
    • Blockchain
    • Crypto Market Trends
    • Crypto Mining
    • Cryptocurrency
    • Ethereum
    About us

    Welcome to cryptogate.info — your trusted gateway to the latest and most reliable news in the world of cryptocurrency. Whether you’re a seasoned trader, a blockchain enthusiast, or just curious about the future of digital finance, we’re here to keep you informed and ahead of the curve.

    At cryptogate.info, we are passionate about delivering timely, accurate, and insightful updates on everything crypto — from market trends, new coin launches, and regulatory developments to expert analysis and educational content. Our mission is to empower you with knowledge that helps you navigate the fast-paced and ever-evolving crypto landscape with confidence.

    Top Insights

    Bitcoin Analysts Point to ‘Manipulation’ as BTC Price Falls to 17-Day Low

    August 22, 2025

    Google Says Quantum Breakthroughs May Be Closer: Should Crypto Holders Worry?

    March 28, 2026

    Wormhole Stakes Its Claim in Stargate Contest

    August 21, 2025
    Categories
    • Altcoins
    • Bitcoin News
    • Blockchain
    • Crypto Market Trends
    • Crypto Mining
    • Cryptocurrency
    • Ethereum
    YouTube
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • Impressum
    • About us
    • Contact us
    Copyright © 2025 CryptoGate All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.