erigon-pulse/cmd/devnet/contracts/backend.go
Mark Holt 529d359ca6
Bor span testing (#7897)
An update to the devnet to introduce a local heimdall to facilitate
multiple validators without the need for an external process, and hence
validator registration/staking etc.

In this initial release only span generation is supported.  

It has the following changes:

* Introduction of a local grpc heimdall interface
* Allocation of accounts via a devnet account generator ()
* Introduction on 'Services' for the network config

"--chain bor-devnet --bor.localheimdall" will run a 2 validator network
with a local service
"--chain bor-devnet --bor.withoutheimdall" will sun a single validator
with no heimdall service as before

---------

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2023-07-18 09:47:04 +01:00

59 lines
1.8 KiB
Go

package contracts
import (
"context"
"fmt"
"math/big"
ethereum "github.com/ledgerwatch/erigon"
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/accounts/abi/bind"
"github.com/ledgerwatch/erigon/cmd/devnet/devnet"
"github.com/ledgerwatch/erigon/core/types"
)
func NewBackend(node devnet.Node) bind.ContractBackend {
return contractBackend{node}
}
type contractBackend struct {
node devnet.Node
}
func (cb contractBackend) CodeAt(ctx context.Context, contract libcommon.Address, blockNumber *big.Int) ([]byte, error) {
return nil, fmt.Errorf("TODO")
}
func (cb contractBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
return nil, fmt.Errorf("TODO")
}
func (cb contractBackend) PendingCodeAt(ctx context.Context, account libcommon.Address) ([]byte, error) {
return nil, fmt.Errorf("TODO")
}
func (cb contractBackend) PendingNonceAt(ctx context.Context, account libcommon.Address) (uint64, error) {
return 0, fmt.Errorf("TODO")
}
func (cb contractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
return nil, fmt.Errorf("TODO")
}
func (cb contractBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) {
return 0, fmt.Errorf("TODO")
}
func (cb contractBackend) SendTransaction(ctx context.Context, tx types.Transaction) error {
_, err := cb.node.SendTransaction(tx)
return err
}
func (cb contractBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) {
return cb.node.FilterLogs(ctx, query)
}
func (cb contractBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
return cb.node.SubscribeFilterLogs(ctx, query, ch)
}