Merge pull request #88 from openrelayxyz/laconic-merge

Laconic merge
This commit is contained in:
AusIV 2023-09-11 13:28:10 -05:00 committed by GitHub
commit 67819b62c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 73 additions and 11 deletions

View File

@ -6,7 +6,7 @@ ARG BUILDNUM=""
# Build Geth in a stock Go builder container
FROM golang:1.20-alpine as builder
RUN apk add --no-cache gcc musl-dev linux-headers git
RUN apk add --no-cache gcc musl-dev binutils-gold linux-headers git
# Get dependencies - will also be cached if we won't change go.mod/go.sum
COPY go.mod /go-ethereum/

View File

@ -25,6 +25,10 @@ rather than forking the Geth project. Out of the box, PluGeth behaves exactly
like upstream Geth, but by installing plugins written in Golang, developers can
extend its functionality in a wide variety of way.
### Submitting Pull Requests
We are eager to include contributions from the community into the project. We ask that pull requests which include new features to be covered by our test plugin found in: `/plugins/test-plugin`. The test design and instructions for use are documented there. If further assistance is needed please get in touch with us.
### Contact Us
If you're trying to do something that isn't supported by the current plugin system, Reach out to us on [Discord](https://discord.gg/Epf7b7Gr) and we'll help you figure out how to make it work.

View File

@ -20,7 +20,7 @@ package main
import (
"fmt"
"os"
"path"
"path/filepath"
"sort"
"strconv"
"strings"
@ -57,6 +57,9 @@ const (
var (
// flags that configure the node
nodeFlags = flags.Merge([]cli.Flag{
//begin PluGeth code injection
utils.PluginsDirFlag,
//end PluGeth code injection
utils.IdentityFlag,
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
@ -322,7 +325,14 @@ func prepare(ctx *cli.Context) {
// blocking mode, waiting for it to be shut down.
func geth(ctx *cli.Context) error {
//begin PluGeth code injection
if err := plugins.Initialize(path.Join(ctx.String(utils.DataDirFlag.Name), "plugins"), ctx); err != nil {
var pluginsDir string
if ctx.IsSet(utils.PluginsDirFlag.Name) {
pluginsDir = ctx.String(utils.PluginsDirFlag.Name)
} else {
pluginsDir = filepath.Join(ctx.String(utils.DataDirFlag.Name), "plugins")
}
if err := plugins.Initialize(pluginsDir, ctx); err != nil {
return err
}
prepare(ctx)

View File

@ -88,6 +88,14 @@ import (
var (
// General settings
//begin PluGeth code injection
PluginsDirFlag = &flags.DirectoryFlag{
Name: "pluginsdir",
Usage: "Directory for plugins",
Value: flags.DirectoryString(filepath.Join("<datadir>", "plugins")),
Category: flags.EthCategory,
}
//end PluGeth code injection
DataDirFlag = &flags.DirectoryFlag{
Name: "datadir",
Usage: "Data directory for the databases and keystore",

View File

@ -8,7 +8,7 @@ import (
"plugin"
"reflect"
"strings"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/openrelayxyz/plugeth-utils/core"
@ -58,6 +58,7 @@ func Lookup(name string, validate func(interface{}) bool) []interface{} {
var DefaultPluginLoader *PluginLoader
func NewPluginLoader(target string) (*PluginLoader, error) {
log.Info("Loading plugins from directory", "path", target)
pl := &PluginLoader{
Plugins: []pluginDetails{},
Subcommands: make(map[string]Subcommand),

View File

@ -5,9 +5,11 @@ import (
"math/big"
"time"
"os"
"bytes"
"github.com/openrelayxyz/plugeth-utils/core"
"github.com/openrelayxyz/plugeth-utils/restricted/hexutil"
"github.com/openrelayxyz/plugeth-utils/restricted/crypto"
)
var hookChan chan map[string]struct{} = make(chan map[string]struct{}, 10)
@ -223,6 +225,8 @@ func txTracer() {
log.Error("debug_traceTransaction failed", "err", err)
}
testGetContractCode(t3)
debugArg0 := map[string]interface{}{
"input": "0x60006000fd",
"from": coinBase,
@ -242,7 +246,6 @@ func txTracer() {
var trResult1 interface{}
err = client.Call(&trResult1, "debug_traceCall", debugArg1, "latest", t)
final := map[string]interface{}{
"input": "0x61520873000000000000000000000000000000000000000060006000600060006000f1",
"from": coinBase,
@ -258,3 +261,39 @@ func txTracer() {
}
func testGetContractCode(hash core.Hash) {
cl := apis[0].Service.(*engineService).stack
client, err := cl.Attach()
if err != nil {
log.Error("Error connecting with client testGetContractCode")
}
receipt := map[string]interface{}{}
err = client.Call(&receipt, "eth_getTransactionReceipt", hash)
if err != nil {
log.Error("Error calling getTransactionReciepts, testGetContractCode", "err", err)
}
var controlCode hexutil.Bytes
err = client.Call(&controlCode, "eth_getCode", receipt["contractAddress"], receipt["blockNumber"])
if err != nil {
log.Error("Error calling getCode, testGetContractCode", "err", err)
}
codeHash := crypto.Keccak256Hash(controlCode)
testCode, err := apis[0].Service.(*engineService).backend.GetContractCode(codeHash)
if err != nil {
log.Error("Error calling GetContractCode", "err", err)
}
if !bytes.Equal(testCode, controlCode) {
log.Error("Exit with error, return value from GetContractCode is divergent from control value")
os.Exit(1)
}
log.Info("made it through checkGetContractCode")
}

View File

@ -11,8 +11,9 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
gcore "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
gparams "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/internal/ethapi"
@ -510,7 +511,6 @@ func (b *Backend) GetAccountTrie(stateRoot core.Hash, account core.Address) (cor
return NewWrappedTrie(acTr), nil
}
func (b *Backend) GetContractCode(h core.Hash) ([]byte, error) {
return state.NewDatabase(b.b.ChainDb()).ContractCode(common.Hash{}, common.Hash(h))
}