utils

package
v1.16.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT, Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const AllowanceSlotIndex = 1
View Source
const BalanceSlotIndex = 0
View Source
const DepositorSlotIndex = 2
View Source
const MultiStorageArtifact = "../contracts/artifacts/MultiStorage.sol/MultiStorage.json"
View Source
const SimpleStorageArtifact = "../contracts/artifacts/SimpleStorage.sol/SimpleStorage.json"
View Source
const TokenVaultArtifact = "../contracts/artifacts/TokenVault.sol/TokenVault.json"

Variables

This section is empty.

Functions

func DeployContract

func DeployContract(t devtest.T, user *dsl.EOA, bin []byte) (common.Address, *types.Receipt)

DeployContract deploys the contract creation bytecode from the given artifact. user must provide a Plan() method compatible with txplan.NewPlannedTx (kept generic).

func FetchAndVerifyProofs

func FetchAndVerifyProofs(t devtest.T, sys *MixedOpProofPreset, address common.Address, slots []common.Hash, block uint64)

FetchAndVerifyProofs fetches account proofs from both L2EL and L2ELB for the given address

func LoadArtifact

func LoadArtifact(t devtest.T, artifactPath string) (abi.ABI, []byte)

LoadArtifact reads the forge artifact JSON at artifactPath and returns the parsed ABI and the creation bytecode (as bytes). It prefers bytecode.object (creation) and falls back to deployedBytecode.object if needed.

func NormalizeProofResponse

func NormalizeProofResponse(res *eth.AccountResult)

NormalizeProofResponse standardizes an AccountResult obtained from eth_getProof across different client implementations (e.g., Geth, Reth) so that they can be compared meaningfully in tests.

Ethereum clients may encode empty or zeroed data structures differently while still representing the same logical state. For example:

  • An empty storage proof may appear as [] (Geth) or ["0x80"] (Reth).

This function normalizes such differences by:

  • Converting single-element proofs containing "0x80" to an empty proof slice.

func VerifyProof

func VerifyProof(res *eth.AccountResult, stateRoot common.Hash) error

VerifyProof verifies an account and its storage proofs against a given state root.

This function extends the standard behavior of go-ethereum’s AccountResult.Verify() by gracefully handling the case where the account’s storage trie root is empty (0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421).

Types

type Artifact

type Artifact struct {
	ABI      json.RawMessage `json:"abi"`
	Bytecode struct {
		Object string `json:"object"`
	} `json:"bytecode"`
}

minimal parts of artifact

type Contract

type Contract struct {
	// contains filtered or unexported fields
}

func NewContract

func NewContract(address common.Address, parsedABI abi.ABI) *Contract

func (*Contract) ABI

func (c *Contract) ABI() abi.ABI

func (*Contract) Address

func (c *Contract) Address() common.Address

type MixedOpProofPreset

type MixedOpProofPreset struct {
	Log log.Logger
	T   devtest.T

	L1Network *dsl.L1Network
	L1EL      *dsl.L1ELNode

	L2Chain   *dsl.L2Network
	L2Batcher *dsl.L2Batcher

	L2ELSequencer *dsl.L2ELNode
	L2CLSequencer *dsl.L2CLNode

	L2ELValidator *dsl.L2ELNode
	L2CLValidator *dsl.L2CLNode

	Wallet *dsl.HDWallet

	FaucetL1 *dsl.Faucet
	FaucetL2 *dsl.Faucet
	FunderL1 *dsl.Funder
	FunderL2 *dsl.Funder

	TestSequencer *dsl.TestSequencer
}

MixedOpProofPreset sets up a two-node L2 devnet (sequencer + validator) with configurable EL clients via environment variables:

  • OP_DEVSTACK_PROOF_SEQUENCER_EL: "op-geth" (default), "op-reth", or "op-reth-with-proof"
  • OP_DEVSTACK_PROOF_VALIDATOR_EL: "op-reth-with-proof" (default), "op-reth", or "op-geth"

func NewMixedOpProofPreset

func NewMixedOpProofPreset(t devtest.T) *MixedOpProofPreset

NewMixedOpProofPreset creates the preset using MixedSingleChainRuntime for full control over EL client types.

func (*MixedOpProofPreset) L2ELSequencerNode

func (m *MixedOpProofPreset) L2ELSequencerNode() *dsl.L2ELNode

func (*MixedOpProofPreset) L2ELValidatorNode

func (m *MixedOpProofPreset) L2ELValidatorNode() *dsl.L2ELNode

func (*MixedOpProofPreset) RethWithProofL2ELNode

func (m *MixedOpProofPreset) RethWithProofL2ELNode() *dsl.L2ELNode

RethWithProofL2ELNode returns the first node running op-reth with proof history. Falls back to the validator, then sequencer.

type MultiStorage

type MultiStorage struct {
	*Contract
	// contains filtered or unexported fields
}

func DeployMultiStorage

func DeployMultiStorage(t devtest.T, user *dsl.EOA) (*MultiStorage, *types.Receipt)

func (*MultiStorage) SetValues

func (c *MultiStorage) SetValues(user *dsl.EOA, a, b *big.Int) *types.Receipt

type SimpleStorage

type SimpleStorage struct {
	*Contract
	// contains filtered or unexported fields
}

func DeploySimpleStorage

func DeploySimpleStorage(t devtest.T, user *dsl.EOA) (*SimpleStorage, *types.Receipt)

func (*SimpleStorage) PlanSetValue

func (c *SimpleStorage) PlanSetValue(user *dsl.EOA, value *big.Int) *txplan.PlannedTx

func (*SimpleStorage) SetValue

func (c *SimpleStorage) SetValue(user *dsl.EOA, value *big.Int) *types.Receipt

type TokenVault

type TokenVault struct {
	*Contract
	// contains filtered or unexported fields
}

func DeployTokenVault

func DeployTokenVault(t devtest.T, user *dsl.EOA) (*TokenVault, *types.Receipt)

func (*TokenVault) Approve

func (c *TokenVault) Approve(user *dsl.EOA, spender common.Address, amount *big.Int) *types.Receipt

func (*TokenVault) DeactivateAllowance

func (c *TokenVault) DeactivateAllowance(user *dsl.EOA, spender common.Address) *types.Receipt

func (*TokenVault) Deposit

func (c *TokenVault) Deposit(user *dsl.EOA, amount eth.ETH) *types.Receipt

func (*TokenVault) GetAllowanceSlot

func (c *TokenVault) GetAllowanceSlot(owner, spender common.Address) common.Hash

func (*TokenVault) GetBalanceSlot

func (c *TokenVault) GetBalanceSlot(user common.Address) common.Hash

func (*TokenVault) GetDepositorSlot

func (c *TokenVault) GetDepositorSlot(index uint64) common.Hash

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL