Skip to content

Commit

Permalink
parent c9b4f2f
Browse files Browse the repository at this point in the history
author Alan Orwick <[email protected]> 1628866293 -0500
committer Alan Orwick <[email protected]> 1629834117 -0500

Implemented requested changes

Updated zero indexes with global context
  • Loading branch information
0xalank committed Aug 24, 2021
1 parent c9b4f2f commit f362c6e
Show file tree
Hide file tree
Showing 79 changed files with 1,188 additions and 796 deletions.
8 changes: 6 additions & 2 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
}
head := b.blockchain.CurrentHeader()
if !b.blockchain.Config().IsLondon(head.Number) {
if !b.blockchain.Config().IsLondon(head.Number[types.QuaiNetworkContext]) {
// If there's no basefee, then it must be a non-1559 execution
if call.GasPrice == nil {
call.GasPrice = new(big.Int)
Expand All @@ -594,7 +594,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
// Backfill the legacy gasPrice for EVM execution, unless we're all zeroes
call.GasPrice = new(big.Int)
if call.GasFeeCap.BitLen() > 0 || call.GasTipCap.BitLen() > 0 {
call.GasPrice = math.BigMin(new(big.Int).Add(call.GasTipCap, head.BaseFee), call.GasFeeCap)
call.GasPrice = math.BigMin(new(big.Int).Add(call.GasTipCap, head.BaseFee[types.QuaiNetworkContext]), call.GasFeeCap)
}
}
}
Expand Down Expand Up @@ -859,6 +859,10 @@ func (fb *filterBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event
return nullSubscription()
}

func (fb *filterBackend) SubscribePendingBlockEvent(ch chan<- *types.Header) event.Subscription {
return nullSubscription()
}

func (fb *filterBackend) BloomStatus() (uint64, uint64) { return 4096, 0 }

func (fb *filterBackend) ServiceFilter(ctx context.Context, ms *bloombits.MatcherSession) {
Expand Down
28 changes: 14 additions & 14 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestSimulatedBackend(t *testing.T) {

// generate a transaction and confirm you can retrieve it
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

code := `6060604052600a8060106000396000f360606040526008565b00`
var gas uint64 = 3000000
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestNewAdjustTimeFail(t *testing.T) {

// Create tx and send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestNonceAt(t *testing.T) {

// create a signed transaction to send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(nonce, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -334,7 +334,7 @@ func TestSendTransaction(t *testing.T) {

// create a signed transaction to send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -372,7 +372,7 @@ func TestTransactionByHash(t *testing.T) {

// create a signed transaction to send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -633,8 +633,8 @@ func TestHeaderByNumber(t *testing.T) {
if latestBlockHeader == nil {
t.Errorf("received a nil block header")
}
if latestBlockHeader.Number.Uint64() != uint64(0) {
t.Errorf("expected block header number 0, instead got %v", latestBlockHeader.Number.Uint64())
if latestBlockHeader.Number[types.QuaiNetworkContext].Uint64() != uint64(0) {
t.Errorf("expected block header number 0, instead got %v", latestBlockHeader.Number[types.QuaiNetworkContext].Uint64())
}

sim.Commit()
Expand All @@ -652,8 +652,8 @@ func TestHeaderByNumber(t *testing.T) {
if blockHeader.Hash() != latestBlockHeader.Hash() {
t.Errorf("block header and latest block header are not the same")
}
if blockHeader.Number.Int64() != int64(1) {
t.Errorf("did not get blockheader for block 1. instead got block %v", blockHeader.Number.Int64())
if blockHeader.Number[types.QuaiNetworkContext].Int64() != int64(1) {
t.Errorf("did not get blockheader for block 1. instead got block %v", blockHeader.Number[types.QuaiNetworkContext].Int64())
}

block, err := sim.BlockByNumber(bgCtx, big.NewInt(1))
Expand Down Expand Up @@ -687,7 +687,7 @@ func TestTransactionCount(t *testing.T) {
}
// create a signed transaction to send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -744,7 +744,7 @@ func TestTransactionInBlock(t *testing.T) {
}
// create a signed transaction to send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -802,7 +802,7 @@ func TestPendingNonceAt(t *testing.T) {

// create a signed transaction to send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -857,7 +857,7 @@ func TestTransactionReceipt(t *testing.T) {

// create a signed transaction to send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -1286,7 +1286,7 @@ func TestForkResendTx(t *testing.T) {
parent := sim.blockchain.CurrentBlock()
// 2.
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
if opts.GasFeeCap == nil {
gasFeeCap := new(big.Int).Add(
opts.GasTipCap,
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
new(big.Int).Mul(head.BaseFee[types.QuaiNetworkContext], big.NewInt(2)),
)
opts.GasFeeCap = gasFeeCap
}
Expand Down
4 changes: 2 additions & 2 deletions accounts/abi/bind/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestWaitDeployed(t *testing.T) {

// Create the transaction
head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

tx := types.NewContractCreation(0, big.NewInt(0), test.gas, gasPrice, common.FromHex(test.code))
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
defer backend.Close()

head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
gasPrice := new(big.Int).Add(head.BaseFee[types.QuaiNetworkContext], big.NewInt(1))

// Create a transaction to an account.
code := "6060604052600a8060106000396000f360606040526008565b00"
Expand Down
9 changes: 5 additions & 4 deletions cmd/checkpoint-admin/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/contracts/checkpointoracle"
"github.com/ethereum/go-ethereum/contracts/checkpointoracle/contract"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -164,7 +165,7 @@ func sign(ctx *cli.Context) error {
if err != nil {
return err
}
num := head.Number.Uint64()
num := head.Number[types.QuaiNetworkContext].Uint64()
if num < ((cindex+1)*params.CheckpointFrequency + params.CheckpointProcessConfirmations) {
utils.Fatalf("Invalid future checkpoint")
}
Expand Down Expand Up @@ -287,7 +288,7 @@ func publish(ctx *cli.Context) error {
if err != nil {
return err
}
num := head.Number.Uint64()
num := head.Number[types.QuaiNetworkContext].Uint64()
recent, err := ethclient.NewClient(client).HeaderByNumber(reqCtx, big.NewInt(int64(num-128)))
if err != nil {
return err
Expand All @@ -298,11 +299,11 @@ func publish(ctx *cli.Context) error {
fmt.Printf("Signer %d => %s\n", i+1, ecrecover(sighash, sig).Hex())
}
fmt.Println()
fmt.Printf("Sentry number => %d\nSentry hash => %s\n", recent.Number, recent.Hash().Hex())
fmt.Printf("Sentry number => %d\nSentry hash => %s\n", recent.Number[types.QuaiNetworkContext], recent.Hash().Hex())

// Publish the checkpoint into the oracle
fmt.Println("Sending publish request to Clef...")
tx, err := oracle.RegisterCheckpoint(newClefSigner(ctx), checkpoint.SectionIndex, checkpoint.Hash().Bytes(), recent.Number, recent.Hash(), sigs)
tx, err := oracle.RegisterCheckpoint(newClefSigner(ctx), checkpoint.SectionIndex, checkpoint.Hash().Bytes(), recent.Number[types.QuaiNetworkContext], recent.Hash(), sigs)
if err != nil {
utils.Fatalf("Register contract failed %v", err)
}
Expand Down
8 changes: 2 additions & 6 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ func (f *faucet) refresh(head *types.Header) error {
nonce uint64
price *big.Int
)
if balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number); err != nil {
if balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number[types.QuaiNetworkContext]); err != nil {
return err
}
if nonce, err = f.client.NonceAt(ctx, f.account.Address, head.Number); err != nil {
if nonce, err = f.client.NonceAt(ctx, f.account.Address, head.Number[types.QuaiNetworkContext]); err != nil {
return err
}
if price, err = f.client.SuggestGasPrice(ctx); err != nil {
Expand Down Expand Up @@ -892,10 +892,6 @@ func getGenesis(genesisFlag *string, goerliFlag bool, rinkebyFlag bool) (*core.G
var genesis core.Genesis
err := common.LoadJSON(*genesisFlag, &genesis)
return &genesis, err
case goerliFlag:
return core.DefaultGoerliGenesisBlock(), nil
case rinkebyFlag:
return core.DefaultRinkebyGenesisBlock(), nil
default:
return nil, fmt.Errorf("no genesis flag provided")
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ It expects the genesis file as argument.`,
Flags: []cli.Flag{
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down Expand Up @@ -434,7 +431,7 @@ func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, eth
log.Info("State dump configured", "block", header.Number, "hash", header.Hash().Hex(),
"skipcode", conf.SkipCode, "skipstorage", conf.SkipStorage,
"start", hexutil.Encode(conf.Start), "limit", conf.Max)
return conf, db, header.Root, nil
return conf, db, header.Root[types.QuaiNetworkContext], nil
}

func dump(ctx *cli.Context) error {
Expand Down
6 changes: 0 additions & 6 deletions cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ func remoteConsole(ctx *cli.Context) error {
} else {
path = filepath.Join(path, "ropsten")
}
} else if ctx.GlobalBool(utils.RinkebyFlag.Name) {
path = filepath.Join(path, "rinkeby")
} else if ctx.GlobalBool(utils.GoerliFlag.Name) {
path = filepath.Join(path, "goerli")
} else if ctx.GlobalBool(utils.CalaverasFlag.Name) {
path = filepath.Join(path, "calaveras")
}
}
endpoint = fmt.Sprintf("%s/geth.ipc", path)
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/dao_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestDAOForkBlockNewChain(t *testing.T) {
expectVote bool
}{
// Test DAO Default Mainnet
{"", params.MainnetChainConfig.DAOForkBlock, true},
{"", params.MainnetPrimeChainConfig.DAOForkBlock, true},
// test DAO Init Old Privnet
{daoOldGenesis, nil, false},
// test DAO Default No Fork Privnet
Expand Down
24 changes: 0 additions & 24 deletions cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ Remove blockchain and state databases`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
Usage: "Inspect the storage size for each type of data in the database",
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
Expand All @@ -89,9 +86,6 @@ Remove blockchain and state databases`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
}
dbCompactCmd = cli.Command{
Expand All @@ -103,9 +97,6 @@ Remove blockchain and state databases`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
},
Expand All @@ -123,9 +114,6 @@ corruption if it is aborted during execution'!`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
Description: "This command looks up the specified database key from the database.",
}
Expand All @@ -139,9 +127,6 @@ corruption if it is aborted during execution'!`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
Description: `This command deletes the specified database key from the database.
WARNING: This is a low-level operation which may cause database corruption!`,
Expand All @@ -156,9 +141,6 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
Description: `This command sets a given database key to the given value.
WARNING: This is a low-level operation which may cause database corruption!`,
Expand All @@ -173,9 +155,6 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
Description: "This command looks up the specified database key from the database.",
}
Expand All @@ -189,9 +168,6 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.SyncModeFlag,
utils.MainnetFlag,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.CalaverasFlag,
},
Description: "This command displays information about the freezer index.",
}
Expand Down
Loading

0 comments on commit f362c6e

Please sign in to comment.