Skip to content

Commit

Permalink
Rename gfork to gingerbread (#2127)
Browse files Browse the repository at this point in the history
* Rename gfork to gingerbread

* Add `override.gingerbread` flag

This one existed for espresso as well and was just
adapted to gingerbread.

* Update monorepo commit

* Use Python 3.9

Use updated version of the monorepo, which includes an update
to `node-gyp` which in turn allows us to use python 3.9
  • Loading branch information
palango committed Jun 20, 2023
1 parent 85c1757 commit 64ac925
Show file tree
Hide file tree
Showing 34 changed files with 130 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: [self-hosted, blockchain, 8-cpu]
env:
NODE_VERSION: 12
PYTHON_VERSION: '2.7'
PYTHON_VERSION: '3.9'
CONTRACTS_BUILD_PATH: packages/protocol/build/contracts

steps:
Expand Down
4 changes: 2 additions & 2 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
// makeFullNode loads geth configuration and creates the Ethereum backend.
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
stack, cfg := makeConfigNode(ctx)
if ctx.GlobalIsSet(utils.OverrideEHardforkFlag.Name) {
cfg.Eth.OverrideEHardfork = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideEHardforkFlag.Name))
if ctx.GlobalIsSet(utils.OverrideGingerbreadFlag.Name) {
cfg.Eth.OverrideGingerbread = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideGingerbreadFlag.Name))
}
backend, _ := utils.RegisterEthService(stack, &cfg.Eth)

Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var (
utils.NoUSBFlag,
utils.USBFlag,
// utils.SmartCardDaemonPathFlag,
utils.OverrideEHardforkFlag,
utils.OverrideGingerbreadFlag,
utils.TxPoolLocalsFlag,
utils.TxPoolNoLocalsFlag,
utils.TxPoolJournalFlag,
Expand Down
14 changes: 7 additions & 7 deletions cmd/mycelo/genesis_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ var templateFlags = []cli.Flag{
Usage: "Optional flag to allow espresso fork overwritting (default: 0, disable: -1)",
},
cli.Int64Flag{
Name: "forks.gfork",
Usage: "Optional flag to allow gfork fork overwritting (default: 0, disable: -1)",
Name: "forks.gingerbread",
Usage: "Optional flag to allow gingerbread fork overwritting (default: 0, disable: -1)",
},
}

Expand Down Expand Up @@ -171,12 +171,12 @@ func envFromTemplate(ctx *cli.Context, workdir string) (*env.Environment, *genes
}
}

if ctx.IsSet("forks.gFork") {
gForkBlockNumber := ctx.Int64("forks.gFork")
if gForkBlockNumber < 0 {
genesisConfig.Hardforks.GForkBlock = nil
if ctx.IsSet("forks.gingerbread") {
gingerbreadBlockNumber := ctx.Int64("forks.gingerbread")
if gingerbreadBlockNumber < 0 {
genesisConfig.Hardforks.GingerbreadBlock = nil
} else {
genesisConfig.Hardforks.GForkBlock = big.NewInt(gForkBlockNumber)
genesisConfig.Hardforks.GingerbreadBlock = big.NewInt(gingerbreadBlockNumber)
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ var (
}

// Hard fork activation overrides
OverrideEHardforkFlag = cli.Uint64Flag{
Name: "override.espresso",
Usage: "Manually specify the espresso fork block, overriding the bundled setting",
OverrideGingerbreadFlag = cli.Uint64Flag{
Name: "override.gingerbread",
Usage: "Manually specify the gingerbread fork block, overriding the bundled setting",
}

BloomFilterSizeFlag = cli.Uint64Flag{
Expand Down
2 changes: 1 addition & 1 deletion consensus/istanbul/backend/pos.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (sb *Backend) distributeEpochRewards(header *types.Header, state *state.Sta
return err
}

if sb.ChainConfig().IsGFork(header.Number) {
if sb.ChainConfig().IsGingerbread(header.Number) {
if err := sb.distributeCommunityRewards(vmRunner, communityReward); err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
return SetupGenesisBlockWithOverride(db, genesis, nil)
}

func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, overrideEHardfork *big.Int) (*params.ChainConfig, common.Hash, error) {
func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, overrideGingerbread *big.Int) (*params.ChainConfig, common.Hash, error) {
if genesis != nil && (genesis.Config == nil || genesis.Config.Istanbul == nil) {
return params.MainnetChainConfig, common.Hash{}, errGenesisNoConfig
}
Expand Down Expand Up @@ -202,8 +202,8 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override

// Get the existing chain configuration.
newcfg := genesis.configOrDefault(stored)
if overrideEHardfork != nil {
newcfg.EspressoBlock = overrideEHardfork
if overrideGingerbread != nil {
newcfg.GingerbreadBlock = overrideGingerbread
}

if err := newcfg.CheckConfigForkOrder(); err != nil {
Expand Down Expand Up @@ -278,7 +278,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
Coinbase: g.Coinbase,
Root: root,
}
if g.Config != nil && g.Config.IsGFork(common.Big0) {
if g.Config != nil && g.Config.IsGingerbread(common.Big0) {
head.Nonce = types.EncodeNonce(0)
head.GasLimit = params.GenesisGasLimit
head.Difficulty = common.Big0
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, gp *GasPool

// CIP 57 deprecates full node incentives
// Check that neither `GatewayFeeRecipient` nor `GatewayFee` are set, otherwise reject the transaction
if config.IsGFork(blockNumber) {
if config.IsGingerbread(blockNumber) {
gatewayFeeSet := !(msg.GatewayFee() == nil || msg.GatewayFee().Cmp(common.Big0) == 0)
if msg.GatewayFeeRecipient() != nil || gatewayFeeSet {
return nil, ErrGatewayFeeDeprecated
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestStateProcessorErrors(t *testing.T) {
ChurritoBlock: big.NewInt(0),
DonutBlock: big.NewInt(0),
EspressoBlock: big.NewInt(0),
GForkBlock: big.NewInt(0),
GingerbreadBlock: big.NewInt(0),
Faker: true,
FakeBaseFee: common.Big3,
}
Expand Down
14 changes: 7 additions & 7 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ type TxPool struct {
signer types.Signer
mu sync.RWMutex

homestead bool // Fork indicator for the homstead fork
istanbul bool // Fork indicator whether we are in the istanbul stage.
donut bool // Fork indicator for the Donut fork.
espresso bool // Fork indicator for the Espresso fork.
gfork bool // Fork indicator for the G fork.
homestead bool // Fork indicator for the homstead fork
istanbul bool // Fork indicator whether we are in the istanbul stage.
donut bool // Fork indicator for the Donut fork.
espresso bool // Fork indicator for the Espresso fork.
gingerbread bool // Fork indicator for the G fork.

currentState *state.StateDB // Current state in the blockchain head
currentVMRunner vm.EVMRunner // Current EVMRunner
Expand Down Expand Up @@ -662,7 +662,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {

// CIP 57 deprecates full node incentives
gatewayFeeSet := !(tx.GatewayFee() == nil || tx.GatewayFee().Cmp(common.Big0) == 0)
if pool.gfork && (tx.GatewayFeeRecipient() != nil || gatewayFeeSet) {
if pool.gingerbread && (tx.GatewayFeeRecipient() != nil || gatewayFeeSet) {
return ErrGatewayFeeDeprecated
}

Expand Down Expand Up @@ -1419,7 +1419,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.istanbul = pool.chainconfig.IsIstanbul(next)
pool.donut = pool.chainconfig.IsDonut(next)
pool.espresso = pool.chainconfig.IsEspresso(next)
pool.gfork = pool.chainconfig.IsGFork(next)
pool.gingerbread = pool.chainconfig.IsGingerbread(next)
}

// promoteExecutables moves transactions that have become processable from the
Expand Down
8 changes: 4 additions & 4 deletions core/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TestInvalidTransactionsPreGFork(t *testing.T) {

pool, key := setupTxPool()
defer pool.Stop()
pool.gfork = false
pool.gingerbread = false

tx := transaction(0, 100, key)
from, _ := deriveSender(tx)
Expand Down Expand Up @@ -944,7 +944,7 @@ func TestTransactionGapFilling(t *testing.T) {
// (a) to set pool.donut = false at its start (so we can add unprotected transactions)
// (b) different functions to generate protected vs unprotected transactions, since we will
// need to update transaction() and the others to use replay protection
func TestPoolReAcceptingUnprotectedTxsFromEFork(t *testing.T) {
func TestPoolReAcceptingUnprotectedTxsFromEspresso(t *testing.T) {
t.Parallel()

pool, key := setupTxPool()
Expand Down Expand Up @@ -993,8 +993,8 @@ func TestPoolReAcceptingUnprotectedTxsFromEFork(t *testing.T) {
t.Fatalf("after donut, queued transactions mismatched: have %d, want %d", queued, 3)
}

// In E fork
// flag it as E hard fork
// In Espresso
// flag it as Espresso fork
pool.espresso = true
pool.AddRemotesSync([]*types.Transaction{
transaction(3, 100000, key),
Expand Down
6 changes: 3 additions & 3 deletions core/vm/celo_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *transfer) Run(input []byte, ctx *celoPrecompileContext) ([]byte, error)
// to: 32 bytes representing the address of the recipient
// value: 32 bytes, a 256 bit integer representing the amount of Celo Gold to transfer
// 3 arguments x 32 bytes each = 96 bytes total input
if (ctx.IsGFork && len(input) != 96) || len(input) < 96 {
if (ctx.IsGingerbread && len(input) != 96) || len(input) < 96 {
return nil, ErrInputLength
}

Expand Down Expand Up @@ -163,7 +163,7 @@ func (c *fractionMulExp) Run(input []byte, ctx *celoPrecompileContext) ([]byte,
// decimals: 32 bytes, 256 bit integer, places of precision
//
// 6 args x 32 bytes each = 192 bytes total input length
if (ctx.IsGFork && len(input) != 192) || len(input) < 192 {
if (ctx.IsGingerbread && len(input) != 192) || len(input) < 192 {
return nil, ErrInputLength
}

Expand Down Expand Up @@ -310,7 +310,7 @@ func (c *getValidator) Run(input []byte, ctx *celoPrecompileContext) ([]byte, er
// input is comprised of two arguments:
// index: 32 byte integer representing the index of the validator to get
// blockNumber: 32 byte integer representing the block number to access
if (ctx.IsGFork && len(input) != 64) || len(input) < 64 {
if (ctx.IsGingerbread && len(input) != 64) || len(input) < 64 {
return nil, ErrInputLength
}

Expand Down
8 changes: 4 additions & 4 deletions core/vm/celo_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ func BenchmarkPrecompiledEd25519Verify(b *testing.B) { benchJson("ed25519Verify"
// Tests sample inputs for fractionMulExp
// NOTE: This currently only verifies that inputs of invalid length are rejected
func TestPrecompiledFractionMulExp(t *testing.T) {
// Post GFork behaviour
mockEVM.chainRules.IsGFork = true
// Post Gingerbread behaviour
mockEVM.chainRules.IsGingerbread = true
testJson("fractionMulExp", "fc", t)
// Pre GFork behaviour
mockEVM.chainRules.IsGFork = false
// Pre Gingerbread behaviour
mockEVM.chainRules.IsGingerbread = false
testJson("fractionMulExpOld", "fc", t)
}

Expand Down
4 changes: 2 additions & 2 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
if cfg.JumpTable[STOP] == nil {
var jt JumpTable
switch {
case evm.chainRules.IsGFork:
jt = gforkInstructionSet
case evm.chainRules.IsGingerbread:
jt = gingerbreadInstructionSet
case evm.chainRules.IsEspresso:
jt = espressoInstructionSet
case evm.chainRules.IsIstanbul:
Expand Down
8 changes: 4 additions & 4 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ var (
constantinopleInstructionSet = newConstantinopleInstructionSet()
istanbulInstructionSet = newIstanbulInstructionSet()
espressoInstructionSet = newEspressoInstructionSet()
gforkInstructionSet = newGforkInstructionSet()
gingerbreadInstructionSet = newGingerbreadInstructionSet()
)

// JumpTable contains the EVM opcodes supported at a given fork.
type JumpTable [256]*operation

// newGforkInstructionSet returns the frontier, homestead, byzantium,
// constantinople, istanbul, petersburg, espresso and g-fork instructions.
func newGforkInstructionSet() JumpTable {
// newGingerbreadInstructionSet returns the frontier, homestead, byzantium,
// constantinople, istanbul, petersburg, espresso and gingerbread instructions.
func newGingerbreadInstructionSet() JumpTable {
instructionSet := newEspressoInstructionSet()
instructionSet[GASLIMIT] = &operation{
execute: opGasLimit,
Expand Down
2 changes: 1 addition & 1 deletion core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func setDefaults(cfg *Config) {
ChurritoBlock: new(big.Int),
DonutBlock: new(big.Int),
EspressoBlock: new(big.Int),
GForkBlock: new(big.Int),
GingerbreadBlock: new(big.Int),
}
}
if cfg.Time == nil {
Expand Down
4 changes: 2 additions & 2 deletions core/vm/vmcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ func TobinTransfer(evm *vm.EVM, sender, recipient common.Address, amount *big.In
defer func() { evm.SetDebug(true) }()
}

// Only deduct tobin tax before the g hardfork
if evm.ChainConfig().IsGFork(evm.Context.BlockNumber) {
// Only deduct tobin tax before gingerbread fork
if evm.ChainConfig().IsGingerbread(evm.Context.BlockNumber) {
Transfer(evm.StateDB, sender, recipient, amount)
} else {
if amount.Cmp(big.NewInt(0)) != 0 {
Expand Down
20 changes: 10 additions & 10 deletions e2e_test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func TestEthersJSCompatibilityDisableAfterGingerbread(t *testing.T) {

for _, field := range []string{"gasLimit", "baseFeePerGas", "sha3Uncles", "uncles", "nonce", "mixHash", "difficulty"} {
_, ok := result[field]
assert.Truef(t, ok, "%s field should be present on RPC block after GFork", field)
assert.Truef(t, ok, "%s field should be present on RPC block after Gingerbread", field)
}
require.Equal(t, result["sha3Uncles"], "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")

Expand All @@ -621,21 +621,21 @@ func TestEthersJSCompatibilityDisableAfterGingerbread(t *testing.T) {
err = network[0].WsClient.GetRPCClient().CallContext(ctx, &result, "eth_getBlockByNumber", "latest", true)
require.NoError(t, err)

// After GFork, gasLimit should be returned directly from the header, even if
// After Gingerbread, gasLimit should be returned directly from the header, even if
// RPCEthCompatibility is off, since it is now part of the header hash.
_, ok := result["gasLimit"]
assert.True(t, ok, "gasLimit field must be present on RPC block after GFork")
assert.True(t, ok, "gasLimit field must be present on RPC block after Gingerbread")
_, ok = result["baseFeePerGas"]
assert.False(t, ok, "baseFeePerGas field must be present on RPC block")
}

// This test checks the functionality of the configuration to enable/disable
// returning the 'gasLimit' and 'baseFeePerGas' fields on RPC blocks before the GFork happened.
// GFork is relevant because it added the gasLimit to the header.
func TestEthersJSCompatibilityDisableBeforeGFork(t *testing.T) {
// returning the 'gasLimit' and 'baseFeePerGas' fields on RPC blocks before the Gingerbread happened.
// Gingerbread is relevant because it added the gasLimit to the header.
func TestEthersJSCompatibilityDisableBeforeGingerbread(t *testing.T) {
ac := test.AccountConfig(1, 1)
gc, ec, err := test.BuildConfig(ac)
gc.Hardforks.GForkBlock = nil
gc.Hardforks.GingerbreadBlock = nil
require.NoError(t, err)

// Check fields present (compatibility set by default)
Expand All @@ -652,11 +652,11 @@ func TestEthersJSCompatibilityDisableBeforeGFork(t *testing.T) {

for _, field := range []string{"gasLimit", "baseFeePerGas", "difficulty"} {
_, ok := result[field]
assert.Truef(t, ok, "%s field should be present on RPC block before GFork", field)
assert.Truef(t, ok, "%s field should be present on RPC block before Gingerbread", field)
}
for _, field := range []string{"sha3Uncles", "uncles", "nonce", "mixHash"} {
_, ok := result[field]
assert.Falsef(t, ok, "%s field should not be present on RPC block before GFork", field)
assert.Falsef(t, ok, "%s field should not be present on RPC block before Gingerbread", field)
}

// Turn off compatibility and check fields are not present
Expand All @@ -674,6 +674,6 @@ func TestEthersJSCompatibilityDisableBeforeGFork(t *testing.T) {

for _, field := range []string{"gasLimit", "baseFeePerGas", "sha3Uncles", "uncles", "nonce", "mixHash", "difficulty"} {
_, ok := result[field]
assert.Falsef(t, ok, "%s field should not be present on RPC block before GFork", field)
assert.Falsef(t, ok, "%s field should not be present on RPC block before Gingerbread", field)
}
}
2 changes: 1 addition & 1 deletion e2e_test/e2e_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestTransferCELO(t *testing.T) {
func TestTransferCELOPreGFork(t *testing.T) {
ac := test.AccountConfig(1, 3)
gc, ec, err := test.BuildConfig(ac)
gc.Hardforks.GForkBlock = nil
gc.Hardforks.GingerbreadBlock = nil

require.NoError(t, err)
network, shutdown, err := test.NewNetwork(ac, gc, ec)
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideEHardfork)
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideGingerbread)
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
return nil, genesisErr
}
Expand Down
4 changes: 2 additions & 2 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ type Config struct {
// CheckpointOracle is the configuration for checkpoint oracle.
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`

// E block override (TODO: remove after the fork)
OverrideEHardfork *big.Int `toml:",omitempty"`
// Gingerbread block override (TODO: remove after the fork)
OverrideGingerbread *big.Int `toml:",omitempty"`

// The minimum required peers in order for syncing to be initiated, if left
// at 0 then the default will be used.
Expand Down
Loading

0 comments on commit 64ac925

Please sign in to comment.