Categorygithub.com/0xPolygon/eth-state-transition
modulepackage
0.0.0-20230518075833-1fe697a5d8b0
Repository: https://github.com/0xpolygon/eth-state-transition.git
Documentation: pkg.go.dev

# README

Eth-state-transition

Ethereum state transition function.

Usage


import (
    itrie "github.com/0xPolygon/eth-state-transition/immutable-trie"
    "github.com/0xPolygon/eth-state-transition/runtime"
    state "github.com/0xPolygon/eth-state-transition"
)

func main() {
    // get a reference for the state
    state := itrie.NewArchiveState(itrie.NewMemoryStorage())
    snap := s.NewSnapshot()

    // create a transition object
    forks := runtime.ForksInTime{}
    config := runtime.TxContext{}
    transition := state.NewTransition(forks, config, snap)

    // process a transaction
    result, err := transition.Write(&state.Transaction{})
    if err != nil {
        panic(err)
    }

    fmt.Printf("Logs: %v\n", result.Logs)
    fmt.Printf("Gas used: %d\n", result.GasUsed)

    // retrieve the state data changed
    objs := transition.Commit()

    // commit the data to the state
    if _, err := snap.Commit(objs); err != nil {
        panic(err)
    }
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewExecutor creates a new executor.
No description provided by the author
TestState tests a set of tests on a state.
No description provided by the author

# Constants

Per transaction not creating a contract.
Per transaction that creates a contract.

# Variables

No description provided by the author
EmptyRootHash is the root when there are no transactions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Account is an object we can retrieve from the state.
No description provided by the author
No description provided by the author
Object is the serialization of the radix object (can be merged to StateObject?).
PreState is the account prestate.
No description provided by the author
StorageObject is an entry in the storage.
No description provided by the author
No description provided by the author
Txn is a reference of the state.

# Interfaces

No description provided by the author
No description provided by the author

# Type aliases

GetHashByNumber returns the hash function of a block number.
No description provided by the author
PreStates is a set of pre states.