Skip to content

Commit

Permalink
Merge branch 'feat/openrpc-discover-20201024'
Browse files Browse the repository at this point in the history
  • Loading branch information
meowsbits committed Dec 29, 2020
2 parents a01988f + 6f8daa6 commit 73e58be
Show file tree
Hide file tree
Showing 23 changed files with 1,322 additions and 2,121 deletions.
7 changes: 6 additions & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,13 @@ func doInstall(cmdline []string) {
// Put the default settings in.
gobuild.Args = append(gobuild.Args, buildFlags(env)...)

/*
TODO(meowsbits): The -trimpath flag is commented because it breaks openrpc discovery, for which
reflection/AST-parsing gets broken when paths are not full.
Is there a better solve for this? Can we just turn reflection off for the geth build?
*/
// We use -trimpath to avoid leaking local paths into the built executables.
gobuild.Args = append(gobuild.Args, "-trimpath")
// gobuild.Args = append(gobuild.Args, "-trimpath")

// Show packages during build.
gobuild.Args = append(gobuild.Args, "-v")
Expand Down
3 changes: 2 additions & 1 deletion cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params/vars"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/signer/core"
Expand Down Expand Up @@ -89,7 +90,7 @@ var (
}
keystoreFlag = cli.StringFlag{
Name: "keystore",
Value: filepath.Join(node.DefaultDataDir(), "keystore"),
Value: filepath.Join(vars.DefaultDataDir(), "keystore"),
Usage: "Directory for the keystore",
}
configdirFlag = cli.StringFlag{
Expand Down
3 changes: 2 additions & 1 deletion cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params/vars"
"github.com/ethereum/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
)
Expand Down Expand Up @@ -118,7 +119,7 @@ func remoteConsole(ctx *cli.Context) error {
// Attach to a remotely running geth instance and start the JavaScript console
endpoint := ctx.Args().First()
if endpoint == "" {
path := node.DefaultDataDir()
path := vars.DefaultDataDir()
if ctx.GlobalIsSet(utils.DataDirFlag.Name) {
path = ctx.GlobalString(utils.DataDirFlag.Name)
}
Expand Down
6 changes: 0 additions & 6 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ import (
"github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/internal/openrpc"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
gopsutil "github.com/shirou/gopsutil/mem"
cli "gopkg.in/urfave/cli.v1"
)
Expand Down Expand Up @@ -281,10 +279,6 @@ func init() {
prompt.Stdin.Close() // Resets terminal mode.
return nil
}

if err := rpc.SetDefaultOpenRPCSchemaRaw(openrpc.OpenRPCSchema); err != nil {
log.Crit("Setting OpenRPC default", "error", err)
}
}

func main() {
Expand Down
13 changes: 7 additions & 6 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/genesisT"
"github.com/ethereum/go-ethereum/params/vars"
pcsclite "github.com/gballet/go-libpcsclite"
cli "gopkg.in/urfave/cli.v1"
)
Expand Down Expand Up @@ -111,7 +112,7 @@ var (
DataDirFlag = DirectoryFlag{
Name: "datadir",
Usage: "Data directory for the databases and keystore",
Value: DirectoryString(node.DefaultDataDir()),
Value: DirectoryString(vars.DefaultDataDir()),
}
AncientFlag = DirectoryFlag{
Name: "datadir.ancient",
Expand Down Expand Up @@ -1351,24 +1352,24 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
case ctx.GlobalBool(DeveloperFlag.Name) || ctx.GlobalBool(DeveloperPoWFlag.Name):
cfg.DataDir = "" // unless explicitly requested, use memory databases

case (ctx.GlobalBool(LegacyTestnetFlag.Name) || ctx.GlobalBool(RopstenFlag.Name)) && cfg.DataDir == node.DefaultDataDir():
case (ctx.GlobalBool(LegacyTestnetFlag.Name) || ctx.GlobalBool(RopstenFlag.Name)) && cfg.DataDir == vars.DefaultDataDir():

// Maintain compatibility with older Geth configurations storing the
// Ropsten database in `testnet` instead of `ropsten`.
legacyPath := filepath.Join(node.DefaultDataDir(), "testnet")
legacyPath := filepath.Join(vars.DefaultDataDir(), "testnet")

if _, err := os.Stat(legacyPath); !os.IsNotExist(err) {

log.Warn("Using the deprecated `testnet` datadir. Future versions will store the Ropsten chain in `ropsten`.")
cfg.DataDir = legacyPath
} else {

cfg.DataDir = filepath.Join(node.DefaultDataDir(), "ropsten")
cfg.DataDir = filepath.Join(vars.DefaultDataDir(), "ropsten")

}

case cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = dataDirPathForCtxChainConfig(ctx, node.DefaultDataDir())
case cfg.DataDir == vars.DefaultDataDir():
cfg.DataDir = dataDirPathForCtxChainConfig(ctx, vars.DefaultDataDir())
}
}

Expand Down
8 changes: 4 additions & 4 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ func (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hex

// BadBlockArgs represents the entries in the list returned when bad blocks are queried.
type BadBlockArgs struct {
Hash common.Hash `json:"hash"`
Block map[string]interface{} `json:"block"`
RLP string `json:"rlp"`
Hash common.Hash `json:"hash"`
Block *ethapi.RPCMarshalBlockT `json:"block"`
RLP string `json:"rlp"`
}

// GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
Expand All @@ -369,7 +369,7 @@ func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs,
results[i].RLP = fmt.Sprintf("0x%x", rlpBytes)
}
if results[i].Block, err = ethapi.RPCMarshalBlock(block, true, true); err != nil {
results[i].Block = map[string]interface{}{"error": err.Error()}
results[i].Block = &ethapi.RPCMarshalBlockT{Error: err.Error()}
}
}
return results, nil
Expand Down
6 changes: 3 additions & 3 deletions eth/filters/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params/vars"
)

func BenchmarkBloomBits512(b *testing.B) {
Expand Down Expand Up @@ -62,7 +62,7 @@ func BenchmarkBloomBits32k(b *testing.B) {
const benchFilterCnt = 2000

func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
benchDataDir := vars.DefaultDataDir() + "/geth/chaindata"
b.Log("Running bloombits benchmark section size:", sectionSize)

db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "")
Expand Down Expand Up @@ -155,7 +155,7 @@ func clearBloomBits(db ethdb.Database) {
}

func BenchmarkNoBloomBits(b *testing.B) {
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
benchDataDir := vars.DefaultDataDir() + "/geth/chaindata"
b.Log("Running benchmark without bloombits")
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "")
if err != nil {
Expand Down
Loading

0 comments on commit 73e58be

Please sign in to comment.