Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some settings from policy contract #2300

Merged
merged 9 commits into from
Feb 12, 2021
Merged

Conversation

erikzhang
Copy link
Member

No description provided.

@roman-khimov
Copy link
Contributor

A step back to Neo 2 IMO. I'd rather have protocol configuration file contain the bare minimum to successfully operate on the network/process chain (like magic and seed nodes list) and everything else should be discoverable from on-chain data. Consider updating these values, going through chain is like sending one transaction and everything works, but changing configuration files requires synchronization between CN maintainers and restarts.

@erikzhang
Copy link
Member Author

These settings are more about consensus. And the consensus is moved to plugin. So we should remove these settings from core.

@shargon
Copy link
Member

shargon commented Feb 5, 2021

I think that any consensus need these kind of limits, so it's good to have this configuration shared and stored in the chain

@erikzhang
Copy link
Member Author

But who can modify these settings? The committee? I don't think so. Maybe the core developers should be responsible for modifying them.

@roman-khimov
Copy link
Contributor

Committee runs the network, so committee sets the setting. In a transparent and traceable way.

@Tommo-L
Copy link
Contributor

Tommo-L commented Feb 6, 2021

The code is good for me. These parameters are mainly protocol security parameters, which can not be determined by committee.

@erikzhang
Copy link
Member Author

Go?

@cloud8little
Copy link
Contributor

Go?

Testing. Please wait.

@shargon
Copy link
Member

shargon commented Feb 8, 2021

How the core developers will ensure that all the nodes will have the same policiy file? maybe we should add this configuration inside the blockchain and allow only core developers to change it

@erikzhang
Copy link
Member Author

maybe we should add this configuration inside the blockchain and allow only core developers to change it

I think it is impossible.

@shargon
Copy link
Member

shargon commented Feb 8, 2021

I think it is impossible.

With hardcoded url and oracle we can update a json in mainnet-config.neo.org (and redirect this dns to github url).

@erikzhang
Copy link
Member Author

I don't think a decentralized blockchain should rely on a centralized website.

@shargon
Copy link
Member

shargon commented Feb 8, 2021

I don't think a decentralized blockchain should rely on a centralized website.

It will be the same with the config file.

@erikzhang
Copy link
Member Author

It will be the same with the config file.

It won't. With config file you can "choose" to update or not.

@roman-khimov
Copy link
Contributor

But you can't set arbitrary values there, the network won't function properly if there is any disagreement between CNs wrt this values.

@@ -287,8 +287,6 @@ public virtual VerifyResult VerifyStateDependent(DataCache snapshot, Transaction
foreach (UInt160 hash in hashes)
if (NativeContract.Policy.IsBlocked(snapshot, hash))
return VerifyResult.PolicyFail;
if (NativeContract.Policy.GetMaxBlockSystemFee(snapshot) < SystemFee)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this check is removed, how to stop such transactions from getting into Mempool?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should treat service, storage and CPU fees differently, otherwise the restrictions on fees are meaningless. This can be done later.

@cloud8little
Copy link
Contributor

cloud8little commented Feb 8, 2021

It seems there is a problem here, when CN all update their protocol settings to set a smaller MaxTransactionsPerBlock, and before the change, there is already a bigger MaxTransactionsPerBlock number of TX persisted in the previous blocks. then the CN failed to start.

scenario:
CN starts with initial MaxTransactionsPerBlock=200, and send massive tx, some blocks contain the maximum 200 blocks. then stop the CN nodes, and update MaxTransactionsPerBlock to 100, fail to start.

466594e92a5403194c925be2142d533

        public void Deserialize(BinaryReader reader)
        {
            Header = reader.ReadSerializable<Header>();
            Transactions = reader.ReadSerializableArray<Transaction>((int)ProtocolSettings.Default.MaxTransactionsPerBlock);
            if (Transactions.Distinct().Count() != Transactions.Length)
                throw new FormatException();
            if (MerkleTree.ComputeRoot(Transactions.Select(p => p.Hash).ToArray()) != Header.MerkleRoot)

@erikzhang
Copy link
Member Author

when CN all update their protocol settings to set a smaller MaxTransactionsPerBlock, and before the change, there is already a bigger MaxTransactionsPerBlock number of TX persisted in the previous blocks. then the CN failed to start.

This field cannot be set smaller.

@erikzhang
Copy link
Member Author

Go?

@cloud8little
Copy link
Contributor

Go?

I am good. Except a little concern that there is a possibility to set the max transaction smaller than the previous configuration

@erikzhang
Copy link
Member Author

there is a possibility to set the max transaction smaller than the previous configuration

This is impossible. Because it is hard-coded, and we will only make it larger.

@superboyiii superboyiii mentioned this pull request Feb 11, 2021
27 tasks
shargon added a commit to shargon/neo-devpack-dotnet that referenced this pull request Feb 12, 2021
@erikzhang erikzhang merged commit 1dcda66 into master Feb 12, 2021
@erikzhang erikzhang deleted the remove-some-policies branch February 12, 2021 14:30
@@ -368,8 +367,7 @@ internal void UpdatePoolForBlockPersisted(Block block, DataCache snapshot)
if (block.Index > 0 && _system.HeaderCache.Count > 0)
return;

uint _maxTxPerBlock = NativeContract.Policy.GetMaxTransactionsPerBlock(snapshot);
ReverifyTransactions(_sortedTransactions, _unverifiedSortedTransactions, (int)_maxTxPerBlock, MaxMillisecondsToReverifyTx, snapshot);
ReverifyTransactions(_sortedTransactions, _unverifiedSortedTransactions, (int)ProtocolSettings.Default.MaxTransactionsPerBlock, MaxMillisecondsToReverifyTx, snapshot);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we eliminate the use of ProtocolSettings.Default here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fixed by #2337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants