Skip to content

Commit

Permalink
changes to xpense
Browse files Browse the repository at this point in the history
  • Loading branch information
WlinkNET committed Dec 20, 2024
1 parent 6fe7027 commit 7b67114
Show file tree
Hide file tree
Showing 32 changed files with 111 additions and 105 deletions.
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Running Sonic in Docker is Experimental - not recommended for production use!
# Running Xpense in Docker is Experimental - not recommended for production use!

# Example of usage:
# docker build -t sonic .
# docker run --name sonic1 --entrypoint xpensetool sonic --datadir=/var/sonic genesis fake 1
# docker run --volumes-from sonic1 -p 5050:5050 -p 5050:5050/udp -p 18545:18545 sonic --fakenet 1/1 --http --http.addr=0.0.0.0
# docker build -t xpense .
# docker run --name xpense1 --entrypoint xpensetool xpense --datadir=/var/xpense genesis fake 1
# docker run --volumes-from xpense1 -p 5050:5050 -p 5050:5050/udp -p 18545:18545 xpense --fakenet 1/1 --http --http.addr=0.0.0.0

FROM golang:1.22 as builder

RUN apt-get update && apt-get install -y git musl-dev make

WORKDIR /go/Sonic
WORKDIR /go/Xpense
COPY . .

ARG GOPROXY
Expand All @@ -19,11 +19,11 @@ RUN make all

FROM golang:1.22

COPY --from=builder /go/Sonic/build/xpensed /usr/local/bin/
COPY --from=builder /go/Sonic/build/xpensetool /usr/local/bin/
COPY --from=builder /go/Xpense/build/xpensed /usr/local/bin/
COPY --from=builder /go/Xpense/build/xpensetool /usr/local/bin/

EXPOSE 18545 18546 5050 5050/udp

VOLUME /var/sonic
VOLUME /var/xpense

