mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
cc74e74a60
This request is extending the devnet functionality to more fully handle contract processing by adding support for the following calls: * trace_call, * trace_transaction * debug_accountAt, * eth_getCode * eth_estimateGas * eth_gasPrice It also contains an initial rationalization of the devnet subscription code to use the erigon client code directly rather than using its own intermediate subscription management. This is used to implement a general purpose block waiter - which can be used in any scenario step - rather than being specific to transaction processing. This pull also contains an end to end tested sync processor for bor and associated support services: * Heimdall (supports sync event transfer) * Faucet - allows the creation and funding of arbitary test specific accounts (cross chain) Notes and Caveats: * Code generation for contracts requires `--evm-version paris`. For chains which don't support push0 for solc over 0.8.19 * The bor log processing post the application of sync events causes a panic - this will be the subject of a seperate smaller push as it is not devnet specific * The bor code seems to make repeated calls for the same sync events and also reverts requests - this needs further investigation. This is the behaviour of the current implementation and may be required - although it does seem to generate repeat processing - which could be avoided.
81 lines
1.5 KiB
Go
81 lines
1.5 KiB
Go
package accounts
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
"github.com/ledgerwatch/erigon/core"
|
|
"github.com/ledgerwatch/erigon/crypto"
|
|
)
|
|
|
|
const DevAddress = "0x67b1d87101671b127f5f8714789C7192f7ad340e"
|
|
|
|
type Account struct {
|
|
Name string
|
|
Address libcommon.Address
|
|
sigKey *ecdsa.PrivateKey
|
|
}
|
|
|
|
func init() {
|
|
core.DevnetSignKey = func(addr libcommon.Address) *ecdsa.PrivateKey {
|
|
return SigKey(addr)
|
|
}
|
|
}
|
|
|
|
var accountsByAddress = map[libcommon.Address]*Account{}
|
|
var accountsByName = map[string]*Account{}
|
|
|
|
func NewAccount(name string) *Account {
|
|
if account, ok := accountsByName[name]; ok {
|
|
return account
|
|
}
|
|
|
|
sigKey, _ := crypto.GenerateKey()
|
|
|
|
account := &Account{
|
|
Name: name,
|
|
Address: crypto.PubkeyToAddress(sigKey.PublicKey),
|
|
sigKey: sigKey,
|
|
}
|
|
|
|
accountsByAddress[account.Address] = account
|
|
accountsByName[name] = account
|
|
|
|
return account
|
|
}
|
|
|
|
func (a *Account) SigKey() *ecdsa.PrivateKey {
|
|
return a.sigKey
|
|
}
|
|
|
|
func GetAccount(account string) *Account {
|
|
if account, ok := accountsByName[account]; ok {
|
|
return account
|
|
}
|
|
|
|
if account, ok := accountsByAddress[libcommon.HexToAddress(account)]; ok {
|
|
return account
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func SigKey(source interface{}) *ecdsa.PrivateKey {
|
|
switch source := source.(type) {
|
|
case libcommon.Address:
|
|
if account, ok := accountsByAddress[source]; ok {
|
|
return account.sigKey
|
|
}
|
|
|
|
if source == core.DevnetEtherbase {
|
|
return core.DevnetSignPrivateKey
|
|
}
|
|
case string:
|
|
if account := GetAccount(source); account != nil {
|
|
return account.sigKey
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|