Add ArbFilteredTransactionsManager precompile#4174
Conversation
1adc79f to
81f4e5e
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4174 +/- ##
==========================================
- Coverage 32.69% 32.68% -0.02%
==========================================
Files 467 469 +2
Lines 56373 56512 +139
==========================================
+ Hits 18433 18472 +39
- Misses 34720 34819 +99
- Partials 3220 3221 +1 |
❌ 3 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
45fb413 to
67c13f2
Compare
7b7a735 to
f56f36c
Compare
Tristan-Wilson
left a comment
There was a problem hiding this comment.
Looks good, just a minor comment about consistency of the interface with other precompiles.
| return filteredState.IsFiltered(txHash) | ||
| } | ||
|
|
||
| func (con ArbFilteredTransactionsManager) hasAccess(c *Context) (bool, error) { |
There was a problem hiding this comment.
This signature is slightly different to ArbNativeTokenManager which has
func (con ArbNativeTokenManager) hasAccess(c ctx) bool {
manager, err := c.State.NativeTokenOwners().IsMember(c.caller)
return manager && err == nil
}
and therefore the behavior when there is an error is slightly different in this implementation in that if there is an error, then the gas is not burned out.
Unsure if this difference is intentional or not.
|
We should consider making |
@Tristan-Wilson, wdyt about going further: remove ArbNativeToken-style check and return an error right in CensorPrecompile, like in ArbOwner? |
| "github.com/offchainlabs/nitro/solgen/go/precompilesgen" | ||
| ) | ||
|
|
||
| func TestManageTransactionCensors(t *testing.T) { |
There was a problem hiding this comment.
Can you please also test that the transactions that should be free are free? You can look at TestArbNativeTokenManager and getGasUsed inside it for inspiration.
There was a problem hiding this comment.
I don't really get how to use getGasUsed in this case, since the transaction will still cost something, only the add/delete call is free. I can suggest to use multigas like this:
tx, err = arbFilteredTxs.AddFilteredTransaction(&censorTxOpts, txHash)
require.NoError(t, err)
receipt, err := builder.L2.EnsureTxSucceeded(tx)
require.NoError(t, err)
require.Equal(t, uint64(0), receipt.MultiGasUsed.Get(multigas.ResourceKindStorageAccess))
This somehow proves that tx did not perform any storage operations like set and clear
There was a problem hiding this comment.
Could you check the censor account's balance is unchanged after adding/deleting filtered txs?
There was a problem hiding this comment.
This precompile wrapper does not make the transaction completely free, but I still believe that this test is useful because it allows to verify that the call goes through the wrapper
| return nil, err | ||
| } | ||
|
|
||
| transactionFiltererStorage := sto.OpenCachedSubStorage(transactionFiltererSubspace) |
There was a problem hiding this comment.
- I think this shouldn't be here but in UpgradeArbosVersion
- I don't think this should be cached, but just a normal storage(?)
|
|
||
| const NativeTokenEnableDelay = 7 * 24 * 60 * 60 | ||
| const NativeTokenEnableDelay = 7 * 24 * 60 * 60 // one week | ||
| const TransactionFilteringEnableDelay = 7 * 24 * 60 * 60 // one week |
There was a problem hiding this comment.
let's just have a single constant for feature that cannot be enabled immediately
| now uint64, | ||
| timestamp uint64, | ||
| delay uint64, | ||
| ) error { |
There was a problem hiding this comment.
not certain - but do we want to go further in code deduplication, and give the function access to the storage + storage offset so it could do get/set by itself? that would remove almost all code from the per-property wrapper.
There was a problem hiding this comment.
I added getters to ArbosState to keep offsets inside
gligneul
left a comment
There was a problem hiding this comment.
Looks good, but please take a look at the comments.
…ransactionsmanager-precompile
| ### Added | ||
| - Add new precompile ArbFilteredTransactionsManager to manage filtered transactions | ||
| - Add transaction filterers to ArbOwner to limit access to ArbFilteredTransactionsManager | ||
| - Limit ArbOwners ability to create transaction filterers with TransactionFilteringFromTime |
|
|
||
| // GetAllTransactionFilterers retrieves the list of transaction filterers | ||
| func (con ArbOwnerPublic) GetAllTransactionFilterers(c ctx, evm mech) ([]common.Address, error) { | ||
| return c.State.TransactionFilterers().AllMembers(65536) |
There was a problem hiding this comment.
What is this magic number? 65536?
There was a problem hiding this comment.
The same magic limiter exist in a few more places, replaced all with maxGetAllMembers
| ArbOwnerPublic.methodsByName["IsNativeTokenOwner"].arbosVersion = params.ArbosVersion_41 | ||
| ArbOwnerPublic.methodsByName["GetAllNativeTokenOwners"].arbosVersion = params.ArbosVersion_41 | ||
| ArbOwnerPublic.methodsByName["GetParentGasFloorPerToken"].arbosVersion = params.ArbosVersion_50 | ||
| ArbOwnerPublic.methodsByName["GetMaxStylusContractFragments"].arbosVersion = params.ArbosVersion_60 |
There was a problem hiding this comment.
Why does this change have anything to do with StylusContractFragments?
There was a problem hiding this comment.
The StylusContractFragments precompile interface was already merged, but nitro PR not yet
…ransactionsmanager-precompile
Fixes NIT-4152 and NIT-4253
pulls in OffchainLabs/nitro-precompile-interfaces#25
pulls in OffchainLabs/go-ethereum#604
pulls in OffchainLabs/nitro-testnode#173
Changes:
ArbFilteredTransactionsManagerto manage filtered transactionsArbFilteredTransactionsManager