ENTRYPOINT ["xpensed", "--datadir=/var/sonic"]
ENTRYPOINT ["xpensed", "--datadir=/var/xpense"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Sonic
# Xpense

EVM-compatible chain secured by the Lachesis consensus algorithm.

## Building the source

Building Sonic requires both a Go (version 1.21 or later) and a C compiler. You can install
Building Xpense requires both a Go (version 1.21 or later) and a C compiler. You can install
them using your favourite package manager. Once the dependencies are installed, run:

```shell
make all
```
The build output are ```build/xpensed``` and ```build/xpensetool``` executables.

## Initialization of the Sonic Database
## Initialization of the Xpense Database

You will need a genesis file to join a network. Please check the following
site for details how to get one: https://github.com/Fantom-foundation/lachesis_launch
Expand Down
2 changes: 1 addition & 1 deletion cmd/xpensed/app/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func initApp() {

app = cli.NewApp()
app.Name = "xpensed"
app.Usage = "the Sonic network client"
app.Usage = "the Xpense network client"
app.Version = version.VersionWithCommit(config.GitCommit, config.GitDate)
app.Action = lachesisMain
app.HideVersion = true // we have a command to print the version
Expand Down
2 changes: 1 addition & 1 deletion cmd/xpensed/cmdhelper/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SUBCOMMANDS:
AppHelpTemplate = `NAME:
{{.App.Name}} - {{.App.Usage}}
Copyright 2024 The Sonic Authors
Copyright 2024 The Xpense Authors
USAGE:
{{.App.HelpName}} [options]{{if .App.Commands}} command [command options]{{end}} {{if .App.ArgsUsage}}{{.App.ArgsUsage}}{{else}}[arguments...]{{end}}
Expand Down
5 changes: 3 additions & 2 deletions cmd/xpensetool/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package app

import (
"fmt"
"strings"

"github.com/WlinkNET/xpense_chain/config/flags"
"github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
"strings"
)

var (
Expand Down Expand Up @@ -34,7 +35,7 @@ func remoteConsole(ctx *cli.Context) error {
if !ctx.GlobalIsSet(flags.DataDirFlag.Name) {
return fmt.Errorf("the --%s flag is missing and the IPC endpoint path is not specified", flags.DataDirFlag.Name)
}
endpoint = fmt.Sprintf("%s/sonic.ipc", ctx.GlobalString(flags.DataDirFlag.Name))
endpoint = fmt.Sprintf("%s/xpense.ipc", ctx.GlobalString(flags.DataDirFlag.Name))
}
client, err := rpc.Dial(endpoint)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cmd/xpensetool/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func Run() error {
app := cli.NewApp()
app.Name = "xpensetool"
app.Usage = "the Sonic management tool"
app.Usage = "the Xpense management tool"
app.Version = version.VersionWithCommit(config.GitCommit, config.GitDate)
app.Flags = []cli.Flag{
flags.DataDirFlag,
Expand Down Expand Up @@ -152,10 +152,10 @@ The archive state is used for RPC - allows to handle state-related RPC queries.
ExecFlag,
},
Description: `
The Sonic console is an interactive shell for the JavaScript runtime environment
The Xpense console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Dapp JavaScript API.
See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console.
This command allows to open a console attached to a running Sonic node.`,
This command allows to open a console attached to a running Xpense node.`,
},

{
Expand Down Expand Up @@ -327,7 +327,7 @@ For non-interactive use the passphrase can be specified with the --password flag
xpensetool account import --password=file <keyfile>
Note:
As you can directly copy your encrypted accounts to another Sonic instance,
As you can directly copy your encrypted accounts to another Xpense instance,
this import mechanism is not needed when you transfer an account between
nodes.
`,
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

const (
// ClientIdentifier to advertise over the network.
ClientIdentifier = "Sonic"
ClientIdentifier = "Xpense"
)

var (
Expand Down Expand Up @@ -354,6 +354,6 @@ func DefaultNodeConfig() node.Config {
cfg.Version = version.VersionWithCommit(GitCommit, GitDate)
cfg.HTTPModules = append(cfg.HTTPModules, "eth", "ftm", "dag", "abft", "web3")
cfg.WSModules = append(cfg.WSModules, "eth", "ftm", "dag", "abft", "web3")
cfg.IPCPath = "sonic.ipc"
cfg.IPCPath = "Xpense.ipc"
return cfg
}
3 changes: 2 additions & 1 deletion config/params.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package config

// TODO need changes
var (
Bootnodes = map[string][]string{
"sonic": {
"xpense": {
"enode://5facb14cfb4c5cb63f916f46e9689619f65040aa8efb7e9e9adb506db9fc006f042828ad7896467cf5eb1f3b74e53ad4fcd6bc4f15ae3acc3e8b7628e5446dad@boot-a.sonic.soniclabs.com:5050",
"enode://04d51b2e172ed3722267bf26a39b55645ea220df7d35be7581a96409567cab5807eadd4c0b94f2c0c7128adece5ae64dd808dd9aa4543aa05c789bca02099731@boot-b.sonic.soniclabs.com:5050",
"enode://ae3a88445aafb8cfff48bbcb1e7399c49d5d00d7c859f6dc0d3f8f2386019481f49cf1c32f2bce5a234de1311ebd8162858a4aa4c9dcc7f99b9b0c770044e7d5@boot-c.sonic.soniclabs.com:5050",
Expand Down
2 changes: 1 addition & 1 deletion demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sonic*.datadir
xpense*.datadir
tool.datadir
*.log
2 changes: 1 addition & 1 deletion demo/clean.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
cd $(dirname $0)

rm -rf sonic*.datadir tool.datadir
rm -rf xpense*.datadir tool.datadir
rm *.log
rm ../build/demo_xpensed
2 changes: 1 addition & 1 deletion demo/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ popd
rm -f ./transactions.rlp
for ((i=0;i<$N;i+=1))
do
DATADIR="${PWD}/sonic$i.datadir"
DATADIR="${PWD}/xpense$i.datadir"
PORT=$(($PORT_BASE+$i))
RPCP=$(($RPCP_BASE+$i))
WSP=$(($WSP_BASE+$i))
Expand Down
6 changes: 3 additions & 3 deletions ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import (
"github.com/WlinkNET/xpense_chain/gossip/gasprice/gaspricelimits"
bip39 "github.com/tyler-smith/go-bip39"

"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/WlinkNET/xpense_chain/evmcore"
"github.com/WlinkNET/xpense_chain/gossip/gasprice"
"github.com/WlinkNET/xpense_chain/inter/state"
"github.com/WlinkNET/xpense_chain/opera"
"github.com/WlinkNET/xpense_chain/utils"
"github.com/WlinkNET/xpense_chain/utils/signers/gsignercache"
"github.com/WlinkNET/xpense_chain/utils/signers/internaltx"
"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/abi"
Expand Down Expand Up @@ -84,7 +84,7 @@ func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI {
// GasPrice returns a suggestion for a gas price for legacy transactions.
func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) {
// Right now, we are not suggesting any tips since those have no real
// effect on the Sonic network. So the suggested gas price is a slightly
// effect on the Xpense network. So the suggested gas price is a slightly
// increased base fee to provide a buffer for short-term price fluctuations.
price := s.b.CurrentBlock().Header().BaseFee
price = gaspricelimits.GetSuggestedGasPriceForNewTransactions(price)
Expand Down Expand Up @@ -1308,7 +1308,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
copyAccessList(tx, result)
copyDynamicPricingFields(tx, result)
case types.BlobTxType:
// BLOB NOTE: the current sonic network supports blobTx so long as they don not contain blobs
// BLOB NOTE: the current Xpense network supports blobTx so long as they don not contain blobs
// for this reason they are equivalent to the dynamic fee tx type
copyAccessList(tx, result)
copyDynamicPricingFields(tx, result)
Expand Down
4 changes: 2 additions & 2 deletions eventcheck/epochcheck/epoch_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func CheckTxs(txs types.Transactions, rules opera.Rules) error {
if rules.Upgrades.London {
maxType = 2
}
if rules.Upgrades.Sonic {
if rules.Upgrades.Xpense {
maxType = 3
}
for _, tx := range txs {
Expand Down Expand Up @@ -124,7 +124,7 @@ func (v *Checker) Validate(e inter.EventPayloadI) error {
}

version := uint8(0)
if rules.Upgrades.Sonic {
if rules.Upgrades.Xpense {
version = 2
} else if rules.Upgrades.Llr {
version = 1
Expand Down
8 changes: 4 additions & 4 deletions evmcore/dummy_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/trie"

"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/WlinkNET/xpense_chain/inter"
"github.com/WlinkNET/xpense_chain/opera"
"github.com/Fantom-foundation/lachesis-base/inter/idx"
)

type (
Expand Down Expand Up @@ -83,17 +83,17 @@ func ToEvmHeader(block *inter.Block, prevHash common.Hash, rules opera.Rules) *E
baseFee := rules.Economy.MinGasPrice
if !rules.Upgrades.London {
baseFee = nil
} else if rules.Upgrades.Sonic {
} else if rules.Upgrades.Xpense {
baseFee = block.BaseFee
}

prevRandao := common.Hash{}
if rules.Upgrades.Sonic {
if rules.Upgrades.Xpense {
prevRandao = block.PrevRandao
}

var withdrawalsHash *common.Hash = nil
if rules.Upgrades.Sonic {
if rules.Upgrades.Xpense {
withdrawalsHash = &types.EmptyWithdrawalsHash
}

Expand Down
2 changes: 1 addition & 1 deletion evmcore/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func applyTransaction(
// Skip checking of base fee limits for internal transactions.
evm.Config.NoBaseFee = msg.SkipAccountChecks

// For now, Sonic only supports Blob transactions without blob data.
// For now, Xpense only supports Blob transactions without blob data.
if msg.BlobHashes != nil {
if len(msg.BlobHashes) > 0 {
return nil, 0, true, fmt.Errorf("blob data is not supported")
Expand Down
2 changes: 1 addition & 1 deletion evmcore/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if !pool.eip4844 {
return ErrTxTypeNotSupported
}
// For now, Sonic only supports Blob transactions without blob data.
// For now, Xpense only supports Blob transactions without blob data.
if len(tx.BlobHashes()) > 0 ||
(tx.BlobTxSidecar() != nil && len(tx.BlobTxSidecar().BlobHashes()) > 0) {
return ErrTxTypeNotSupported
Expand Down
2 changes: 1 addition & 1 deletion example-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Berlin": true,
"London": true,
"Llr": false,
"Sonic": true
"Xpense": true
}
},
"blockZeroTime": "2024-11-01T00:00:00+01:00",
Expand Down
2 changes: 1 addition & 1 deletion genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Berlin": true,
"London": true,
"Llr": false,
"Sonic": true
"Xpense": true
}
},
"blockZeroTime": "2024-12-20T00:00:00+01:00",
Expand Down
6 changes: 3 additions & 3 deletions gossip/blockproc/evmmodule/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ func (p *OperaEVMProcessor) evmBlockWith(txs types.Transactions) *evmcore.EvmBlo
baseFee := p.net.Economy.MinGasPrice
if !p.net.Upgrades.London {
baseFee = nil
} else if p.net.Upgrades.Sonic {
} else if p.net.Upgrades.Xpense {
baseFee = p.gasBaseFee
}

prevRandao := common.Hash{}
// This condition must be kept, otherwise Opera will not be able to synchronize
if p.net.Upgrades.Sonic {
if p.net.Upgrades.Xpense {
prevRandao = p.prevRandao
}

var withdrawalsHash *common.Hash = nil
if p.net.Upgrades.Sonic {
if p.net.Upgrades.Xpense {
withdrawalsHash = &types.EmptyWithdrawalsHash
}

Expand Down
2 changes: 1 addition & 1 deletion gossip/c_block_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func consensusCallbackBeginBlockFn(
}

signer := gsignercache.Wrap(types.MakeSigner(chainCfg, new(big.Int).SetUint64(number), uint64(blockCtx.Time)))
orderedTxs := getExecutionOrder(unorderedTxs, signer, es.Rules.Upgrades.Sonic)
orderedTxs := getExecutionOrder(unorderedTxs, signer, es.Rules.Upgrades.Xpense)

for i, receipt := range evmProcessor.Execute(orderedTxs) {
if receipt != nil { // < nil if skipped
Expand Down
2 changes: 1 addition & 1 deletion gossip/c_llr_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/WlinkNET/xpense_chain/opera"
)

// defaultBlobGasPrice Sonic does not support blobs, so this price is constant
// defaultBlobGasPrice Xpense does not support blobs, so this price is constant
var defaultBlobGasPrice = big.NewInt(1) // TODO issue #147

func indexRawReceipts(s *Store, receiptsForStorage []*types.ReceiptForStorage, txs types.Transactions, blockIdx idx.Block, blockHash common.Hash, config *params.ChainConfig, time uint64, baseFee *big.Int, blobGasPrice *big.Int) (types.Receipts, error) {
Expand Down
6 changes: 3 additions & 3 deletions gossip/emitter/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"sync/atomic"
"time"

"github.com/WlinkNET/xpense_chain/utils"
"github.com/WlinkNET/xpense_chain/utils/txtime"
"github.com/Fantom-foundation/lachesis-base/emitter/ancestor"
"github.com/Fantom-foundation/lachesis-base/hash"
"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/Fantom-foundation/lachesis-base/inter/pos"
"github.com/Fantom-foundation/lachesis-base/utils/piecefunc"
"github.com/WlinkNET/xpense_chain/utils"
"github.com/WlinkNET/xpense_chain/utils/txtime"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/metrics"
Expand Down Expand Up @@ -399,7 +399,7 @@ func (em *Emitter) createEvent(sortedTxs *transactionsByPriceAndNonce) (*inter.E
}

version := uint8(0)
if em.world.GetRules().Upgrades.Sonic {
if em.world.GetRules().Upgrades.Xpense {
version = 2
} else if em.world.GetRules().Upgrades.Llr {
version = 1
Expand Down
4 changes: 2 additions & 2 deletions gossip/evm_state_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ func (r *EvmStateReader) getBlock(h common.Hash, n idx.Block, readTxs bool) *evm
}

// There is no epoch state for epoch 0 comprising block 0.
// For this epoch, London and Sonic upgrades are enabled.
// For this epoch, London and Xpense upgrades are enabled.
// TODO: instead of hard-coding these values here, a corresponding
// epoch state should be included in the genesis procedure to be
// consistent. See issue #72.
if epoch == 0 {
rules.Upgrades.London = true
rules.Upgrades.Sonic = true
rules.Upgrades.Xpense = true
}

var prev common.Hash
Expand Down
Loading

0 comments on commit 7b67114

Please sign in to comment.