repo_description: The core protocol of harmony
repo_topics: blockchain bls consensus distributed-ledger-technology harmony harmony-protocol pbft proof-of-stake sharding
code: package core
  
  /*
  import (
  	"math/big"
  	"testing"
  
  	"github.com/ethereum/go-ethereum/common"
  	"github.com/ethereum/go-ethereum/consensus/ethash"
  	"github.com/ethereum/go-ethereum/core/types"
  	"github.com/ethereum/go-ethereum/crypto"
  	"github.com/harmony-one/harmony/core/rawdb"
  	"github.com/harmony-one/harmony/core/vm"
  	"github.com/harmony-one/harmony/internal/params"
  )
  
  // TestTransientStorageReset ensures the transient storage is wiped correctly
  // between transactions.
  func TestTransientStorageReset(t *testing.T) {
  	var (
  		engine      = ethash.NewFaker()
  		key, _      = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
  		address     = crypto.PubkeyToAddress(key.PublicKey)
  		destAddress = crypto.CreateAddress(address, 0)
  		funds       = big.NewInt(1000000000000000)
  		vmConfig    = vm.Config{
  			ExtraEips: []int{1153}, // Enable transient storage EIP
  		}
  	)
  	code := append([]byte{
  		// TLoad value with location 1
  		byte(vm.PUSH1), 0x1,
  		byte(vm.TLOAD),
  
  		// PUSH location
  		byte(vm.PUSH1), 0x1,
  
  		// SStore location:value
  		byte(vm.SSTORE),
  	}, make([]byte, 32-6)...)
  	initCode := []byte{
  		// TSTORE 1:1
  		byte(vm.PUSH1), 0x1,
  		byte(vm.PUSH1), 0x1,
  		byte(vm.TSTORE),
  
  		// Get the runtime-code on the stack
  		byte(vm.PUSH32)}
  	initCode = append(initCode, code...)
  	initCode = append(initCode, []byte{
  		byte(vm.PUSH1), 0x0, // offset
  		byte(vm.MSTORE),
  		byte(vm.PUSH1), 0x6, // size
  		byte(vm.PUSH1), 0x0, // offset
  		byte(vm.RETURN), // return 6 bytes of zero-code
  	}...)
  	gspec := &Genesis{
  		Config: params.TestChainConfig,
  		Alloc: GenesisAlloc{
  			address: {Balance: funds},
  		},
  	}
  	nonce := uint64(0)
  	signer := types.HomesteadSigner{}
  	_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 1, func(i int, b *BlockGen) {
  		fee := big.NewInt(1)
  		if b.header.BaseFee != nil {
  			fee = b.header.BaseFee
  		}
  		b.SetCoinbase(common.Address{1})
  		tx, _ := types.SignNewTx(key, signer, &types.LegacyTx{
  			Nonce:    nonce,
  			GasPrice: new(big.Int).Set(fee),
  			Gas:      100000,
  			Data:     initCode,
  		})
  		nonce++
  		b.AddTxWithVMConfig(tx, vmConfig)
  
  		tx, _ = types.SignNewTx(key, signer, &types.LegacyTx{
  			Nonce:    nonce,
  			GasPrice: new(big.Int).Set(fee),
  			Gas:      100000,
  			To:       &destAddress,
  		})
  		b.AddTxWithVMConfig(tx, vmConfig)
  		nonce++
  	})
  
  	// Initialize the blockchain with 1153 enabled.
  	chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vmConfig, nil, nil)
  	if err != nil {
  		t.Fatalf("failed to create tester chain: %v", err)
  	}
  	// Import the blocks
  	if _, err := chain.InsertChain(blocks); err != nil {
  		t.Fatalf("failed to insert into chain: %v", err)
  	}
  	// Check the storage
  	state, err := chain.StateAt(chain.CurrentHeader().Root())
  	if err != nil {
  		t.Fatalf("Failed to load state %v", err)
  	}
  	loc := common.BytesToHash([]byte{1})
  	slot := state.GetState(destAddress, loc)
  	if slot != (common.Hash{}) {
  		t.Fatalf("Unexpected dirty storage slot")
  	}
  }
  */
  