diff --git a/action/protocol/context.go b/action/protocol/context.go index 3e1375212a..39e508a661 100644 --- a/action/protocol/context.go +++ b/action/protocol/context.go @@ -115,7 +115,6 @@ type ( FixContractStakingWeightedVotes bool ExecutionSizeLimit32KB bool UseZeroNonceForFreshAccount bool - SharedGasWithDapp bool CandidateRegisterMustWithStake bool DisableDelegateEndorsement bool RefactorFreshAccountConversion bool @@ -267,7 +266,6 @@ func WithFeatureCtx(ctx context.Context) context.Context { FixContractStakingWeightedVotes: g.IsRedsea(height), ExecutionSizeLimit32KB: !g.IsSumatra(height), UseZeroNonceForFreshAccount: g.IsSumatra(height), - SharedGasWithDapp: g.IsToBeEnabled(height), CandidateRegisterMustWithStake: !g.IsTsunami(height), DisableDelegateEndorsement: !g.IsTsunami(height), RefactorFreshAccountConversion: g.IsTsunami(height), diff --git a/action/protocol/execution/evm/context.go b/action/protocol/execution/evm/context.go index 8d2cb1dff9..2f06a77b18 100644 --- a/action/protocol/execution/evm/context.go +++ b/action/protocol/execution/evm/context.go @@ -13,9 +13,7 @@ type ( HelperContext struct { GetBlockHash GetBlockHash GetBlockTime GetBlockTime - DepositGasFunc DepositGasWithSGD - // TODO: sgd should be moved into depositGasFunc - Sgd SGDRegistry + DepositGasFunc DepositGas } ) diff --git a/action/protocol/execution/evm/evm.go b/action/protocol/execution/evm/evm.go index 363925d79e..2def172fd2 100644 --- a/action/protocol/execution/evm/evm.go +++ b/action/protocol/execution/evm/evm.go @@ -55,13 +55,8 @@ type ( // GetBlockTime gets block time by height GetBlockTime func(uint64) (time.Time, error) - // DepositGasWithSGD deposits gas with Sharing of Gas-fee with DApps - DepositGasWithSGD func(context.Context, protocol.StateManager, address.Address, *big.Int, *big.Int) (*action.TransactionLog, error) - - // SGDRegistry is the interface for handling Sharing of Gas-fee with DApps - SGDRegistry interface { - CheckContract(context.Context, string) (address.Address, uint64, bool, error) - } + // DepositGas deposits gas + DepositGas func(context.Context, protocol.StateManager, *big.Int) (*action.TransactionLog, error) ) // CanTransfer checks whether the from account has enough balance @@ -240,7 +235,6 @@ func ExecuteContract( if err != nil { return nil, nil, err } - sgd := ps.helperCtx.Sgd retval, depositGas, remainingGas, contractAddress, statusCode, err := executeInEVM(ps, stateDB) if err != nil { return nil, nil, err @@ -275,24 +269,8 @@ func ExecuteContract( } } if consumedGas > 0 { - var ( - receiver address.Address - sharedGas uint64 - sharedGasFee, totalGasFee *big.Int - ) - if ps.featureCtx.SharedGasWithDapp && sgd != nil { - // TODO: sgd is whether nil should be checked in processSGD - receiver, sharedGas, err = processSGD(ctx, sm, execution, consumedGas, sgd) - if err != nil { - return nil, nil, errors.Wrap(err, "failed to process Sharing of Gas-fee with DApps") - } - } - if sharedGas > 0 { - sharedGasFee = big.NewInt(int64(sharedGas)) - sharedGasFee.Mul(sharedGasFee, ps.txCtx.GasPrice) - } - totalGasFee = new(big.Int).Mul(new(big.Int).SetUint64(consumedGas), ps.txCtx.GasPrice) - depositLog, err = ps.helperCtx.DepositGasFunc(ctx, sm, receiver, totalGasFee, sharedGasFee) + gasValue := new(big.Int).Mul(new(big.Int).SetUint64(consumedGas), ps.txCtx.GasPrice) + depositLog, err = ps.helperCtx.DepositGasFunc(ctx, sm, gasValue) if err != nil { return nil, nil, err } @@ -319,25 +297,6 @@ func ExecuteContract( return retval, receipt, nil } -func processSGD(ctx context.Context, sm protocol.StateManager, execution *action.EvmTransaction, consumedGas uint64, sgd SGDRegistry, -) (address.Address, uint64, error) { - if execution.To() == nil { - return nil, 0, nil - } - - contract, _ := address.FromBytes((*execution.To())[:]) - receiver, percentage, ok, err := sgd.CheckContract(ctx, contract.String()) - if err != nil || !ok { - return nil, 0, err - } - - sharedGas := consumedGas * percentage / 100 - if sharedGas > consumedGas { - sharedGas = consumedGas - } - return receiver, sharedGas, nil -} - // ReadContractStorage reads contract's storage func ReadContractStorage( ctx context.Context, diff --git a/action/protocol/execution/evm/evm_test.go b/action/protocol/execution/evm/evm_test.go index de32ff9ca1..9001f2fb41 100644 --- a/action/protocol/execution/evm/evm_test.go +++ b/action/protocol/execution/evm/evm_test.go @@ -17,7 +17,6 @@ import ( "github.com/stretchr/testify/require" "github.com/iotexproject/go-pkgs/hash" - "github.com/iotexproject/iotex-address/address" "github.com/iotexproject/iotex-proto/golang/iotextypes" "github.com/iotexproject/iotex-core/action" @@ -67,10 +66,9 @@ func TestExecuteContractFailure(t *testing.T) { GetBlockTime: func(uint64) (time.Time, error) { return time.Time{}, nil }, - DepositGasFunc: func(context.Context, protocol.StateManager, address.Address, *big.Int, *big.Int) (*action.TransactionLog, error) { + DepositGasFunc: func(context.Context, protocol.StateManager, *big.Int) (*action.TransactionLog, error) { return nil, nil }, - Sgd: nil, }) retval, receipt, err := ExecuteContract(ctx, sm, action.NewEvmTx(e)) require.Nil(t, retval) diff --git a/action/protocol/execution/protocol.go b/action/protocol/execution/protocol.go index f6d77295e9..630f85d3d8 100644 --- a/action/protocol/execution/protocol.go +++ b/action/protocol/execution/protocol.go @@ -31,19 +31,18 @@ const ( type Protocol struct { getBlockHash evm.GetBlockHash getBlockTime evm.GetBlockTime - depositGas evm.DepositGasWithSGD + depositGas evm.DepositGas addr address.Address - sgdRegistry evm.SGDRegistry } // NewProtocol instantiates the protocol of exeuction -func NewProtocol(getBlockHash evm.GetBlockHash, depositGasWithSGD evm.DepositGasWithSGD, sgd evm.SGDRegistry, getBlockTime evm.GetBlockTime) *Protocol { +func NewProtocol(getBlockHash evm.GetBlockHash, depositGas evm.DepositGas, getBlockTime evm.GetBlockTime) *Protocol { h := hash.Hash160b([]byte(_protocolID)) addr, err := address.FromBytes(h[:]) if err != nil { log.L().Panic("Error when constructing the address of vote protocol", zap.Error(err)) } - return &Protocol{getBlockHash: getBlockHash, depositGas: depositGasWithSGD, addr: addr, sgdRegistry: sgd, getBlockTime: getBlockTime} + return &Protocol{getBlockHash: getBlockHash, depositGas: depositGas, addr: addr, getBlockTime: getBlockTime} } // FindProtocol finds the registered protocol from registry @@ -72,7 +71,6 @@ func (p *Protocol) Handle(ctx context.Context, act action.Action, sm protocol.St GetBlockHash: p.getBlockHash, GetBlockTime: p.getBlockTime, DepositGasFunc: p.depositGas, - Sgd: p.sgdRegistry, }) _, receipt, err := evm.ExecuteContract(ctx, sm, action.NewEvmTx(exec)) diff --git a/action/protocol/execution/protocol_test.go b/action/protocol/execution/protocol_test.go index be8cffe27a..67391880ce 100644 --- a/action/protocol/execution/protocol_test.go +++ b/action/protocol/execution/protocol_test.go @@ -296,7 +296,7 @@ func readExecution( ctx = evm.WithHelperCtx(ctx, evm.HelperContext{ GetBlockHash: dao.GetBlockHash, GetBlockTime: getBlockTimeForTest, - DepositGasFunc: rewarding.DepositGasWithSGD, + DepositGasFunc: rewarding.DepositGas, }) return sf.SimulateExecution(ctx, addr, exec) } @@ -492,7 +492,7 @@ func (sct *SmartContractTest) prepareBlockchain( r.NoError(reward.Register(registry)) r.NotNil(bc) - execution := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, getBlockTimeForTest) + execution := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, getBlockTimeForTest) r.NoError(execution.Register(registry)) r.NoError(bc.Start(ctx)) @@ -642,7 +642,7 @@ func TestProtocol_Validate(t *testing.T) { require := require.New(t) p := execution.NewProtocol(func(uint64) (hash.Hash256, error) { return hash.ZeroHash256, nil - }, rewarding.DepositGasWithSGD, nil, getBlockTimeForTest) + }, rewarding.DepositGas, getBlockTimeForTest) cases := []struct { name string @@ -735,7 +735,7 @@ func TestProtocol_Handle(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - exeProtocol := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, getBlockTimeForTest) + exeProtocol := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, getBlockTimeForTest) require.NoError(exeProtocol.Register(registry)) require.NoError(bc.Start(ctx)) require.NotNil(bc) diff --git a/action/protocol/poll/consortium.go b/action/protocol/poll/consortium.go index 7f85cb73af..841527b557 100644 --- a/action/protocol/poll/consortium.go +++ b/action/protocol/poll/consortium.go @@ -135,10 +135,9 @@ func (cc *consortiumCommittee) CreateGenesisStates(ctx context.Context, sm proto return hash.ZeroHash256, nil }, GetBlockTime: getBlockTime, - DepositGasFunc: func(context.Context, protocol.StateManager, address.Address, *big.Int, *big.Int) (*action.TransactionLog, error) { + DepositGasFunc: func(context.Context, protocol.StateManager, *big.Int) (*action.TransactionLog, error) { return nil, nil }, - Sgd: nil, }) // deploy consortiumCommittee contract diff --git a/action/protocol/poll/staking_committee.go b/action/protocol/poll/staking_committee.go index c93e2ed3f9..aa5d1aaa4d 100644 --- a/action/protocol/poll/staking_committee.go +++ b/action/protocol/poll/staking_committee.go @@ -143,10 +143,9 @@ func (sc *stakingCommittee) CreateGenesisStates(ctx context.Context, sm protocol // make sure the returned timestamp is after the current block time so that evm upgrades based on timestamp (Shanghai and onwards) are disabled return blkCtx.BlockTimeStamp.Add(5 * time.Second), nil }, - DepositGasFunc: func(context.Context, protocol.StateManager, address.Address, *big.Int, *big.Int) (*action.TransactionLog, error) { + DepositGasFunc: func(context.Context, protocol.StateManager, *big.Int) (*action.TransactionLog, error) { return nil, nil }, - Sgd: nil, }) // deploy native staking contract _, receipt, err := evm.ExecuteContract( diff --git a/action/protocol/rewarding/fund.go b/action/protocol/rewarding/fund.go index bb29fb81cb..1f942c934a 100644 --- a/action/protocol/rewarding/fund.go +++ b/action/protocol/rewarding/fund.go @@ -63,17 +63,6 @@ func (p *Protocol) Deposit( sm protocol.StateManager, amount *big.Int, transactionLogType iotextypes.TransactionLogType, -) (*action.TransactionLog, error) { - // fallback to regular case by setting sgdAmount = nil - return p.deposit(ctx, sm, nil, amount, nil, transactionLogType) -} - -func (p *Protocol) deposit( - ctx context.Context, - sm protocol.StateManager, - receiver address.Address, - amount, sgdAmount *big.Int, - transactionLogType iotextypes.TransactionLogType, ) (*action.TransactionLog, error) { actionCtx := protocol.MustGetActionCtx(ctx) accountCreationOpts := []state.AccountCreationOption{} @@ -96,18 +85,8 @@ func (p *Protocol) deposit( if _, err := p.state(ctx, sm, _fundKey, &f); err != nil { return nil, err } - f.totalBalance.Add(f.totalBalance, amount) - f.unclaimedBalance.Add(f.unclaimedBalance, amount) - if !isZero(sgdAmount) { - f.unclaimedBalance.Sub(f.unclaimedBalance, sgdAmount) - if f.unclaimedBalance.Sign() == -1 { - return nil, errors.New("no enough available balance") - } - // grant sgd amount to receiver - if err := p.grantToAccount(ctx, sm, receiver, sgdAmount); err != nil { - return nil, err - } - } + f.totalBalance = big.NewInt(0).Add(f.totalBalance, amount) + f.unclaimedBalance = big.NewInt(0).Add(f.unclaimedBalance, amount) if err := p.putState(ctx, sm, _fundKey, &f); err != nil { return nil, err } @@ -167,35 +146,3 @@ func DepositGas(ctx context.Context, sm protocol.StateManager, amount *big.Int) } return rp.Deposit(ctx, sm, amount, iotextypes.TransactionLogType_GAS_FEE) } - -// DepositGasWithSGD deposits gas into the rewarding fund with Sharing of Gas-fee with DApps -func DepositGasWithSGD(ctx context.Context, sm protocol.StateManager, sgdReceiver address.Address, totalAmount, sgdAmount *big.Int, -) (*action.TransactionLog, error) { - if isZero(sgdAmount) { - // fallback to regular case if SGD amount is zero - return DepositGas(ctx, sm, totalAmount) - } - if sgdReceiver == nil { - // a valid SGD amount but no valid receiver address - return nil, errors.New("no valid receiver address to receive the Sharing of Gas-fee with DApps") - } - // TODO: we bypass the gas deposit for the actions in genesis block. Later we should remove this after we remove - // genesis actions - blkCtx := protocol.MustGetBlockCtx(ctx) - if blkCtx.BlockHeight == 0 { - return nil, nil - } - reg, ok := protocol.GetRegistry(ctx) - if !ok { - return nil, nil - } - rp := FindProtocol(reg) - if rp == nil { - return nil, nil - } - return rp.deposit(ctx, sm, sgdReceiver, totalAmount, sgdAmount, iotextypes.TransactionLogType_GAS_FEE) -} - -func isZero(a *big.Int) bool { - return a == nil || len(a.Bytes()) == 0 -} diff --git a/action/protocol/staking/handler_stake_migrate_test.go b/action/protocol/staking/handler_stake_migrate_test.go index 50aa61f4c9..fdf27f7d32 100644 --- a/action/protocol/staking/handler_stake_migrate_test.go +++ b/action/protocol/staking/handler_stake_migrate_test.go @@ -148,10 +148,9 @@ func TestHandleStakeMigrate(t *testing.T) { r.Equal(uint64(iotextypes.ReceiptStatus_Success), receipts[1].Status) excPrtl := execution.NewProtocol( func(u uint64) (hash.Hash256, error) { return hash.ZeroHash256, nil }, - func(context.Context, protocol.StateManager, address.Address, *big.Int, *big.Int) (*action.TransactionLog, error) { + func(context.Context, protocol.StateManager, *big.Int) (*action.TransactionLog, error) { return nil, nil }, - nil, func(uint64) (time.Time, error) { return time.Now(), nil }, ) reg := protocol.NewRegistry() diff --git a/api/coreservice.go b/api/coreservice.go index c25604fa64..51b16175a1 100644 --- a/api/coreservice.go +++ b/api/coreservice.go @@ -1904,7 +1904,7 @@ func (core *coreService) simulateExecution(ctx context.Context, addr address.Add ctx = evm.WithHelperCtx(ctx, evm.HelperContext{ GetBlockHash: getBlockHash, GetBlockTime: getBlockTime, - DepositGasFunc: rewarding.DepositGasWithSGD, + DepositGasFunc: rewarding.DepositGas, }) return core.sf.SimulateExecution(ctx, addr, exec) } diff --git a/api/serverV2_integrity_test.go b/api/serverV2_integrity_test.go index 8994d9b664..7a30f3f12c 100644 --- a/api/serverV2_integrity_test.go +++ b/api/serverV2_integrity_test.go @@ -338,7 +338,7 @@ func setupChain(cfg testConfig) (blockchain.Blockchain, blockdao.BlockDAO, block }() acc := account.NewProtocol(rewarding.DepositGas) - evm := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, func(u uint64) (time.Time, error) { return time.Time{}, nil }) + evm := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, func(u uint64) (time.Time, error) { return time.Time{}, nil }) p := poll.NewLifeLongDelegatesProtocol(cfg.genesis.Delegates) rolldposProtocol := rolldpos.NewProtocol( genesis.Default.NumCandidateDelegates, diff --git a/blockchain/integrity/benchmark_test.go b/blockchain/integrity/benchmark_test.go index 48cac0954b..087a3db244 100644 --- a/blockchain/integrity/benchmark_test.go +++ b/blockchain/integrity/benchmark_test.go @@ -282,7 +282,7 @@ func newChainInDB() (blockchain.Blockchain, actpool.ActPool, error) { if bc == nil { return nil, nil, errors.New("pointer is nil") } - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) if err = ep.Register(registry); err != nil { return nil, nil, err } diff --git a/blockchain/integrity/integrity_test.go b/blockchain/integrity/integrity_test.go index 397916ce64..14827a2509 100644 --- a/blockchain/integrity/integrity_test.go +++ b/blockchain/integrity/integrity_test.go @@ -506,7 +506,7 @@ func TestCreateBlockchain(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) require.NoError(ep.Register(registry)) rewardingProtocol := rewarding.NewProtocol(cfg.Genesis.Rewarding) require.NoError(rewardingProtocol.Register(registry)) @@ -561,7 +561,7 @@ func TestGetBlockHash(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) require.NoError(ep.Register(registry)) rewardingProtocol := rewarding.NewProtocol(cfg.Genesis.Rewarding) require.NoError(rewardingProtocol.Register(registry)) @@ -726,7 +726,7 @@ func TestBlockchain_MintNewBlock(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) require.NoError(t, ep.Register(registry)) rewardingProtocol := rewarding.NewProtocol(cfg.Genesis.Rewarding) require.NoError(t, rewardingProtocol.Register(registry)) @@ -804,7 +804,7 @@ func TestBlockchain_MintNewBlock_PopAccount(t *testing.T) { ) rp := rolldpos.NewProtocol(cfg.Genesis.NumCandidateDelegates, cfg.Genesis.NumDelegates, cfg.Genesis.NumSubEpochs) require.NoError(t, rp.Register(registry)) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) require.NoError(t, ep.Register(registry)) rewardingProtocol := rewarding.NewProtocol(cfg.Genesis.Rewarding) require.NoError(t, rewardingProtocol.Register(registry)) @@ -931,7 +931,7 @@ func createChain(cfg config.Config, inMem bool) (blockchain.Blockchain, factory. if dao == nil { return nil, nil, nil, nil, err } - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) if err = ep.Register(registry); err != nil { return nil, nil, nil, nil, err } @@ -1433,7 +1433,7 @@ func TestConstantinople(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) require.NoError(ep.Register(registry)) rewardingProtocol := rewarding.NewProtocol(cfg.Genesis.Rewarding) require.NoError(rewardingProtocol.Register(registry)) @@ -1686,7 +1686,7 @@ func TestLoadBlockchainfromDB(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) require.NoError(ep.Register(registry)) require.NoError(bc.Start(ctx)) @@ -2552,7 +2552,7 @@ func newChain(t *testing.T, stateTX bool) (blockchain.Blockchain, factory.Factor )), ) require.NotNil(bc) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) require.NoError(ep.Register(registry)) require.NoError(bc.Start(context.Background())) diff --git a/blockindex/sgd_indexer.go b/blockindex/sgd_indexer.go deleted file mode 100644 index 5d5e2532bb..0000000000 --- a/blockindex/sgd_indexer.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2023 IoTeX Foundation -// This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability -// or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed. -// This source code is governed by Apache License 2.0 that can be found in the LICENSE file. - -package blockindex - -import ( - "context" - - "github.com/iotexproject/iotex-address/address" - - "github.com/iotexproject/iotex-core/blockchain/block" - "github.com/iotexproject/iotex-core/blockchain/blockdao" -) - -type ( - // SGDRegistry is the interface for Sharing of Gas-fee with DApps - SGDRegistry interface { - blockdao.BlockIndexer - // CheckContract returns the contract's eligibility for SGD and percentage - CheckContract(context.Context, string) (address.Address, uint64, bool, error) - } - - sgdRegistry struct { - } -) - -// NewSGDRegistry creates a new SGDIndexer -func NewSGDRegistry() SGDRegistry { - return &sgdRegistry{} -} - -func (sgd *sgdRegistry) Start(ctx context.Context) error { - return nil -} - -func (sgd *sgdRegistry) Stop(ctx context.Context) error { - return nil -} - -func (sgd *sgdRegistry) Height() (uint64, error) { - return 0, nil -} - -func (sgd *sgdRegistry) PutBlock(ctx context.Context, blk *block.Block) error { - return nil -} - -func (sgd *sgdRegistry) DeleteTipBlock(context.Context, *block.Block) error { - return nil -} - -func (sgd *sgdRegistry) CheckContract(ctx context.Context, contract string) (address.Address, uint64, bool, error) { - return nil, 0, false, nil -} diff --git a/chainservice/builder.go b/chainservice/builder.go index 7c007a27b4..22fd45b179 100644 --- a/chainservice/builder.go +++ b/chainservice/builder.go @@ -273,9 +273,6 @@ func (builder *Builder) buildBlockDAO(forTest bool) error { if builder.cs.contractStakingIndexerV2 != nil { synchronizedIndexers = append(synchronizedIndexers, builder.cs.contractStakingIndexerV2) } - if builder.cs.sgdIndexer != nil { - synchronizedIndexers = append(synchronizedIndexers, builder.cs.sgdIndexer) - } if len(synchronizedIndexers) > 1 { indexers = append(indexers, blockindex.NewSyncIndexers(synchronizedIndexers...)) } else { @@ -306,18 +303,6 @@ func (builder *Builder) buildBlockDAO(forTest bool) error { return nil } -func (builder *Builder) buildSGDRegistry(forTest bool) error { - if builder.cs.sgdIndexer != nil { - return nil - } - if forTest { - builder.cs.sgdIndexer = nil - } else { - builder.cs.sgdIndexer = blockindex.NewSGDRegistry() - } - return nil -} - func (builder *Builder) buildContractStakingIndexer(forTest bool) error { if !builder.cfg.Chain.EnableStakingProtocol { return nil @@ -611,7 +596,7 @@ func (builder *Builder) registerAccountProtocol() error { } func (builder *Builder) registerExecutionProtocol() error { - return execution.NewProtocol(builder.cs.blockdao.GetBlockHash, rewarding.DepositGasWithSGD, builder.cs.sgdIndexer, builder.cs.blockTimeCalculator.CalculateBlockTime).Register(builder.cs.registry) + return execution.NewProtocol(builder.cs.blockdao.GetBlockHash, rewarding.DepositGas, builder.cs.blockTimeCalculator.CalculateBlockTime).Register(builder.cs.registry) } func (builder *Builder) registerRollDPoSProtocol() error { @@ -653,7 +638,7 @@ func (builder *Builder) registerRollDPoSProtocol() error { ctx = evm.WithHelperCtx(ctx, evm.HelperContext{ GetBlockHash: dao.GetBlockHash, GetBlockTime: getBlockTime, - DepositGasFunc: rewarding.DepositGasWithSGD, + DepositGasFunc: rewarding.DepositGas, }) data, _, err := factory.SimulateExecution(ctx, addr, ex) return data, err @@ -749,9 +734,6 @@ func (builder *Builder) build(forSubChain, forTest bool) (*ChainService, error) if err := builder.buildGatewayComponents(forTest); err != nil { return nil, err } - if err := builder.buildSGDRegistry(forTest); err != nil { - return nil, err - } if err := builder.buildContractStakingIndexer(forTest); err != nil { return nil, err } diff --git a/chainservice/chainservice.go b/chainservice/chainservice.go index b1864f7626..299207e1ec 100644 --- a/chainservice/chainservice.go +++ b/chainservice/chainservice.go @@ -70,7 +70,6 @@ type ChainService struct { bfIndexer blockindex.BloomFilterIndexer candidateIndexer *poll.CandidateIndexer candBucketsIndexer *staking.CandidatesBucketsIndexer - sgdIndexer blockindex.SGDRegistry contractStakingIndexer *contractstaking.Indexer contractStakingIndexerV2 stakingindex.StakingIndexer registry *protocol.Registry diff --git a/e2etest/bigint_test.go b/e2etest/bigint_test.go index 0903aec388..c3642da3eb 100644 --- a/e2etest/bigint_test.go +++ b/e2etest/bigint_test.go @@ -116,7 +116,7 @@ func prepareBlockchain(ctx context.Context, _executor string, r *require.Asserti reward := rewarding.NewProtocol(cfg.Genesis.Rewarding) r.NoError(reward.Register(registry)) - ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) r.NoError(ep.Register(registry)) r.NoError(bc.Start(ctx)) ctx = genesis.WithGenesisContext(ctx, cfg.Genesis) diff --git a/e2etest/contract_staking_test.go b/e2etest/contract_staking_test.go index a85fc4ba63..faa2af57d4 100644 --- a/e2etest/contract_staking_test.go +++ b/e2etest/contract_staking_test.go @@ -1993,7 +1993,7 @@ func prepareContractStakingBlockchain(ctx context.Context, cfg config.Config, r // r.NoError(reward.Register(registry)) r.NotNil(bc) - execution := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGasWithSGD, nil, fakeGetBlockTime) + execution := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas, fakeGetBlockTime) r.NoError(execution.Register(registry)) r.NoError(bc.Start(ctx)) diff --git a/e2etest/staking_test.go b/e2etest/staking_test.go index fe9d8e05fd..45b05da5ce 100644 --- a/e2etest/staking_test.go +++ b/e2etest/staking_test.go @@ -126,7 +126,7 @@ func TestStakingContract(t *testing.T) { ctx = evm.WithHelperCtx(ctx, evm.HelperContext{ GetBlockHash: dao.GetBlockHash, GetBlockTime: fakeGetBlockTime, - DepositGasFunc: rewarding.DepositGasWithSGD, + DepositGasFunc: rewarding.DepositGas, }) data, _, err := sf.SimulateExecution(ctx, addr, ex) diff --git a/gasstation/gasstattion_test.go b/gasstation/gasstattion_test.go index 5bf8000ed7..695afd38f9 100644 --- a/gasstation/gasstattion_test.go +++ b/gasstation/gasstattion_test.go @@ -99,7 +99,7 @@ func TestSuggestGasPriceForUserAction(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - ep := execution.NewProtocol(blkMemDao.GetBlockHash, rewarding.DepositGasWithSGD, nil, func(u uint64) (time.Time, error) { return time.Time{}, nil }) + ep := execution.NewProtocol(blkMemDao.GetBlockHash, rewarding.DepositGas, func(u uint64) (time.Time, error) { return time.Time{}, nil }) require.NoError(t, ep.Register(registry)) rewardingProtocol := rewarding.NewProtocol(cfg.Genesis.Rewarding) require.NoError(t, rewardingProtocol.Register(registry)) @@ -181,7 +181,7 @@ func TestSuggestGasPriceForSystemAction(t *testing.T) { protocol.NewGenericValidator(sf, accountutil.AccountState), )), ) - ep := execution.NewProtocol(blkMemDao.GetBlockHash, rewarding.DepositGasWithSGD, nil, func(u uint64) (time.Time, error) { return time.Time{}, nil }) + ep := execution.NewProtocol(blkMemDao.GetBlockHash, rewarding.DepositGas, func(u uint64) (time.Time, error) { return time.Time{}, nil }) require.NoError(t, ep.Register(registry)) rewardingProtocol := rewarding.NewProtocol(cfg.Genesis.Rewarding) require.NoError(t, rewardingProtocol.Register(registry)) diff --git a/ioctl/cmd/ws/wsprojectconfig.go b/ioctl/cmd/ws/wsprojectconfig.go index 0044f2b89d..fc11c90040 100644 --- a/ioctl/cmd/ws/wsprojectconfig.go +++ b/ioctl/cmd/ws/wsprojectconfig.go @@ -215,4 +215,4 @@ func convertCodeToZlibHex(codeFile string) (string, error) { hexString := hex.EncodeToString(b.Bytes()) return hexString, err -} \ No newline at end of file +} diff --git a/ioctl/cmd/ws/wsproverquery.go b/ioctl/cmd/ws/wsproverquery.go index a083e0c1f6..877f3ac216 100644 --- a/ioctl/cmd/ws/wsproverquery.go +++ b/ioctl/cmd/ws/wsproverquery.go @@ -115,7 +115,6 @@ func queryProver(proverID *big.Int) (any, error) { } - func queryProverVmType(proverID, vmType *big.Int) (string, error) { caller, err := NewContractCaller(proverStoreABI, proverStoreAddress) if err != nil { diff --git a/state/factory/factory_test.go b/state/factory/factory_test.go index 264f0f25d3..2c8c32aa07 100644 --- a/state/factory/factory_test.go +++ b/state/factory/factory_test.go @@ -1229,7 +1229,7 @@ func testSimulateExecution(ctx context.Context, sf Factory, t *testing.T) { GetBlockTime: func(u uint64) (time.Time, error) { return time.Time{}, nil }, - DepositGasFunc: rewarding.DepositGasWithSGD, + DepositGasFunc: rewarding.DepositGas, }) _, _, err = sf.SimulateExecution(ctx, addr, ex) require.NoError(err)